Пример #1
0
  private static int valueHashCode(Type type, Slice slice, int offset) {
    boolean isNull = slice.getByte(offset) != 0;
    if (isNull) {
      return 0;
    }

    if (type == Type.FIXED_INT_64) {
      return Longs.hashCode(slice.getLong(offset + SIZE_OF_BYTE));
    } else if (type == Type.DOUBLE) {
      long longValue = Double.doubleToLongBits(slice.getDouble(offset + SIZE_OF_BYTE));
      return Longs.hashCode(longValue);
    } else if (type == Type.BOOLEAN) {
      return slice.getByte(offset + SIZE_OF_BYTE) != 0 ? 1 : 0;
    } else if (type == Type.VARIABLE_BINARY) {
      int sliceLength = getVariableBinaryLength(slice, offset);
      return slice.hashCode(offset + SIZE_OF_BYTE + SIZE_OF_INT, sliceLength);
    } else {
      throw new IllegalArgumentException("Unsupported type " + type);
    }
  }