@Test public void buildListOfRowKeyColumnExpressionsSingleNodeComparisonTest() throws Exception { List<Expression> expressions = new ArrayList<>(); RowKeyColumnExpression rvc = new RowKeyColumnExpression(); ComparisonExpression expression = mock(ComparisonExpression.class); Mockito.when(expression.getChildren()).thenReturn(Lists.<Expression>newArrayList(rvc)); RVCOffsetCompiler.RowKeyColumnExpressionOutput output = offsetCompiler.buildListOfRowKeyColumnExpressions(expression, false); List<RowKeyColumnExpression> result = output.getRowKeyColumnExpressions(); assertEquals(1,result.size()); assertEquals(rvc,result.get(0)); }
@VisibleForTesting RowKeyColumnExpressionOutput buildListOfRowKeyColumnExpressions ( Expression whereExpression, boolean isIndex) throws RowValueConstructorOffsetNotCoercibleException, RowValueConstructorOffsetInternalErrorException { boolean trailingNull = false; List<Expression> expressions; if((whereExpression instanceof AndExpression)) { expressions = whereExpression.getChildren(); } else if (whereExpression instanceof ComparisonExpression || whereExpression instanceof IsNullExpression) { expressions = Lists.newArrayList(whereExpression); } else { LOGGER.warn("Unexpected error while compiling RVC Offset, expected either a Comparison/IsNull Expression of a AndExpression got " + whereExpression.getClass().getName()); throw new RowValueConstructorOffsetInternalErrorException( "RVC Offset must specify the tables PKs."); } List<RowKeyColumnExpression> rowKeyColumnExpressionList = new ArrayList<RowKeyColumnExpression>(); for (int i = 0; i < expressions.size(); i++) { Expression child = expressions.get(i); if (!(child instanceof ComparisonExpression || child instanceof IsNullExpression)) { LOGGER.warn("Unexpected error while compiling RVC Offset"); throw new RowValueConstructorOffsetNotCoercibleException( "RVC Offset must specify the tables PKs."); } if(i == expressions.size() - 1) { if(child instanceof IsNullExpression) { trailingNull = true; } } Expression possibleRowKeyColumnExpression = child.getChildren().get(0); if (isIndex) { if (possibleRowKeyColumnExpression instanceof CoerceExpression) { possibleRowKeyColumnExpression = ((CoerceExpression) possibleRowKeyColumnExpression).getChild(); } } if (!(possibleRowKeyColumnExpression instanceof RowKeyColumnExpression)) { LOGGER.warn("Unexpected error while compiling RVC Offset"); throw new RowValueConstructorOffsetNotCoercibleException( "RVC Offset must specify the tables PKs."); } rowKeyColumnExpressionList.add((RowKeyColumnExpression) possibleRowKeyColumnExpression); } return new RowKeyColumnExpressionOutput(rowKeyColumnExpressionList,trailingNull); }
RVCOffsetCompiler { @VisibleForTesting RowKeyColumnExpressionOutput buildListOfRowKeyColumnExpressions ( Expression whereExpression, boolean isIndex) throws RowValueConstructorOffsetNotCoercibleException, RowValueConstructorOffsetInternalErrorException { boolean trailingNull = false; List<Expression> expressions; if((whereExpression instanceof AndExpression)) { expressions = whereExpression.getChildren(); } else if (whereExpression instanceof ComparisonExpression || whereExpression instanceof IsNullExpression) { expressions = Lists.newArrayList(whereExpression); } else { LOGGER.warn("Unexpected error while compiling RVC Offset, expected either a Comparison/IsNull Expression of a AndExpression got " + whereExpression.getClass().getName()); throw new RowValueConstructorOffsetInternalErrorException( "RVC Offset must specify the tables PKs."); } List<RowKeyColumnExpression> rowKeyColumnExpressionList = new ArrayList<RowKeyColumnExpression>(); for (int i = 0; i < expressions.size(); i++) { Expression child = expressions.get(i); if (!(child instanceof ComparisonExpression || child instanceof IsNullExpression)) { LOGGER.warn("Unexpected error while compiling RVC Offset"); throw new RowValueConstructorOffsetNotCoercibleException( "RVC Offset must specify the tables PKs."); } if(i == expressions.size() - 1) { if(child instanceof IsNullExpression) { trailingNull = true; } } Expression possibleRowKeyColumnExpression = child.getChildren().get(0); if (isIndex) { if (possibleRowKeyColumnExpression instanceof CoerceExpression) { possibleRowKeyColumnExpression = ((CoerceExpression) possibleRowKeyColumnExpression).getChild(); } } if (!(possibleRowKeyColumnExpression instanceof RowKeyColumnExpression)) { LOGGER.warn("Unexpected error while compiling RVC Offset"); throw new RowValueConstructorOffsetNotCoercibleException( "RVC Offset must specify the tables PKs."); } rowKeyColumnExpressionList.add((RowKeyColumnExpression) possibleRowKeyColumnExpression); } return new RowKeyColumnExpressionOutput(rowKeyColumnExpressionList,trailingNull); } }
RVCOffsetCompiler { @VisibleForTesting RowKeyColumnExpressionOutput buildListOfRowKeyColumnExpressions ( Expression whereExpression, boolean isIndex) throws RowValueConstructorOffsetNotCoercibleException, RowValueConstructorOffsetInternalErrorException { boolean trailingNull = false; List<Expression> expressions; if((whereExpression instanceof AndExpression)) { expressions = whereExpression.getChildren(); } else if (whereExpression instanceof ComparisonExpression || whereExpression instanceof IsNullExpression) { expressions = Lists.newArrayList(whereExpression); } else { LOGGER.warn("Unexpected error while compiling RVC Offset, expected either a Comparison/IsNull Expression of a AndExpression got " + whereExpression.getClass().getName()); throw new RowValueConstructorOffsetInternalErrorException( "RVC Offset must specify the tables PKs."); } List<RowKeyColumnExpression> rowKeyColumnExpressionList = new ArrayList<RowKeyColumnExpression>(); for (int i = 0; i < expressions.size(); i++) { Expression child = expressions.get(i); if (!(child instanceof ComparisonExpression || child instanceof IsNullExpression)) { LOGGER.warn("Unexpected error while compiling RVC Offset"); throw new RowValueConstructorOffsetNotCoercibleException( "RVC Offset must specify the tables PKs."); } if(i == expressions.size() - 1) { if(child instanceof IsNullExpression) { trailingNull = true; } } Expression possibleRowKeyColumnExpression = child.getChildren().get(0); if (isIndex) { if (possibleRowKeyColumnExpression instanceof CoerceExpression) { possibleRowKeyColumnExpression = ((CoerceExpression) possibleRowKeyColumnExpression).getChild(); } } if (!(possibleRowKeyColumnExpression instanceof RowKeyColumnExpression)) { LOGGER.warn("Unexpected error while compiling RVC Offset"); throw new RowValueConstructorOffsetNotCoercibleException( "RVC Offset must specify the tables PKs."); } rowKeyColumnExpressionList.add((RowKeyColumnExpression) possibleRowKeyColumnExpression); } return new RowKeyColumnExpressionOutput(rowKeyColumnExpressionList,trailingNull); } private  RVCOffsetCompiler(); }
RVCOffsetCompiler { @VisibleForTesting RowKeyColumnExpressionOutput buildListOfRowKeyColumnExpressions ( Expression whereExpression, boolean isIndex) throws RowValueConstructorOffsetNotCoercibleException, RowValueConstructorOffsetInternalErrorException { boolean trailingNull = false; List<Expression> expressions; if((whereExpression instanceof AndExpression)) { expressions = whereExpression.getChildren(); } else if (whereExpression instanceof ComparisonExpression || whereExpression instanceof IsNullExpression) { expressions = Lists.newArrayList(whereExpression); } else { LOGGER.warn("Unexpected error while compiling RVC Offset, expected either a Comparison/IsNull Expression of a AndExpression got " + whereExpression.getClass().getName()); throw new RowValueConstructorOffsetInternalErrorException( "RVC Offset must specify the tables PKs."); } List<RowKeyColumnExpression> rowKeyColumnExpressionList = new ArrayList<RowKeyColumnExpression>(); for (int i = 0; i < expressions.size(); i++) { Expression child = expressions.get(i); if (!(child instanceof ComparisonExpression || child instanceof IsNullExpression)) { LOGGER.warn("Unexpected error while compiling RVC Offset"); throw new RowValueConstructorOffsetNotCoercibleException( "RVC Offset must specify the tables PKs."); } if(i == expressions.size() - 1) { if(child instanceof IsNullExpression) { trailingNull = true; } } Expression possibleRowKeyColumnExpression = child.getChildren().get(0); if (isIndex) { if (possibleRowKeyColumnExpression instanceof CoerceExpression) { possibleRowKeyColumnExpression = ((CoerceExpression) possibleRowKeyColumnExpression).getChild(); } } if (!(possibleRowKeyColumnExpression instanceof RowKeyColumnExpression)) { LOGGER.warn("Unexpected error while compiling RVC Offset"); throw new RowValueConstructorOffsetNotCoercibleException( "RVC Offset must specify the tables PKs."); } rowKeyColumnExpressionList.add((RowKeyColumnExpression) possibleRowKeyColumnExpression); } return new RowKeyColumnExpressionOutput(rowKeyColumnExpressionList,trailingNull); } private  RVCOffsetCompiler(); static RVCOffsetCompiler getInstance(); CompiledOffset getRVCOffset(StatementContext context, FilterableStatement statement,
            boolean inJoin, boolean inUnion, OffsetNode offsetNode); }
