ChinmaySKulkarni commented on a change in pull request #671: PHOENIX-4845
Support using Row Value Constructors in OFFSET clause fo…
URL: https://github.com/apache/phoenix/pull/671#discussion_r363572391
##########
File path:
phoenix-core/src/main/java/org/apache/phoenix/compile/OffsetCompiler.java
##########
@@ -62,23 +82,233 @@ public SortOrder getSortOrder() {
private OffsetCompiler() {}
- public static Integer compile(StatementContext context,
FilterableStatement statement) throws SQLException {
+ // eager initialization
+ final private static OffsetCompiler OFFSET_COMPILER = getInstance();
+
+ private static OffsetCompiler getInstance() {
+ return new OffsetCompiler();
+ }
+
+ public static OffsetCompiler getOffsetCompiler() {
+ return OFFSET_COMPILER;
+ }
+
+ public CompiledOffset compile(StatementContext context,
FilterableStatement statement) throws SQLException {
OffsetNode offsetNode = statement.getOffset();
- if (offsetNode == null) { return null; }
- OffsetParseNodeVisitor visitor = new OffsetParseNodeVisitor(context);
- offsetNode.getOffsetParseNode().accept(visitor);
- return visitor.getOffset();
+ if (offsetNode == null) { return new
CompiledOffset(Optional.<Integer>absent(), Optional.<byte[]>absent()); }
+ if (offsetNode.isIntegerOffset()) {
+ OffsetParseNodeVisitor visitor = new
OffsetParseNodeVisitor(context);
+ offsetNode.getOffsetParseNode().accept(visitor);
+ Integer offset = visitor.getOffset();
+ return new CompiledOffset(Optional.fromNullable(offset),
Optional.<byte[]>absent());
+ } else {
+ // We have a RVC offset. See PHOENIX-4845
Review comment:
I feel like we should break up this entire `else` block into multiple
methods or call 1 rvcOffset-related method which calls other methods. Basically
this will help in unit testing
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services