@Test public void testGetSortedRowValueConstructorExpressionList() { byte[] bytesValueOne = ByteBuffer.allocate(4).putInt(1).array(); byte[] bytesValueTwo = ByteBuffer.allocate(4).putInt(1).array(); List<Expression> literalExpressions = new ArrayList<>(); LiteralExpression literalChild1 = Mockito.mock(LiteralExpression.class); when(literalChild1.getDataType()).thenReturn(PInteger.INSTANCE); when(literalChild1.getBytes()).thenReturn(bytesValueOne); when(literalChild1.getDeterminism()).thenReturn(Determinism.ALWAYS); literalExpressions.add(literalChild1); LiteralExpression literalChild2 = Mockito.mock(LiteralExpression.class); when(literalChild2.getDataType()).thenReturn(PInteger.INSTANCE); when(literalChild2.getBytes()).thenReturn(bytesValueTwo); when(literalChild2.getDeterminism()).thenReturn(Determinism.ALWAYS); literalExpressions.add(literalChild2); List<Expression> expressionChildren = new ArrayList<>(); RowKeyColumnExpression rowKeyColumnExpressionMock1 = Mockito.mock(RowKeyColumnExpression.class); RowKeyColumnExpression rowKeyColumnExpressionMock2 = Mockito.mock(RowKeyColumnExpression.class); expressionChildren.add(rowKeyColumnExpressionMock1); expressionChildren.add(rowKeyColumnExpressionMock2); when(rowKeyColumnExpressionMock1.getPosition()).thenReturn(1); when(rowKeyColumnExpressionMock1.getDeterminism()).thenReturn(Determinism.ALWAYS); when(rowKeyColumnExpressionMock2.getPosition()).thenReturn(2); when(rowKeyColumnExpressionMock2.getDeterminism()).thenReturn(Determinism.ALWAYS); when(rowKeyColumnExpressionMock1.getChildren()).thenReturn(expressionChildren); when(rowKeyColumnExpressionMock2.getChildren()).thenReturn(literalExpressions); List<InListExpression.InListColumnKeyValuePair> children = new ArrayList<>(); InListExpression.InListColumnKeyValuePair rvc1 = new InListExpression.InListColumnKeyValuePair(rowKeyColumnExpressionMock1); rvc1.addToLiteralExpressionList(literalChild1); children.add(rvc1); InListExpression.InListColumnKeyValuePair rvc2 = new InListExpression.InListColumnKeyValuePair(rowKeyColumnExpressionMock2); rvc2.addToLiteralExpressionList(literalChild2); children.add(rvc2); List<Expression> result = InListExpression.getSortedRowValueConstructorExpressionList( children,true, 1); assertTrue(result.get(0).getChildren().get(0) instanceof RowKeyColumnExpression); assertTrue(result.get(0).getChildren().get(1) instanceof RowKeyColumnExpression); assertEquals(1, ((RowKeyColumnExpression)result.get(0).getChildren().get(0)).getPosition()); assertEquals(2, ((RowKeyColumnExpression)result.get(0).getChildren().get(1)).getPosition()); assertTrue(result.get(1).getChildren().get(0) instanceof LiteralExpression); assertTrue(result.get(1).getChildren().get(1) instanceof LiteralExpression); assertEquals(bytesValueOne, ((LiteralExpression)result.get(1).getChildren().get(0)).getBytes()); assertEquals(bytesValueTwo, ((LiteralExpression)result.get(1).getChildren().get(1)).getBytes()); }
public static List<Expression> getSortedRowValueConstructorExpressionList( List<InListColumnKeyValuePair> inListColumnKeyValuePairList, boolean isStateless, int numberOfRows) { List<Expression> l = new ArrayList<>(); List<Expression> keyExpressions = new ArrayList<>(); for (int i = 0; i < inListColumnKeyValuePairList.size(); i++) { keyExpressions.add(inListColumnKeyValuePairList.get(i).getRowKeyColumnExpression()); } l.add(new RowValueConstructorExpression(keyExpressions,isStateless)); List<List<Expression>> valueExpressionsList = new ArrayList<>(); for (int j = 0; j < inListColumnKeyValuePairList.size(); j++) { List<LiteralExpression> valueList = inListColumnKeyValuePairList.get(j).getLiteralExpressionList(); for (int i = 0; i < numberOfRows; i++) { if (j == 0) { valueExpressionsList.add(new ArrayList<Expression>()); } valueExpressionsList.get(i).add(valueList.get(i)); } } for (List<Expression> valueExpressions: valueExpressionsList) { l.add(new RowValueConstructorExpression(valueExpressions, isStateless)); } return l; }
InListExpression extends BaseSingleExpression { public static List<Expression> getSortedRowValueConstructorExpressionList( List<InListColumnKeyValuePair> inListColumnKeyValuePairList, boolean isStateless, int numberOfRows) { List<Expression> l = new ArrayList<>(); List<Expression> keyExpressions = new ArrayList<>(); for (int i = 0; i < inListColumnKeyValuePairList.size(); i++) { keyExpressions.add(inListColumnKeyValuePairList.get(i).getRowKeyColumnExpression()); } l.add(new RowValueConstructorExpression(keyExpressions,isStateless)); List<List<Expression>> valueExpressionsList = new ArrayList<>(); for (int j = 0; j < inListColumnKeyValuePairList.size(); j++) { List<LiteralExpression> valueList = inListColumnKeyValuePairList.get(j).getLiteralExpressionList(); for (int i = 0; i < numberOfRows; i++) { if (j == 0) { valueExpressionsList.add(new ArrayList<Expression>()); } valueExpressionsList.get(i).add(valueList.get(i)); } } for (List<Expression> valueExpressions: valueExpressionsList) { l.add(new RowValueConstructorExpression(valueExpressions, isStateless)); } return l; } }
InListExpression extends BaseSingleExpression { public static List<Expression> getSortedRowValueConstructorExpressionList( List<InListColumnKeyValuePair> inListColumnKeyValuePairList, boolean isStateless, int numberOfRows) { List<Expression> l = new ArrayList<>(); List<Expression> keyExpressions = new ArrayList<>(); for (int i = 0; i < inListColumnKeyValuePairList.size(); i++) { keyExpressions.add(inListColumnKeyValuePairList.get(i).getRowKeyColumnExpression()); } l.add(new RowValueConstructorExpression(keyExpressions,isStateless)); List<List<Expression>> valueExpressionsList = new ArrayList<>(); for (int j = 0; j < inListColumnKeyValuePairList.size(); j++) { List<LiteralExpression> valueList = inListColumnKeyValuePairList.get(j).getLiteralExpressionList(); for (int i = 0; i < numberOfRows; i++) { if (j == 0) { valueExpressionsList.add(new ArrayList<Expression>()); } valueExpressionsList.get(i).add(valueList.get(i)); } } for (List<Expression> valueExpressions: valueExpressionsList) { l.add(new RowValueConstructorExpression(valueExpressions, isStateless)); } return l; } InListExpression(); @VisibleForTesting protected  InListExpression(List<ImmutableBytesPtr> values);  InListExpression(List<Expression> keyExpressions, boolean rowKeyOrderOptimizable); }
InListExpression extends BaseSingleExpression { public static List<Expression> getSortedRowValueConstructorExpressionList( List<InListColumnKeyValuePair> inListColumnKeyValuePairList, boolean isStateless, int numberOfRows) { List<Expression> l = new ArrayList<>(); List<Expression> keyExpressions = new ArrayList<>(); for (int i = 0; i < inListColumnKeyValuePairList.size(); i++) { keyExpressions.add(inListColumnKeyValuePairList.get(i).getRowKeyColumnExpression()); } l.add(new RowValueConstructorExpression(keyExpressions,isStateless)); List<List<Expression>> valueExpressionsList = new ArrayList<>(); for (int j = 0; j < inListColumnKeyValuePairList.size(); j++) { List<LiteralExpression> valueList = inListColumnKeyValuePairList.get(j).getLiteralExpressionList(); for (int i = 0; i < numberOfRows; i++) { if (j == 0) { valueExpressionsList.add(new ArrayList<Expression>()); } valueExpressionsList.get(i).add(valueList.get(i)); } } for (List<Expression> valueExpressions: valueExpressionsList) { l.add(new RowValueConstructorExpression(valueExpressions, isStateless)); } return l; } InListExpression(); @VisibleForTesting protected  InListExpression(List<ImmutableBytesPtr> values);  InListExpression(List<Expression> keyExpressions, boolean rowKeyOrderOptimizable); static Expression create(List<Expression> children, boolean isNegate, ImmutableBytesWritable ptr, boolean rowKeyOrderOptimizable); @Override boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr); @Override int hashCode(); @Override boolean equals(Object obj); @Override PDataType getDataType(); @Override void readFields(DataInput input); @Override void write(DataOutput output); @Override final T accept(ExpressionVisitor<T> visitor); List<Expression> getKeyExpressions(); ImmutableBytesWritable getMinKey(); ImmutableBytesWritable getMaxKey(); @Override String toString(); InListExpression clone(List<Expression> l); static List<InListColumnKeyValuePair> getSortedInListColumnKeyValuePair(List<Expression> children); static List<Expression> getSortedRowValueConstructorExpressionList(
            List<InListColumnKeyValuePair> inListColumnKeyValuePairList, boolean isStateless, int numberOfRows); }