RVCOffsetCompiler { @VisibleForTesting RowKeyColumnExpressionOutput buildListOfRowKeyColumnExpressions ( Expression whereExpression, boolean isIndex) throws RowValueConstructorOffsetNotCoercibleException, RowValueConstructorOffsetInternalErrorException { boolean trailingNull = false; List<Expression> expressions; if((whereExpression instanceof AndExpression)) { expressions = whereExpression.getChildren(); } else if (whereExpression instanceof ComparisonExpression || whereExpression instanceof IsNullExpression) { expressions = Lists.newArrayList(whereExpression); } else { LOGGER.warn("Unexpected error while compiling RVC Offset, expected either a Comparison/IsNull Expression of a AndExpression got " + whereExpression.getClass().getName()); throw new RowValueConstructorOffsetInternalErrorException( "RVC Offset must specify the tables PKs."); } List<RowKeyColumnExpression> rowKeyColumnExpressionList = new ArrayList<RowKeyColumnExpression>(); for (int i = 0; i < expressions.size(); i++) { Expression child = expressions.get(i); if (!(child instanceof ComparisonExpression || child instanceof IsNullExpression)) { LOGGER.warn("Unexpected error while compiling RVC Offset"); throw new RowValueConstructorOffsetNotCoercibleException( "RVC Offset must specify the tables PKs."); } if(i == expressions.size() - 1) { if(child instanceof IsNullExpression) { trailingNull = true; } } Expression possibleRowKeyColumnExpression = child.getChildren().get(0); if (isIndex) { if (possibleRowKeyColumnExpression instanceof CoerceExpression) { possibleRowKeyColumnExpression = ((CoerceExpression) possibleRowKeyColumnExpression).getChild(); } } if (!(possibleRowKeyColumnExpression instanceof RowKeyColumnExpression)) { LOGGER.warn("Unexpected error while compiling RVC Offset"); throw new RowValueConstructorOffsetNotCoercibleException( "RVC Offset must specify the tables PKs."); } rowKeyColumnExpressionList.add((RowKeyColumnExpression) possibleRowKeyColumnExpression); } return new RowKeyColumnExpressionOutput(rowKeyColumnExpressionList,trailingNull); } private  RVCOffsetCompiler(); static RVCOffsetCompiler getInstance(); CompiledOffset getRVCOffset(StatementContext context, FilterableStatement statement,
            boolean inJoin, boolean inUnion, OffsetNode offsetNode);  }