@Test public void testHashCode() throws Exception { int valuesNumber = 500000; List<ImmutableBytesPtr> values = new ArrayList<>(valuesNumber); for (int i = 0; i < valuesNumber; i++) { values.add(new ImmutableBytesPtr(Bytes.toBytes(i))); } InListExpression exp = new InListExpression(values); long startTs = System.currentTimeMillis(); int firstHashCode = exp.hashCode(); long firstTimeCost = System.currentTimeMillis() - startTs; int restAccessNumber = 3; startTs = System.currentTimeMillis(); List<Integer> hashCodes = Lists.newArrayListWithExpectedSize(restAccessNumber); for (int i = 0; i < restAccessNumber; i++) { hashCodes.add(exp.hashCode()); } long restTimeCost = System.currentTimeMillis() - startTs; assertTrue("first time: " + firstTimeCost + " <= rest time: " + restTimeCost, firstTimeCost > restTimeCost); for (int hashCode : hashCodes) { assertEquals("hash code not equal, firstHashCode: " + firstHashCode + ", restHashCode: " + hashCode, firstHashCode, hashCode); } }
@Override public int hashCode() { if (!hashCodeSet) { final int prime = 31; int result = 1; result = prime * result + children.hashCode() + values.hashCode(); hashCode = result; hashCodeSet = true; } return hashCode; }
InListExpression extends BaseSingleExpression { @Override public int hashCode() { if (!hashCodeSet) { final int prime = 31; int result = 1; result = prime * result + children.hashCode() + values.hashCode(); hashCode = result; hashCodeSet = true; } return hashCode; } }
InListExpression extends BaseSingleExpression { @Override public int hashCode() { if (!hashCodeSet) { final int prime = 31; int result = 1; result = prime * result + children.hashCode() + values.hashCode(); hashCode = result; hashCodeSet = true; } return hashCode; } InListExpression(); @VisibleForTesting protected  InListExpression(List<ImmutableBytesPtr> values);  InListExpression(List<Expression> keyExpressions, boolean rowKeyOrderOptimizable); }
InListExpression extends BaseSingleExpression { @Override public int hashCode() { if (!hashCodeSet) { final int prime = 31; int result = 1; result = prime * result + children.hashCode() + values.hashCode(); hashCode = result; hashCodeSet = true; } return hashCode; } 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 { @Override public int hashCode() { if (!hashCodeSet) { final int prime = 31; int result = 1; result = prime * result + children.hashCode() + values.hashCode(); hashCode = result; hashCodeSet = true; } return hashCode; } 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);  }