Exemplo n.º 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);
    }
  }
Exemplo n.º 2
0
    public void appendTo(int position, BlockBuilder builder) {
      checkArgument(position >= 0 && position < positionOffsets.size());

      int offset = positionOffsets.getInt(position);

      if (slice.getByte(offset) != 0) {
        builder.appendNull();
      } else if (type == Type.FIXED_INT_64) {
        builder.append(slice.getLong(offset + SIZE_OF_BYTE));
      } else if (type == Type.DOUBLE) {
        builder.append(slice.getDouble(offset + SIZE_OF_BYTE));
      } else if (type == Type.BOOLEAN) {
        builder.append(slice.getByte(offset + SIZE_OF_BYTE) != 0);
      } else if (type == Type.VARIABLE_BINARY) {
        int sliceLength = getVariableBinaryLength(slice, offset);
        builder.append(slice.slice(offset + SIZE_OF_BYTE + SIZE_OF_INT, sliceLength));
      } else {
        throw new IllegalArgumentException("Unsupported type " + type);
      }
    }