InListExpression extends BaseSingleExpression { public static List<Expression> getSortedRowValueConstructorExpressionList( List<InListColumnKeyValuePair> inListColumnKeyValuePairList, boolean isStateless, int numberOfRows) { List<Expression> l = new ArrayList<>(); List<Expression> keyExpressions = new ArrayList<>(); for (int i = 0; i < inListColumnKeyValuePairList.size(); i++) { keyExpressions.add(inListColumnKeyValuePairList.get(i).getRowKeyColumnExpression()); } l.add(new RowValueConstructorExpression(keyExpressions,isStateless)); List<List<Expression>> valueExpressionsList = new ArrayList<>(); for (int j = 0; j < inListColumnKeyValuePairList.size(); j++) { List<LiteralExpression> valueList = inListColumnKeyValuePairList.get(j).getLiteralExpressionList(); for (int i = 0; i < numberOfRows; i++) { if (j == 0) { valueExpressionsList.add(new ArrayList<Expression>()); } valueExpressionsList.get(i).add(valueList.get(i)); } } for (List<Expression> valueExpressions: valueExpressionsList) { l.add(new RowValueConstructorExpression(valueExpressions, isStateless)); } return l; } InListExpression(); @VisibleForTesting protected  InListExpression(List<ImmutableBytesPtr> values);  InListExpression(List<Expression> keyExpressions, boolean rowKeyOrderOptimizable); static Expression create(List<Expression> children, boolean isNegate, ImmutableBytesWritable ptr, boolean rowKeyOrderOptimizable); @Override boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr); @Override int hashCode(); @Override boolean equals(Object obj); @Override PDataType getDataType(); @Override void readFields(DataInput input); @Override void write(DataOutput output); @Override final T accept(ExpressionVisitor<T> visitor); List<Expression> getKeyExpressions(); ImmutableBytesWritable getMinKey(); ImmutableBytesWritable getMaxKey(); @Override String toString(); InListExpression clone(List<Expression> l); static List<InListColumnKeyValuePair> getSortedInListColumnKeyValuePair(List<Expression> children); static List<Expression> getSortedRowValueConstructorExpressionList(
            List<InListColumnKeyValuePair> inListColumnKeyValuePairList, boolean isStateless, int numberOfRows);  }