Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
PR superseed by https://github.com/28msec/zorba/pull/7 -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/175747 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp
[Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
William Candillon has proposed merging lp:~zorba-coders/zorba/skiplimit into lp:zorba. Requested reviews: William Candillon (wcandillon) Markos Zaharioudakis (markos-za) Ghislain Fourny (gislenius) For more details, see: https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/175747 Add offset limit clauses to the FLWOR. These clauses are similar to limit and offset from SQL. For example: for $i in (1 to 10) offset 5 limit 2 return $i -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/175747 Your team Zorba Coders is subscribed to branch lp:zorba. === modified file 'src/compiler/parser/parser.y' --- src/compiler/parser/parser.y 2013-06-17 20:05:21 + +++ src/compiler/parser/parser.y 2013-07-19 07:42:35 + @@ -325,6 +325,8 @@ %token QUOTE'\' %token RBRACE '}' %token RBRACK ']' +%token OFFSET 'offset' +%token LIMIT'limit' %token RETURN 'return' %token RPAR ')' %token SATISFIES'satisfies' @@ -637,6 +639,8 @@ %type node BlockVarDecl %type node WhereClause %type node CountClause +%type node OffsetClause +%type node LimitClause %type node Wildcard /* left-hand sides: expressions */ @@ -883,7 +887,7 @@ %destructor { release_hack( $$ ); } SchemaPrefix SequenceType SequenceTypeList Setter SignList SingleType TextTest NamespaceTest TypeDeclaration TypeName TypeName_WITH_HOOK %destructor { release_hack( $$ ); } URILiteralList ValueComp CollectionDecl IndexDecl IndexKeySpec IndexKeyList IntegrityConstraintDecl CtxItemDecl CtxItemDecl2 CtxItemDecl3 %destructor { release_hack( $$ ); } CtxItemDecl4 VarDecl VarGetsDecl VarGetsDeclList VarInDecl VarInDeclList WindowVarDecl WindowVars WindowVars2 WindowVars3 FLWORWinCond -%destructor { release_hack( $$ ); } VersionDecl VFO_Decl VFO_DeclList WhereClause CountClause Wildcard DecimalFormatDecl TypedFunctionTest AnyFunctionTest TypeList +%destructor { release_hack( $$ ); } VersionDecl VFO_Decl VFO_DeclList WhereClause CountClause LimitClause OffsetClause Wildcard DecimalFormatDecl TypedFunctionTest AnyFunctionTest TypeList %destructor { release_hack( $$ ); } SwitchCaseClause SwitchCaseClauseList SwitchCaseOperandList #ifdef XQUERY_PARSER @@ -2712,8 +2716,23 @@ | OrderByClause | GroupByClause | CountClause -; - + | OffsetClause + | LimitClause +; + +OffsetClause : + OFFSET ExprSingle + { +$$ = new OffsetClause(LOC (@$), $2); + } +; + +LimitClause : + LIMIT ExprSingle + { +$$ = new LimitClause(LOC (@$), $2); + } +; FLWORClauseList : ForLetWinClause === modified file 'src/compiler/parser/scanner.l' --- src/compiler/parser/scanner.l 2013-04-23 13:20:31 + +++ src/compiler/parser/scanner.l 2013-07-19 07:42:35 + @@ -557,6 +557,8 @@ by { return token::BY; } stable { return token::STABLE; } or { return token::OR; } +limit { return token::LIMIT; } +offset { return token::OFFSET; } return { return token::RETURN; } #ifdef JSONIQ_SCANNER select { return token::RETURN; } === modified file 'src/compiler/parsetree/parsenode_print_xml_visitor.cpp' --- src/compiler/parsetree/parsenode_print_xml_visitor.cpp 2013-06-07 13:46:26 + +++ src/compiler/parsetree/parsenode_print_xml_visitor.cpp 2013-07-19 07:42:35 + @@ -726,6 +726,8 @@ BEGIN_END_TAG (ContextItemExpr) BEGIN_END_TAG (CopyNamespacesDecl) BEGIN_END_TAG (CountClause) +BEGIN_END_TAG (LimitClause) +BEGIN_END_TAG (OffsetClause) BEGIN_END_TAG (DefaultCollationDecl) BEGIN_END_TAG (DeleteExpr) END_TAG (DirAttr) === modified file 'src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp' --- src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp 2013-07-01 18:59:06 + +++ src/compiler/parsetree/parsenode_print_xqdoc_visitor.cpp 2013-07-19 07:42:35 + @@ -1529,6 +1529,8 @@ XQDOC_NO_BEGIN_END_TAG (VarRef) XQDOC_NO_BEGIN_END_TAG (VFO_DeclList) XQDOC_NO_BEGIN_END_TAG (WhereClause) +XQDOC_NO_BEGIN_END_TAG (OffsetClause) +XQDOC_NO_BEGIN_END_TAG (LimitClause) XQDOC_NO_BEGIN_END_TAG (WhileExpr) XQDOC_NO_BEGIN_END_TAG (Wildcard) XQDOC_NO_BEGIN_END_TAG (WindowClause) === modified file 'src/compiler/parsetree/parsenode_print_xquery_visitor.cpp' --- src/compiler/parsetree/parsenode_print_xquery_visitor.cpp 2013-06-07 13:46:26 + +++ src/compiler/parsetree/parsenode_print_xquery_visitor.cpp 2013-07-19 07:42:35 + @@ -1199,6 +1199,24 @@ } DEFAULT_END_VISIT (WhereClause) +void* begin_visit(const OffsetClause n) +{ + os offset ; + n.get_offset()-accept(*this); + return 0; +} +DEFAULT_END_VISIT (OffsetClause) + + +void* begin_visit(const LimitClause n) +{ + os limit ; + n.get_limit()-accept(*this); + return 0; +} +DEFAULT_END_VISIT (LimitClause) + + void* begin_visit(const CountClause n) { os count $
Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
Review: Approve -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/175747 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp
Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
Hi William, I think that count$i-where$i aka offset/limit can be optimized, but in most cases not in terms of subsequence: it sets an offset or a limit on the number of tuples, not on the number of items (a tuple may well produce zero, or more than one item in the end). I think that an early exit, or skipping, in FLWOR iterators should be possible when encountering a count$i-where$i. Markos is probably more familiar with this code than I am though. Does it make sense? -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp
Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
It feels that the current proposal is actually quite efficient and has a predictable performance. But I like the beauty of having the count/where syntactic sugar. So I'm not sure what do to. -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp
Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
Hi Ghislain, Thank you so much for this insight. That makes perfect sense. Now I see two way this can go: - offset/limit is just a syntactic sugar for count/where and using the subsequence optimisation for it is completely orthogonal to this merge proposal. - offset/limit doesn't make sense if the subsequence optimisation is not used. If so, could I have some pointers on how to implement this optimisation? -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp
Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
I have the feeling that this could and should be made more general, i.e., introduce limit ExprSingle and offset ExprSingle as regular FLWOR clauses, like any other clauses, that you can put everywhere (as intermediate clauses), and that are syntactic sugars for count $i where $i le ExprSingle and count $i where $i gt ExprSingle respectively. That way, there would no longer be any need to go through syntactic options as above as they behave like any other clause. Concretely, I think that it comes down to something as simple as: IntermediateClause ::= InitialClause | WhereClause | GroupByClause | OrderByClause | CountClause | OffsetClause | LimitClause OffsetClause ::= offset ExprSingle LimitClause ::= limit ExprSingle -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp
Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
Review: Needs Fixing -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp
[Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
The proposal to merge lp:~zorba-coders/zorba/skiplimit into lp:zorba has been updated. Status: Approved = Needs review For more details, see: https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp
Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
Review: Needs Information 1. I think Dana will have to approve the adding of proprietary syntax to do what is essentially syntactic sugar for fn:subsequence(). 2. Why allow multiple offset/limit clauses when, as far as I can understand, only the last offset/limit clause takes effect? -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp
Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
1. I make an email loop to get Dana's approval. 2. There are couple of options, I wasn't sure which one to pick: a) (offset ExprSingle)? (limit ExprSingle)? b) (offset ExprSingle) | (limit ExprSingle) | (limit ExprSingle offset ExprSingle) | (offset ExprSingle limit ExprSingle) c) ((offset ExprSingle) | (limit ExprSingle)?)* I ended up doing c) but I can do a) or b). -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp
[Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
William Candillon has proposed merging lp:~zorba-coders/zorba/skiplimit into lp:zorba. Commit message: Add offset limit clauses to the FLWOR. Requested reviews: William Candillon (wcandillon) Markos Zaharioudakis (markos-za) For more details, see: https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Add offset limit clauses to the FLWOR. These clauses are similar to limit and offset from SQL. For example: for $i in (1 to 10) offset 5 limit 2 return $i -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Your team Zorba Coders is subscribed to branch lp:zorba. === modified file 'src/compiler/parser/parser.y' --- src/compiler/parser/parser.y 2013-06-17 20:05:21 + +++ src/compiler/parser/parser.y 2013-07-05 04:45:36 + @@ -325,6 +325,8 @@ %token QUOTE'\' %token RBRACE '}' %token RBRACK ']' +%token OFFSET'offset' +%token LIMIT'limit' %token RETURN 'return' %token RPAR ')' %token SATISFIES'satisfies' @@ -693,6 +695,7 @@ %type expr ExprSimple %type expr ExtensionExpr %type expr FLWORExpr +%type expr OffsetLimitExpr %type expr ReturnExpr %type expr PostfixExpr %type expr FunctionCall @@ -904,7 +907,7 @@ %destructor { release_hack( $$ ); } AxisStep // exprnodes -%destructor { release_hack( $$ ); } AdditiveExpr AndExpr CDataSection CastExpr CastableExpr CommonContent ComparisonExpr CompAttrConstructor CompCommentConstructor CompDocConstructor CompElemConstructor CompPIConstructor CompNamespaceConstructor CompTextConstructor ComputedConstructor Constructor ContextItemExpr DirCommentConstructor DirElemConstructor DirElemContent DirPIConstructor DirectConstructor BracedExpr BlockExpr EnclosedStatementsAndOptionalExpr BlockStatement Statement Statements StatementsAndExpr StatementsAndOptionalExpr StatementsAndOptionalExprTop SwitchStatement TypeswitchStatement TryStatement CatchListStatement CatchStatement ApplyStatement IfStatement FLWORStatement ReturnStatement VarDeclStatement Expr ExprSingle ExprSimple ExtensionExpr FLWORExpr ReturnExpr PostfixExpr FunctionCall IfExpr InstanceofExpr IntersectExceptExpr Literal MultiplicativeExpr NumericLiteral OrExpr OrderedExpr ParenthesizedExpr PathExpr Predicate PrimaryExpr QuantifiedExpr QueryBody RangeExpr RelativePathExpr StepExpr StringLiteral TreatExpr StringConcatExpr SwitchExpr TypeswitchExpr UnaryExpr UnionExpr UnorderedExpr ValidateExpr ValueExpr SimpleMapExpr VarRef TryExpr CatchListExpr CatchExpr DeleteExpr InsertExpr RenameExpr ReplaceExpr TransformExpr VarNameList VarNameDecl AssignStatement ExitStatement WhileStatement FlowCtlStatement QNAME EQNAME FUNCTION_NAME FTContainsExpr +%destructor { release_hack( $$ ); } AdditiveExpr AndExpr CDataSection CastExpr CastableExpr CommonContent ComparisonExpr CompAttrConstructor CompCommentConstructor CompDocConstructor CompElemConstructor CompPIConstructor CompNamespaceConstructor CompTextConstructor ComputedConstructor Constructor ContextItemExpr DirCommentConstructor DirElemConstructor DirElemContent DirPIConstructor DirectConstructor BracedExpr BlockExpr EnclosedStatementsAndOptionalExpr BlockStatement Statement Statements StatementsAndExpr StatementsAndOptionalExpr StatementsAndOptionalExprTop SwitchStatement TypeswitchStatement TryStatement CatchListStatement CatchStatement ApplyStatement IfStatement FLWORStatement ReturnStatement VarDeclStatement Expr ExprSingle ExprSimple ExtensionExpr FLWORExpr OffsetLimitExpr ReturnExpr PostfixExpr FunctionCall IfExpr InstanceofExpr IntersectExceptExpr Literal MultiplicativeExpr NumericLiteral OrExpr OrderedExpr ParenthesizedExpr PathExpr Predicate PrimaryExpr QuantifiedExpr QueryBody RangeExpr RelativePathExpr StepExpr StringLiteral TreatExpr StringConcatExpr SwitchExpr TypeswitchExpr UnaryExpr UnionExpr UnorderedExpr ValidateExpr ValueExpr SimpleMapExpr VarRef TryExpr CatchListExpr CatchExpr DeleteExpr InsertExpr RenameExpr ReplaceExpr TransformExpr VarNameList VarNameDecl AssignStatement ExitStatement WhileStatement FlowCtlStatement QNAME EQNAME FUNCTION_NAME FTContainsExpr // internal non-terminals with values %destructor { delete $$; } FunctionSig VarNameAndType NameTestList DecimalFormatParam DecimalFormatParamList @@ -973,6 +976,10 @@ %nonassoc SIMPLEMAPEXPR_REDUCE %left BANG +%nonassoc SKIPLIMIT_REDUCE +%left OFFSET +%left LIMIT + /*_ * * resolve shift-reduce conflict for @@ -2584,6 +2591,19 @@ FLWORExpr : +FLWORClauseList %prec SKIPLIMIT_REDUCE OffsetLimitExpr ReturnExpr +{ + OffsetLimitExpr *sl = dynamic_castOffsetLimitExpr*($2); + ReturnExpr *re = dynamic_castReturnExpr*($3); + $$ = new FLWORExpr(LOC(@$), + dynamic_castFLWORClauseList*($1), +
[Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
The proposal to merge lp:~zorba-coders/zorba/skiplimit into lp:zorba has been updated. Commit Message changed to: Add offset limit clauses to the FLWOR. For more details, see: https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp
[Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
The proposal to merge lp:~zorba-coders/zorba/skiplimit into lp:zorba has been updated. Status: Needs review = Approved For more details, see: https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp
Re: [Zorba-coders] [Merge] lp:~zorba-coders/zorba/skiplimit into lp:zorba
Review: Approve -- https://code.launchpad.net/~zorba-coders/zorba/skiplimit/+merge/173126 Your team Zorba Coders is subscribed to branch lp:zorba. -- Mailing list: https://launchpad.net/~zorba-coders Post to : zorba-coders@lists.launchpad.net Unsubscribe : https://launchpad.net/~zorba-coders More help : https://help.launchpad.net/ListHelp