http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp index 109e5a9..206033a 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp @@ -22,7 +22,7 @@ use tpch; declare function q22_customer_tmp() { ( - SELECT c.c_acctbal AS c_acctbal, c.c_custkey AS c_custkey, substring(c.c_phone,1,2) AS cntrycode + SELECT c.c_acctbal AS c_acctbal, c.c_custkey AS c_custkey, substring(c.c_phone,0,2) AS cntrycode FROM Customer AS c ) };
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql/query-issue562/query-issue562.3.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql/query-issue562/query-issue562.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql/query-issue562/query-issue562.3.query.sqlpp index 3c99324..531e17f 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql/query-issue562/query-issue562.3.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-sql/query-issue562/query-issue562.3.query.sqlpp @@ -30,7 +30,7 @@ declare function q22_customer_tmp() { ( SELECT c.c_acctbal AS c_acctbal, c.c_custkey AS c_custkey, phone_substr AS cntrycode FROM Customer AS c - WITH phone_substr AS substring(c.c_phone,1,2) + WITH phone_substr AS substring(c.c_phone,0,2) WHERE phone_substr = '13' OR phone_substr = '31' OR phone_substr = '23' OR phone_substr = '29' OR phone_substr = '30' OR phone_substr = '18' OR phone_substr = '17' ) http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-with-index/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-with-index/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-with-index/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp index bdd7323..d33a095 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-with-index/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-with-index/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp @@ -22,7 +22,7 @@ use tpch; declare function q22_customer_tmp() { ( - select element {'c_acctbal':c.c_acctbal,'c_custkey':c.c_custkey,'cntrycode':SUBSTR(c.c_phone,1,2)} + select element {'c_acctbal':c.c_acctbal,'c_custkey':c.c_custkey,'cntrycode':SUBSTR(c.c_phone,0,2)} from Customer as c ) }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-with-index/query-issue562/query-issue562.3.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-with-index/query-issue562/query-issue562.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-with-index/query-issue562/query-issue562.3.query.sqlpp index dc54947..4cd5d54 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-with-index/query-issue562/query-issue562.3.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch-with-index/query-issue562/query-issue562.3.query.sqlpp @@ -30,14 +30,14 @@ declare function q22_customer_tmp() { ( select element {'c_acctbal':c.c_acctbal,'c_custkey':c.c_custkey,'cntrycode':phone_substr} from Customer as c - let phone_substr = tpch.substring(c.c_phone,1,2) + let phone_substr = tpch.substring(c.c_phone,0,2) where ((phone_substr = '13') or (phone_substr = '31') or (phone_substr = '23') or (phone_substr = '29') or (phone_substr = '30') or (phone_substr = '18') or (phone_substr = '17')) ) }; with avg as tpch.coll_avg(( select element c.c_acctbal from Customer as c - let phone_substr = tpch.substring(c.c_phone,1,2) + let phone_substr = tpch.substring(c.c_phone,0,2) where ((c.c_acctbal > 0.0) and ((phone_substr = '13') or (phone_substr = '31') or (phone_substr = '23') or (phone_substr = '29') or (phone_substr = '30') or (phone_substr = '18') or (phone_substr = '17'))) )) select element {'cntrycode':cntrycode,'numcust':tpch.count(ct),'totacctbal':tpch.coll_sum(( http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp index bdd7323..d33a095 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.query.sqlpp @@ -22,7 +22,7 @@ use tpch; declare function q22_customer_tmp() { ( - select element {'c_acctbal':c.c_acctbal,'c_custkey':c.c_custkey,'cntrycode':SUBSTR(c.c_phone,1,2)} + select element {'c_acctbal':c.c_acctbal,'c_custkey':c.c_custkey,'cntrycode':SUBSTR(c.c_phone,0,2)} from Customer as c ) }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.3.query.sqlpp ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.3.query.sqlpp index dc54947..4cd5d54 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.3.query.sqlpp +++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tpch/query-issue562/query-issue562.3.query.sqlpp @@ -30,14 +30,14 @@ declare function q22_customer_tmp() { ( select element {'c_acctbal':c.c_acctbal,'c_custkey':c.c_custkey,'cntrycode':phone_substr} from Customer as c - let phone_substr = tpch.substring(c.c_phone,1,2) + let phone_substr = tpch.substring(c.c_phone,0,2) where ((phone_substr = '13') or (phone_substr = '31') or (phone_substr = '23') or (phone_substr = '29') or (phone_substr = '30') or (phone_substr = '18') or (phone_substr = '17')) ) }; with avg as tpch.coll_avg(( select element c.c_acctbal from Customer as c - let phone_substr = tpch.substring(c.c_phone,1,2) + let phone_substr = tpch.substring(c.c_phone,0,2) where ((c.c_acctbal > 0.0) and ((phone_substr = '13') or (phone_substr = '31') or (phone_substr = '23') or (phone_substr = '29') or (phone_substr = '30') or (phone_substr = '18') or (phone_substr = '17'))) )) select element {'cntrycode':cntrycode,'numcust':tpch.count(ct),'totacctbal':tpch.coll_sum(( http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/explain/explain_field_access/explain_field_access.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/explain/explain_field_access/explain_field_access.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/explain/explain_field_access/explain_field_access.1.adm index 5f25e64..98cedcc 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/explain/explain_field_access/explain_field_access.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/explain/explain_field_access/explain_field_access.1.adm @@ -28,7 +28,7 @@ distribute result [$$36] -- ONE_TO_ONE_EXCHANGE |PARTITIONED| project ([$$34, $$37]) -- STREAM_PROJECT |PARTITIONED| - assign [$$37] <- [substring($$41.getField("department_id"), 1)] + assign [$$37] <- [substring($$41.getField("department_id"), 0)] -- ASSIGN |PARTITIONED| project ([$$34, $$41]) -- STREAM_PROJECT |PARTITIONED| http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/explain/explain_field_access_closed/explain_field_access_closed.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/explain/explain_field_access_closed/explain_field_access_closed.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/explain/explain_field_access_closed/explain_field_access_closed.1.adm index 92df490..e2e1c91 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/explain/explain_field_access_closed/explain_field_access_closed.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/explain/explain_field_access_closed/explain_field_access_closed.1.adm @@ -28,7 +28,7 @@ distribute result [$$35] -- ONE_TO_ONE_EXCHANGE |PARTITIONED| project ([$$33, $$36]) -- STREAM_PROJECT |PARTITIONED| - assign [$$36, $$33] <- [substring($$e.getField(1), 1), $$e.getField(2)] + assign [$$36, $$33] <- [substring($$e.getField(1), 0), $$e.getField(2)] -- ASSIGN |PARTITIONED| project ([$$e]) -- STREAM_PROJECT |PARTITIONED| http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/string/position/position.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/position/position.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/position/position.1.adm index 5c54d04..76e3e97 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/position/position.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/position/position.1.adm @@ -1 +1 @@ -[ 3, -1 ] +[ 2, -1 ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_position/regexp_position.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_position/regexp_position.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_position/regexp_position.1.adm index 83ee615..428917f 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_position/regexp_position.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_position/regexp_position.1.adm @@ -1,15 +1,15 @@ -1 +0 -1 -1 -1 -1 +0 +0 +0 -1 -1 +0 -1 -1 -1 -1 -1 -1 +0 +0 +0 +0 -1 -1 +0 http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_position_with_flag/regexp_position_with_flag.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_position_with_flag/regexp_position_with_flag.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_position_with_flag/regexp_position_with_flag.1.adm index f962896..fa99af7 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_position_with_flag/regexp_position_with_flag.1.adm +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/string/regexp_position_with_flag/regexp_position_with_flag.1.adm @@ -1 +1 @@ -{ "result1": 1 } +{ "result1": 0 } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/findbinary/findbinary.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/findbinary/findbinary.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/findbinary/findbinary.1.adm new file mode 100644 index 0000000..0fae953 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/findbinary/findbinary.1.adm @@ -0,0 +1 @@ +[ 1, 1, 1, 7, -1 ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/findbinary2/findbinary2.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/findbinary2/findbinary2.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/findbinary2/findbinary2.1.adm new file mode 100644 index 0000000..299ae43 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/findbinary2/findbinary2.1.adm @@ -0,0 +1 @@ +[ 1, 3, -1 ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/position/position.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/position/position.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/position/position.1.adm new file mode 100644 index 0000000..613f89b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/position/position.1.adm @@ -0,0 +1 @@ +[ 1, 4, -1 ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/regexp_position/regexp_position.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/regexp_position/regexp_position.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/regexp_position/regexp_position.1.adm new file mode 100644 index 0000000..613f89b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/regexp_position/regexp_position.1.adm @@ -0,0 +1 @@ +[ 1, 4, -1 ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/regexp_position_with_flag/regexp_position_with_flag.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/regexp_position_with_flag/regexp_position_with_flag.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/regexp_position_with_flag/regexp_position_with_flag.1.adm new file mode 100644 index 0000000..613f89b --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/regexp_position_with_flag/regexp_position_with_flag.1.adm @@ -0,0 +1 @@ +[ 1, 4, -1 ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/subbinary/subbinary.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/subbinary/subbinary.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/subbinary/subbinary.1.adm new file mode 100644 index 0000000..f5e809d --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/subbinary/subbinary.1.adm @@ -0,0 +1 @@ +[ "AABB", "AABB", "AABB", "BBCC", "CCDD" ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/subbinary2/subbinary2.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/subbinary2/subbinary2.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/subbinary2/subbinary2.1.adm new file mode 100644 index 0000000..275d27a --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/subbinary2/subbinary2.1.adm @@ -0,0 +1 @@ +[ "AABBCCDDEEFF", "AABBCCDDEEFF", "AABBCCDDEEFF", "BBCCDDEEFF", "CCDDEEFF" ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/substring/substring.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/substring/substring.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/substring/substring.1.adm new file mode 100644 index 0000000..b92a705 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/substring/substring.1.adm @@ -0,0 +1 @@ +[ "ab", "ab", "ab", "bc", "cd" ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/substring2/substring2.1.adm ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/substring2/substring2.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/substring2/substring2.1.adm new file mode 100644 index 0000000..e341861 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/stringoffset/substring2/substring2.1.adm @@ -0,0 +1 @@ +[ "abcdefg", "abcdefg", "abcdefg", "bcdefg", "cdefg" ] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.3.ast index cd2f25c..813591c 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/find/find.3.ast @@ -11,7 +11,7 @@ OrderedListConstructor [ ] ] = - LiteralExpr [LONG] [1] + LiteralExpr [LONG] [0] ] OperatorExpr [ FunctionCall test.find-binary@2[ @@ -23,7 +23,7 @@ OrderedListConstructor [ ] ] = - LiteralExpr [LONG] [1] + LiteralExpr [LONG] [0] ] OperatorExpr [ FunctionCall test.find-binary@3[ @@ -36,7 +36,7 @@ OrderedListConstructor [ LiteralExpr [LONG] [1] ] = - LiteralExpr [LONG] [5] + LiteralExpr [LONG] [4] ] OperatorExpr [ FunctionCall test.find-binary@3[ @@ -46,7 +46,7 @@ OrderedListConstructor [ FunctionCall test.hex@1[ LiteralExpr [STRING] [aabb] ] - LiteralExpr [LONG] [0] + - LiteralExpr [LONG] [1] ] = FunctionCall test.find-binary@2[ @@ -68,7 +68,7 @@ OrderedListConstructor [ ] ] = - LiteralExpr [LONG] [0] + - LiteralExpr [LONG] [1] ] OperatorExpr [ FunctionCall test.find-binary@2[ @@ -80,7 +80,7 @@ OrderedListConstructor [ ] ] = - LiteralExpr [LONG] [3] + LiteralExpr [LONG] [2] ] OperatorExpr [ FunctionCall test.find-binary@2[ @@ -92,7 +92,7 @@ OrderedListConstructor [ ] ] = - LiteralExpr [LONG] [0] + - LiteralExpr [LONG] [1] ] FunctionCall test.find-binary@2[ FunctionCall test.hex@1[ http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.3.ast index 6ec8199..5a232ae 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/binary/subbinary/subbinary_01.3.ast @@ -42,7 +42,7 @@ OrderedListConstructor [ FunctionCall test.hex@1[ LiteralExpr [STRING] [aabbccdd] ] - LiteralExpr [LONG] [1] + LiteralExpr [LONG] [0] FunctionCall test.binary-length@1[ FunctionCall test.hex@1[ LiteralExpr [STRING] [aabbccdd] @@ -59,7 +59,7 @@ OrderedListConstructor [ FunctionCall test.hex@1[ LiteralExpr [STRING] [aabbccdd] ] - LiteralExpr [LONG] [2] + LiteralExpr [LONG] [1] LiteralExpr [LONG] [1] ] = @@ -72,7 +72,7 @@ OrderedListConstructor [ FunctionCall test.hex@1[ LiteralExpr [STRING] [aabbccdd] ] - LiteralExpr [LONG] [2] + LiteralExpr [LONG] [1] ] = FunctionCall test.hex@1[ @@ -84,7 +84,7 @@ OrderedListConstructor [ FunctionCall test.hex@1[ LiteralExpr [STRING] [aabbccdd] ] - LiteralExpr [LONG] [5] + LiteralExpr [LONG] [4] LiteralExpr [LONG] [0] ] = @@ -97,7 +97,7 @@ OrderedListConstructor [ FunctionCall test.hex@1[ LiteralExpr [STRING] [aabbccdd] ] - LiteralExpr [LONG] [4] + LiteralExpr [LONG] [3] LiteralExpr [LONG] [1] ] = @@ -110,7 +110,7 @@ OrderedListConstructor [ FunctionCall test.hex@1[ LiteralExpr [STRING] [aabbccdd] ] - LiteralExpr [LONG] [2] + LiteralExpr [LONG] [1] LiteralExpr [LONG] [2] ] = @@ -147,7 +147,7 @@ OrderedListConstructor [ FunctionCall test.hex@1[ LiteralExpr [STRING] [aabbccdd] ] - LiteralExpr [LONG] [1] + LiteralExpr [LONG] [0] LiteralExpr [LONG] [256] ] = @@ -160,7 +160,7 @@ OrderedListConstructor [ FunctionCall test.hex@1[ LiteralExpr [STRING] [aabbccdd] ] - LiteralExpr [LONG] [2] + LiteralExpr [LONG] [1] LiteralExpr [LONG] [256] ] = @@ -173,7 +173,7 @@ OrderedListConstructor [ FunctionCall test.hex@1[ LiteralExpr [STRING] [aabbccdd] ] - LiteralExpr [LONG] [2] + LiteralExpr [LONG] [1] - LiteralExpr [LONG] [1] ] = http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.3.ast index 9e8f66d..a86d0a4 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr01/substr01.3.ast @@ -5,7 +5,7 @@ RecordConstructor [ : FunctionCall null.substring@2[ LiteralExpr [STRING] [Hello World] - LiteralExpr [LONG] [10] + LiteralExpr [LONG] [9] ] ) ( @@ -13,7 +13,7 @@ RecordConstructor [ : FunctionCall null.substring@2[ LiteralExpr [STRING] [This is a test string] - LiteralExpr [LONG] [21] + LiteralExpr [LONG] [20] ] ) ( @@ -21,7 +21,7 @@ RecordConstructor [ : FunctionCall null.substring@2[ LiteralExpr [STRING] [This is a test string] - LiteralExpr [LONG] [22] + LiteralExpr [LONG] [21] ] ) ( @@ -50,7 +50,7 @@ RecordConstructor [ LiteralExpr [STRING] [This is a another test string] ] ] - LiteralExpr [LONG] [21] + LiteralExpr [LONG] [20] ] ) ( @@ -59,11 +59,15 @@ RecordConstructor [ FunctionCall null.substring@2[ LiteralExpr [STRING] [UC Irvine] OperatorExpr [ - FunctionCall null.string-length@1[ - LiteralExpr [STRING] [UC Irvine] + OperatorExpr [ + FunctionCall null.string-length@1[ + LiteralExpr [STRING] [UC Irvine] + ] + / + LiteralExpr [LONG] [2] ] - / - LiteralExpr [LONG] [2] + - + LiteralExpr [LONG] [1] ] ] ) http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.3.ast index ccd395d..f85b949 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr04/substr04.3.ast @@ -5,32 +5,32 @@ Variable [ Name=$a ] FROM [ OrderedListConstructor [ FunctionCall null.substring@3[ LiteralExpr [STRING] [hello world] - LiteralExpr [LONG] [7] + LiteralExpr [LONG] [6] LiteralExpr [LONG] [5] ] FunctionCall null.substring@3[ LiteralExpr [STRING] [hello world] - LiteralExpr [LONG] [1] + LiteralExpr [LONG] [0] LiteralExpr [LONG] [11] ] FunctionCall null.substring@3[ LiteralExpr [STRING] [hello world] - LiteralExpr [LONG] [3] + LiteralExpr [LONG] [2] LiteralExpr [LONG] [9] ] FunctionCall null.substring@3[ LiteralExpr [STRING] [ABCD] - LiteralExpr [LONG] [3] + LiteralExpr [LONG] [2] LiteralExpr [LONG] [2] ] FunctionCall null.substring@3[ LiteralExpr [STRING] [ABCD] - LiteralExpr [LONG] [1] + LiteralExpr [LONG] [0] LiteralExpr [LONG] [4] ] FunctionCall null.substring@3[ LiteralExpr [STRING] [UC Irvine] - LiteralExpr [LONG] [4] + LiteralExpr [LONG] [3] OperatorExpr [ FunctionCall null.string-length@1[ LiteralExpr [STRING] [UC Irvine] @@ -41,7 +41,7 @@ FROM [ OrderedListConstructor [ ] FunctionCall null.substring@3[ LiteralExpr [STRING] [UC Irvine] - LiteralExpr [LONG] [1] + LiteralExpr [LONG] [0] FunctionCall null.string-length@1[ LiteralExpr [STRING] [UC Irvine] ] @@ -49,9 +49,9 @@ FROM [ OrderedListConstructor [ FunctionCall null.substring@3[ FunctionCall null.substring@2[ LiteralExpr [STRING] [UC Irvine] - LiteralExpr [LONG] [4] + LiteralExpr [LONG] [3] ] - LiteralExpr [LONG] [1] + LiteralExpr [LONG] [0] FunctionCall null.string-length@1[ LiteralExpr [STRING] [Irvine] ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.3.ast index d02dca1..685a3b4 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr05/substr05.3.ast @@ -6,7 +6,7 @@ FunctionCall test.substring@3[ Variable [ Name=$a ] Field=name ] - LiteralExpr [LONG] [4] + LiteralExpr [LONG] [3] OperatorExpr [ FunctionCall test.string-length@1[ FieldAccessor [ http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.3.ast index 4f1d3f4..f27bf4d 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substr06/substr06.3.ast @@ -6,7 +6,7 @@ FunctionCall test.substring@2[ Variable [ Name=$a ] Field=name ] - LiteralExpr [LONG] [4] + LiteralExpr [LONG] [3] ] ] FROM [ FunctionCall asterix.dataset@1[ http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.3.ast index ed84aaa..c170655 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-1/substring2-1.3.ast @@ -6,7 +6,7 @@ RecordConstructor [ : FunctionCall test.substring@2[ LiteralExpr [STRING] [HEllow] - LiteralExpr [LONG] [2] + LiteralExpr [LONG] [1] ] ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.3.ast index 865e373..358d135 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring2-3/substring2-3.3.ast @@ -6,7 +6,7 @@ RecordConstructor [ : FunctionCall test.substring@2[ LiteralExpr [STRING] [HEllow] - LiteralExpr [LONG] [10] + LiteralExpr [LONG] [9] ] ) ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.3.ast index cd3b906..d24c5b8 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/string/substring_01/substring_01.3.ast @@ -3,7 +3,7 @@ Query: SELECT ELEMENT [ FunctionCall test.substring@3[ Variable [ Name=$x ] - LiteralExpr [LONG] [2] + LiteralExpr [LONG] [1] LiteralExpr [LONG] [3] ] ] http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.24.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.24.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.24.ast index 7425817..cdd8a53 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.24.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.24.ast @@ -16,7 +16,7 @@ FunctionCall TinySocial.substring@2[ Variable [ Name=$message ] Field=message ] - LiteralExpr [LONG] [30] + LiteralExpr [LONG] [29] ] msg ] @@ -78,7 +78,7 @@ Orderby Variable [ Name=$message ] Field=message ] - LiteralExpr [LONG] [30] + LiteralExpr [LONG] [29] ] ASC http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.24.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.24.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.24.ast index 7425817..cdd8a53 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.24.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite/tinysocial-suite.24.ast @@ -16,7 +16,7 @@ FunctionCall TinySocial.substring@2[ Variable [ Name=$message ] Field=message ] - LiteralExpr [LONG] [30] + LiteralExpr [LONG] [29] ] msg ] @@ -78,7 +78,7 @@ Orderby Variable [ Name=$message ] Field=message ] - LiteralExpr [LONG] [30] + LiteralExpr [LONG] [29] ] ASC http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast index 9b94363..0ad2c82 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch-sql-like/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast @@ -27,7 +27,7 @@ FunctionDecl q22_customer_tmp([]) { Variable [ Name=$c ] Field=c_phone ] - LiteralExpr [LONG] [1] + LiteralExpr [LONG] [0] LiteralExpr [LONG] [2] ] ) http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast index 9b94363..0ad2c82 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/q22_global_sales_opportunity/q22_global_sales_opportunity.3.ast @@ -27,7 +27,7 @@ FunctionDecl q22_customer_tmp([]) { Variable [ Name=$c ] Field=c_phone ] - LiteralExpr [LONG] [1] + LiteralExpr [LONG] [0] LiteralExpr [LONG] [2] ] ) http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.3.ast ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.3.ast index d9f60e3..928d5e2 100644 --- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.3.ast +++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tpch/query-issue562/query-issue562.3.ast @@ -36,7 +36,7 @@ FunctionDecl q22_customer_tmp([]) { Variable [ Name=$c ] Field=c_phone ] - LiteralExpr [LONG] [1] + LiteralExpr [LONG] [0] LiteralExpr [LONG] [2] ] Where @@ -109,7 +109,7 @@ Let Variable [ Name=$avg ] Variable [ Name=$c ] Field=c_phone ] - LiteralExpr [LONG] [1] + LiteralExpr [LONG] [0] LiteralExpr [LONG] [2] ] Where http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_stringoffset.xml ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_stringoffset.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_stringoffset.xml new file mode 100644 index 0000000..f7da162 --- /dev/null +++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_stringoffset.xml @@ -0,0 +1,67 @@ +<!-- + ! Licensed to the Apache Software Foundation (ASF) under one + ! or more contributor license agreements. See the NOTICE file + ! distributed with this work for additional information + ! regarding copyright ownership. The ASF licenses this file + ! to you under the Apache License, Version 2.0 (the + ! "License"); you may not use this file except in compliance + ! with the License. You may obtain a copy of the License at + ! + ! http://www.apache.org/licenses/LICENSE-2.0 + ! + ! Unless required by applicable law or agreed to in writing, + ! software distributed under the License is distributed on an + ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ! KIND, either express or implied. See the License for the + ! specific language governing permissions and limitations + ! under the License. + !--> +<test-suite xmlns="urn:xml.testframework.asterix.apache.org" ResultOffsetPath="results" QueryOffsetPath="queries_sqlpp" QueryFileExtension=".sqlpp"> + <test-group name="stringoffset"> + <test-case FilePath="stringoffset"> + <compilation-unit name="position"> + <output-dir compare="Text">position</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="stringoffset"> + <compilation-unit name="regexp_position"> + <output-dir compare="Text">regexp_position</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="stringoffset"> + <compilation-unit name="regexp_position_with_flag"> + <output-dir compare="Text">regexp_position_with_flag</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="stringoffset"> + <compilation-unit name="substring"> + <output-dir compare="Text">substring</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="stringoffset"> + <compilation-unit name="substring2"> + <output-dir compare="Text">substring2</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="stringoffset"> + <compilation-unit name="subbinary"> + <output-dir compare="Text">subbinary</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="stringoffset"> + <compilation-unit name="subbinary2"> + <output-dir compare="Text">subbinary2</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="stringoffset"> + <compilation-unit name="findbinary"> + <output-dir compare="Text">findbinary</output-dir> + </compilation-unit> + </test-case> + <test-case FilePath="stringoffset"> + <compilation-unit name="findbinary2"> + <output-dir compare="Text">findbinary2</output-dir> + </compilation-unit> + </test-case> + </test-group> +</test-suite> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/CompilerProperties.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/CompilerProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/CompilerProperties.java index 0d29943..821b6e1 100644 --- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/CompilerProperties.java +++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/CompilerProperties.java @@ -57,7 +57,8 @@ public class CompilerProperties extends AbstractProperties { + "other integer values dictate the number of query execution parallel partitions. The system will " + "fall back to use the number of all available CPU cores in the cluster as the degree of parallelism " + "if the number set by a user is too large or too small"), - COMPILER_PREGELIX_HOME(STRING, "~/pregelix", "Pregelix installation root directory"); + COMPILER_PREGELIX_HOME(STRING, "~/pregelix", "Pregelix installation root directory"), + COMPILER_STRINGOFFSET(INTEGER, 0, "Position of a first character in a String/Binary (0 or 1)"); private final IOptionType type; private final Object defaultValue; @@ -91,7 +92,7 @@ public class CompilerProperties extends AbstractProperties { @Override public boolean hidden() { - return this == COMPILER_PREGELIX_HOME; + return this == COMPILER_PREGELIX_HOME || this == COMPILER_STRINGOFFSET; } } @@ -132,4 +133,9 @@ public class CompilerProperties extends AbstractProperties { public String getPregelixHome() { return accessor.getString(Option.COMPILER_PREGELIX_HOME); } + + public int getStringOffset() { + int value = accessor.getInt(Option.COMPILER_STRINGOFFSET); + return value > 0 ? 1 : 0; + } } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-doc/src/main/markdown/builtins/2_string_common.md ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/2_string_common.md b/asterixdb/asterix-doc/src/main/markdown/builtins/2_string_common.md index 95d0550..1f56c4c 100644 --- a/asterixdb/asterix-doc/src/main/markdown/builtins/2_string_common.md +++ b/asterixdb/asterix-doc/src/main/markdown/builtins/2_string_common.md @@ -211,8 +211,8 @@ * `string` : a `string` that might contain the pattern, * `string_pattern` : a pattern `string` to be matched. * Return Value: - * the first position that `string_pattern` appears within `string`, - or -1 if it does not appear, + * the first position that `string_pattern` appears within `string` + (starting at 0), or -1 if it does not appear, * `missing` if any argument is a `missing` value, * `null` if any argument is a `null` value but no argument is a `missing` value, * any other non-string input value will cause a type error. @@ -306,8 +306,8 @@ * `string_flag` : (Optional) a `string` with flags to be used during regular expression matching. * The following modes are enabled with these flags: dotall (s), multiline (m), case_insensitive (i), and comments and whitespace (x). * Return Value: - * the first position that the regular expression `string_pattern` appears in `string`, - or -1 if it does not appear. + * the first position that the regular expression `string_pattern` appears in `string` + (starting at 0), or -1 if it does not appear. * `missing` if any argument is a `missing` value, * `null` if any argument is a `null` value but no argument is a `missing` value, * any other non-string input value will cause a type error. @@ -363,7 +363,7 @@ * Returns a string formed by repeating the input `string` `n` times. * Arguments: * `string` : a `string` to be repeated, - * `offset` : an `tinyint`/`smallint`/`integer`/`bigint` value as the starting offset of the substring in `string`. + * `n` : an `tinyint`/`smallint`/`integer`/`bigint` value - how many times the string should be repeated. * Return Value: * a string that repeats the input `string` `n` times, * `missing` if any argument is a `missing` value, @@ -471,7 +471,8 @@ * Returns the substring from the given string `string` based on the given start offset `offset` with the optional `length`. * Arguments: * `string` : a `string` to be extracted, - * `offset` : an `tinyint`/`smallint`/`integer`/`bigint` value as the starting offset of the substring in `string`, + * `offset` : an `tinyint`/`smallint`/`integer`/`bigint` value as the starting offset of the substring in `string` + (starting at 0), * `length` : (Optional) an an `tinyint`/`smallint`/`integer`/`bigint` value as the length of the substring. * Return Value: * a `string` that represents the substring, http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-doc/src/main/markdown/builtins/3_binary.md ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-doc/src/main/markdown/builtins/3_binary.md b/asterixdb/asterix-doc/src/main/markdown/builtins/3_binary.md index 2902496..82a68be 100644 --- a/asterixdb/asterix-doc/src/main/markdown/builtins/3_binary.md +++ b/asterixdb/asterix-doc/src/main/markdown/builtins/3_binary.md @@ -97,7 +97,7 @@ * Arguments: * `binary` : a `binary` to be extracted, * `offset` : a `tinyint`, `smallint`, `integer`, or `bigint` value - as the starting offset of the sub binary in `binary`, + as the starting offset of the sub binary in `binary` (starting at 0), * `length` : (Optional) a `tinyint`, `smallint`, `integer`, or `bigint` value as the length of the sub binary. * Return Value: http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/IFunctionTypeInferer.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/IFunctionTypeInferer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/IFunctionTypeInferer.java index b8e27e1..97042e2 100644 --- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/IFunctionTypeInferer.java +++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/IFunctionTypeInferer.java @@ -19,11 +19,12 @@ package org.apache.asterix.om.functions; +import org.apache.asterix.common.config.CompilerProperties; import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression; import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment; public interface IFunctionTypeInferer { - void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException; + void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractStringOffsetConfigurableDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractStringOffsetConfigurableDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractStringOffsetConfigurableDescriptor.java new file mode 100644 index 0000000..3f8f45f --- /dev/null +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractStringOffsetConfigurableDescriptor.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.asterix.runtime.evaluators.functions; + +import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; + +public abstract class AbstractStringOffsetConfigurableDescriptor extends AbstractScalarFunctionDynamicDescriptor { + + private static final long serialVersionUID = 1L; + + protected int stringOffset; + + @Override + public void setImmutableStates(Object... states) { + stringOffset = (int) states[0]; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringPositionDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringPositionDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringPositionDescriptor.java index 6f4d116..e9ec211 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringPositionDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringPositionDescriptor.java @@ -24,7 +24,8 @@ import java.io.IOException; import org.apache.asterix.om.functions.BuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; -import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; +import org.apache.asterix.om.functions.IFunctionTypeInferer; +import org.apache.asterix.runtime.functions.FunctionTypeInferers; import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; @@ -32,7 +33,7 @@ import org.apache.hyracks.api.context.IHyracksTaskContext; import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.data.std.primitive.UTF8StringPointable; -public class StringPositionDescriptor extends AbstractScalarFunctionDynamicDescriptor { +public class StringPositionDescriptor extends AbstractStringOffsetConfigurableDescriptor { private static final long serialVersionUID = 1L; public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { @@ -40,6 +41,11 @@ public class StringPositionDescriptor extends AbstractScalarFunctionDynamicDescr public IFunctionDescriptor createFunctionDescriptor() { return new StringPositionDescriptor(); } + + @Override + public IFunctionTypeInferer createFunctionTypeInferer() { + return FunctionTypeInferers.SET_STRING_OFFSET; + } }; @Override @@ -47,6 +53,8 @@ public class StringPositionDescriptor extends AbstractScalarFunctionDynamicDescr return new IScalarEvaluatorFactory() { private static final long serialVersionUID = 1L; + private final int baseOffset = stringOffset; + @Override public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException { return new AbstractBinaryStringIntEval(ctx, args[0], args[1], @@ -55,7 +63,7 @@ public class StringPositionDescriptor extends AbstractScalarFunctionDynamicDescr @Override protected int compute(UTF8StringPointable left, UTF8StringPointable right) throws IOException { int pos = UTF8StringPointable.find(left, right, false); - return pos < 0 ? pos : pos + 1; + return pos < 0 ? pos : pos + baseOffset; } }; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRegExpPositionDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRegExpPositionDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRegExpPositionDescriptor.java index 1bb0fdc..b39c473 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRegExpPositionDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRegExpPositionDescriptor.java @@ -24,8 +24,9 @@ import java.io.IOException; import org.apache.asterix.om.functions.BuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; -import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; +import org.apache.asterix.om.functions.IFunctionTypeInferer; import org.apache.asterix.runtime.evaluators.functions.utils.RegExpMatcher; +import org.apache.asterix.runtime.functions.FunctionTypeInferers; import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; @@ -33,7 +34,7 @@ import org.apache.hyracks.api.context.IHyracksTaskContext; import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.data.std.primitive.UTF8StringPointable; -public class StringRegExpPositionDescriptor extends AbstractScalarFunctionDynamicDescriptor { +public class StringRegExpPositionDescriptor extends AbstractStringOffsetConfigurableDescriptor { private static final long serialVersionUID = 1L; public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { @@ -41,6 +42,11 @@ public class StringRegExpPositionDescriptor extends AbstractScalarFunctionDynami public IFunctionDescriptor createFunctionDescriptor() { return new StringRegExpPositionDescriptor(); } + + @Override + public IFunctionTypeInferer createFunctionTypeInferer() { + return FunctionTypeInferers.SET_STRING_OFFSET; + } }; @Override @@ -48,6 +54,8 @@ public class StringRegExpPositionDescriptor extends AbstractScalarFunctionDynami return new IScalarEvaluatorFactory() { private static final long serialVersionUID = 1L; + private final int baseOffset = stringOffset; + @Override public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException { return new AbstractBinaryStringIntEval(ctx, args[0], args[1], @@ -55,11 +63,10 @@ public class StringRegExpPositionDescriptor extends AbstractScalarFunctionDynami private final RegExpMatcher matcher = new RegExpMatcher(); @Override - protected int compute(UTF8StringPointable srcPtr, UTF8StringPointable patternPtr) - throws IOException { + protected int compute(UTF8StringPointable srcPtr, UTF8StringPointable patternPtr) { matcher.build(srcPtr, patternPtr); int pos = matcher.postion(); - return pos < 0 ? pos : pos + 1; + return pos < 0 ? pos : pos + baseOffset; } }; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRegExpPositionWithFlagDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRegExpPositionWithFlagDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRegExpPositionWithFlagDescriptor.java index 35eb3b1..16d428f 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRegExpPositionWithFlagDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringRegExpPositionWithFlagDescriptor.java @@ -24,8 +24,9 @@ import java.io.IOException; import org.apache.asterix.om.functions.BuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; -import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; +import org.apache.asterix.om.functions.IFunctionTypeInferer; import org.apache.asterix.runtime.evaluators.functions.utils.RegExpMatcher; +import org.apache.asterix.runtime.functions.FunctionTypeInferers; import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; @@ -33,7 +34,7 @@ import org.apache.hyracks.api.context.IHyracksTaskContext; import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.data.std.primitive.UTF8StringPointable; -public class StringRegExpPositionWithFlagDescriptor extends AbstractScalarFunctionDynamicDescriptor { +public class StringRegExpPositionWithFlagDescriptor extends AbstractStringOffsetConfigurableDescriptor { private static final long serialVersionUID = 1L; public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { @@ -41,6 +42,11 @@ public class StringRegExpPositionWithFlagDescriptor extends AbstractScalarFuncti public IFunctionDescriptor createFunctionDescriptor() { return new StringRegExpPositionWithFlagDescriptor(); } + + @Override + public IFunctionTypeInferer createFunctionTypeInferer() { + return FunctionTypeInferers.SET_STRING_OFFSET; + } }; @Override @@ -48,6 +54,8 @@ public class StringRegExpPositionWithFlagDescriptor extends AbstractScalarFuncti return new IScalarEvaluatorFactory() { private static final long serialVersionUID = 1L; + private final int baseOffset = stringOffset; + @Override public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws HyracksDataException { return new AbstractTripleStringIntEval(ctx, args[0], args[1], args[2], @@ -56,10 +64,10 @@ public class StringRegExpPositionWithFlagDescriptor extends AbstractScalarFuncti @Override protected int compute(UTF8StringPointable srcPtr, UTF8StringPointable patternPtr, - UTF8StringPointable flagPtr) throws IOException { + UTF8StringPointable flagPtr) { matcher.build(srcPtr, patternPtr, flagPtr); int pos = matcher.postion(); - return pos < 0 ? pos : pos + 1; + return pos < 0 ? pos : pos + baseOffset; } }; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java index 5a36942..8ebfb94 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java @@ -26,10 +26,11 @@ import org.apache.asterix.common.exceptions.RuntimeDataException; import org.apache.asterix.om.functions.BuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.asterix.om.functions.IFunctionTypeInferer; import org.apache.asterix.om.types.ATypeTag; import org.apache.asterix.om.types.hierachy.ATypeHierarchy; -import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; import org.apache.asterix.runtime.exceptions.TypeMismatchException; +import org.apache.asterix.runtime.functions.FunctionTypeInferers; import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; @@ -43,13 +44,18 @@ import org.apache.hyracks.data.std.util.GrowableArray; import org.apache.hyracks.data.std.util.UTF8StringBuilder; import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; -public class Substring2Descriptor extends AbstractScalarFunctionDynamicDescriptor { +public class Substring2Descriptor extends AbstractStringOffsetConfigurableDescriptor { private static final long serialVersionUID = 1L; public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { @Override public IFunctionDescriptor createFunctionDescriptor() { return new Substring2Descriptor(); } + + @Override + public IFunctionTypeInferer createFunctionTypeInferer() { + return FunctionTypeInferers.SET_STRING_OFFSET; + } }; @Override @@ -57,6 +63,8 @@ public class Substring2Descriptor extends AbstractScalarFunctionDynamicDescripto return new IScalarEvaluatorFactory() { private static final long serialVersionUID = 1L; + private final int baseOffset = stringOffset; + @Override public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException { return new IScalarEvaluator() { @@ -78,7 +86,8 @@ public class Substring2Descriptor extends AbstractScalarFunctionDynamicDescripto byte[] bytes = argStart.getByteArray(); int offset = argStart.getStartOffset(); - int start = ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 1, bytes, offset) - 1; + int start = ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 1, bytes, offset) + - baseOffset; bytes = argString.getByteArray(); offset = argString.getStartOffset(); int len = argString.getLength(); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java index 28bbe08..d2a1203 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java @@ -26,10 +26,11 @@ import org.apache.asterix.common.exceptions.RuntimeDataException; import org.apache.asterix.om.functions.BuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.asterix.om.functions.IFunctionTypeInferer; import org.apache.asterix.om.types.ATypeTag; import org.apache.asterix.om.types.hierachy.ATypeHierarchy; -import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; import org.apache.asterix.runtime.exceptions.TypeMismatchException; +import org.apache.asterix.runtime.functions.FunctionTypeInferers; import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; @@ -43,7 +44,7 @@ import org.apache.hyracks.data.std.util.GrowableArray; import org.apache.hyracks.data.std.util.UTF8StringBuilder; import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; -public class SubstringDescriptor extends AbstractScalarFunctionDynamicDescriptor { +public class SubstringDescriptor extends AbstractStringOffsetConfigurableDescriptor { private static final long serialVersionUID = 1L; @@ -52,6 +53,11 @@ public class SubstringDescriptor extends AbstractScalarFunctionDynamicDescriptor public IFunctionDescriptor createFunctionDescriptor() { return new SubstringDescriptor(); } + + @Override + public IFunctionTypeInferer createFunctionTypeInferer() { + return FunctionTypeInferers.SET_STRING_OFFSET; + } }; @Override @@ -59,6 +65,8 @@ public class SubstringDescriptor extends AbstractScalarFunctionDynamicDescriptor return new IScalarEvaluatorFactory() { private static final long serialVersionUID = 1L; + private final int baseOffset = stringOffset; + @Override public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException { return new IScalarEvaluator() { @@ -85,7 +93,8 @@ public class SubstringDescriptor extends AbstractScalarFunctionDynamicDescriptor byte[] bytes = argStart.getByteArray(); int offset = argStart.getStartOffset(); - int start = ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 0, bytes, offset) - 1; + int start = ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 0, bytes, offset) + - baseOffset; bytes = argLen.getByteArray(); offset = argLen.getStartOffset(); http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractFindBinaryEvaluator.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractFindBinaryEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractFindBinaryEvaluator.java index 827b43e..c88fe25 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractFindBinaryEvaluator.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractFindBinaryEvaluator.java @@ -35,8 +35,9 @@ import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; public abstract class AbstractFindBinaryEvaluator extends AbstractBinaryScalarEvaluator { private static final ATypeTag[] EXPECTED_INPUT_TAG = { ATypeTag.BINARY, ATypeTag.BINARY }; - protected String functionName; - protected AMutableInt64 result = new AMutableInt64(-1); + protected final int baseOffset; + protected final String functionName; + protected final AMutableInt64 result = new AMutableInt64(-1); protected final ByteArrayPointable textPtr = new ByteArrayPointable(); protected final ByteArrayPointable wordPtr = new ByteArrayPointable(); @@ -45,8 +46,9 @@ public abstract class AbstractFindBinaryEvaluator extends AbstractBinaryScalarEv SerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(BuiltinType.AINT64); public AbstractFindBinaryEvaluator(IHyracksTaskContext context, IScalarEvaluatorFactory[] copyEvaluatorFactories, - String functionName) throws HyracksDataException { + int baseOffset, String functionName) throws HyracksDataException { super(context, copyEvaluatorFactories); + this.baseOffset = baseOffset; this.functionName = functionName; } @@ -64,9 +66,9 @@ public abstract class AbstractFindBinaryEvaluator extends AbstractBinaryScalarEv checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAG, textTag, wordTag); textPtr.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1, pointables[0].getLength() - 1); wordPtr.set(pointables[1].getByteArray(), pointables[0].getStartOffset() + 1, pointables[1].getLength() - 1); - result.setValue(1L + indexOf(textPtr.getByteArray(), textPtr.getContentStartOffset(), - textPtr.getContentLength(), wordPtr.getByteArray(), wordPtr.getContentStartOffset(), - wordPtr.getContentLength(), fromOffset)); + int pos = indexOf(textPtr.getByteArray(), textPtr.getContentStartOffset(), textPtr.getContentLength(), + wordPtr.getByteArray(), wordPtr.getContentStartOffset(), wordPtr.getContentLength(), fromOffset); + result.setValue(pos < 0 ? pos : pos + baseOffset); intSerde.serialize(result, dataOutput); resultPointable.set(resultStorage); } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java index cd7b7d3..fc049a4 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java @@ -36,13 +36,15 @@ public abstract class AbstractSubBinaryEvaluator extends AbstractBinaryScalarEva private ByteArrayPointable byteArrayPointable = new ByteArrayPointable(); private byte[] metaBuffer = new byte[5]; + protected final int baseOffset; protected final String functionName; private static final ATypeTag[] EXPECTED_INPUT_TAGS = { ATypeTag.BINARY, ATypeTag.INTEGER }; public AbstractSubBinaryEvaluator(IHyracksTaskContext context, IScalarEvaluatorFactory[] copyEvaluatorFactories, - String functionName) throws HyracksDataException { + int baseOffset, String functionName) throws HyracksDataException { super(context, copyEvaluatorFactories); + this.baseOffset = baseOffset; this.functionName = functionName; } @@ -67,9 +69,8 @@ public abstract class AbstractSubBinaryEvaluator extends AbstractBinaryScalarEva int subStart; - // strange SQL index convention subStart = ATypeHierarchy.getIntegerValue(BuiltinFunctions.SUBBINARY_FROM.getName(), 1, startBytes, offset) - - 1; + - baseOffset; int totalLength = byteArrayPointable.getContentLength(); int subLength = getSubLength(tuple); @@ -78,7 +79,10 @@ public abstract class AbstractSubBinaryEvaluator extends AbstractBinaryScalarEva subStart = 0; } - if (subStart >= totalLength || subLength < 0) { + if (subStart >= totalLength) { + subStart = 0; + subLength = 0; + } else if (subLength < 0) { subLength = 0; } else if (subLength > totalLength // for the IntMax case || subStart + subLength > totalLength) { @@ -88,6 +92,7 @@ public abstract class AbstractSubBinaryEvaluator extends AbstractBinaryScalarEva dataOutput.write(ATypeTag.BINARY.serialize()); int metaLength = VarLenIntEncoderDecoder.encode(subLength, metaBuffer, 0); dataOutput.write(metaBuffer, 0, metaLength); + dataOutput.write(byteArrayPointable.getByteArray(), byteArrayPointable.getContentStartOffset() + subStart, subLength); } catch (IOException e) { http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java index 61a24c4..307585d 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java @@ -22,7 +22,9 @@ package org.apache.asterix.runtime.evaluators.functions.binary; import org.apache.asterix.om.functions.BuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; -import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; +import org.apache.asterix.om.functions.IFunctionTypeInferer; +import org.apache.asterix.runtime.evaluators.functions.AbstractStringOffsetConfigurableDescriptor; +import org.apache.asterix.runtime.functions.FunctionTypeInferers; import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; @@ -30,13 +32,18 @@ import org.apache.hyracks.api.context.IHyracksTaskContext; import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; -public class FindBinaryDescriptor extends AbstractScalarFunctionDynamicDescriptor { +public class FindBinaryDescriptor extends AbstractStringOffsetConfigurableDescriptor { private static final long serialVersionUID = 1L; public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { @Override public IFunctionDescriptor createFunctionDescriptor() { return new FindBinaryDescriptor(); } + + @Override + public IFunctionTypeInferer createFunctionTypeInferer() { + return FunctionTypeInferers.SET_STRING_OFFSET; + } }; @Override @@ -49,11 +56,13 @@ public class FindBinaryDescriptor extends AbstractScalarFunctionDynamicDescripto return new IScalarEvaluatorFactory() { private static final long serialVersionUID = 1L; + private final int baseOffset = stringOffset; + @Override public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException { - return new AbstractFindBinaryEvaluator(ctx, args, getIdentifier().getName()) { + return new AbstractFindBinaryEvaluator(ctx, args, baseOffset, getIdentifier().getName()) { @Override - protected int getFromOffset(IFrameTupleReference tuple) throws HyracksDataException { + protected int getFromOffset(IFrameTupleReference tuple) { return 0; } }; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java index 71f8459..243d344 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java @@ -22,8 +22,10 @@ package org.apache.asterix.runtime.evaluators.functions.binary; import org.apache.asterix.om.functions.BuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.asterix.om.functions.IFunctionTypeInferer; import org.apache.asterix.om.types.hierachy.ATypeHierarchy; -import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; +import org.apache.asterix.runtime.evaluators.functions.AbstractStringOffsetConfigurableDescriptor; +import org.apache.asterix.runtime.functions.FunctionTypeInferers; import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; @@ -31,7 +33,7 @@ import org.apache.hyracks.api.context.IHyracksTaskContext; import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; -public class FindBinaryFromDescriptor extends AbstractScalarFunctionDynamicDescriptor { +public class FindBinaryFromDescriptor extends AbstractStringOffsetConfigurableDescriptor { private static final long serialVersionUID = 1L; public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { @@ -39,6 +41,11 @@ public class FindBinaryFromDescriptor extends AbstractScalarFunctionDynamicDescr public IFunctionDescriptor createFunctionDescriptor() { return new FindBinaryFromDescriptor(); } + + @Override + public IFunctionTypeInferer createFunctionTypeInferer() { + return FunctionTypeInferers.SET_STRING_OFFSET; + } }; @Override @@ -51,13 +58,15 @@ public class FindBinaryFromDescriptor extends AbstractScalarFunctionDynamicDescr return new IScalarEvaluatorFactory() { private static final long serialVersionUID = 1L; + private final int baseOffset = stringOffset; + @Override public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException { - return new AbstractFindBinaryEvaluator(ctx, args, getIdentifier().getName()) { + return new AbstractFindBinaryEvaluator(ctx, args, baseOffset, getIdentifier().getName()) { @Override protected int getFromOffset(IFrameTupleReference tuple) throws HyracksDataException { return ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 2, - pointables[2].getByteArray(), pointables[2].getStartOffset()); + pointables[2].getByteArray(), pointables[2].getStartOffset()) - baseOffset; } }; } http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java index a677072..3b07c6c 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java @@ -22,7 +22,9 @@ package org.apache.asterix.runtime.evaluators.functions.binary; import org.apache.asterix.om.functions.BuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; -import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; +import org.apache.asterix.om.functions.IFunctionTypeInferer; +import org.apache.asterix.runtime.evaluators.functions.AbstractStringOffsetConfigurableDescriptor; +import org.apache.asterix.runtime.functions.FunctionTypeInferers; import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator; import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; @@ -30,13 +32,18 @@ import org.apache.hyracks.api.context.IHyracksTaskContext; import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; -public class SubBinaryFromDescriptor extends AbstractScalarFunctionDynamicDescriptor { +public class SubBinaryFromDescriptor extends AbstractStringOffsetConfigurableDescriptor { private static final long serialVersionUID = 1L; public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { @Override public IFunctionDescriptor createFunctionDescriptor() { return new SubBinaryFromDescriptor(); } + + @Override + public IFunctionTypeInferer createFunctionTypeInferer() { + return FunctionTypeInferers.SET_STRING_OFFSET; + } }; @Override @@ -49,11 +56,13 @@ public class SubBinaryFromDescriptor extends AbstractScalarFunctionDynamicDescri return new IScalarEvaluatorFactory() { private static final long serialVersionUID = 1L; + private final int baseOffset = stringOffset; + @Override public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException { - return new AbstractSubBinaryEvaluator(ctx, args, getIdentifier().getName()) { + return new AbstractSubBinaryEvaluator(ctx, args, baseOffset, getIdentifier().getName()) { @Override - protected int getSubLength(IFrameTupleReference tuple) throws HyracksDataException { + protected int getSubLength(IFrameTupleReference tuple) { return Integer.MAX_VALUE; } };
