parquet.io.api.Binary.getBytes()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(159)

本文整理了Java中parquet.io.api.Binary.getBytes()方法的一些代码示例,展示了Binary.getBytes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Binary.getBytes()方法的具体详情如下:
包路径:parquet.io.api.Binary
类名称:Binary
方法名:getBytes

Binary.getBytes介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

@Override
protected void readValue(BlockBuilder blockBuilder, Type type)
{
  if (definitionLevel == columnDescriptor.getMaxDefinitionLevel()) {
    Binary value = valuesReader.readBytes();
    type.writeSlice(blockBuilder, Decimals.encodeUnscaledValue(new BigInteger(value.getBytes())));
  }
  else if (isValueNull()) {
    blockBuilder.appendNull();
  }
}

代码示例来源:origin: prestodb/presto

List<Domain> domains = new ArrayList<>();
for (int i = 0; i < dictionarySize; i++) {
  domains.add(Domain.singleValue(type, Slices.wrappedBuffer(dictionary.decodeToBinary(i).getBytes())));

代码示例来源:origin: prestodb/presto

/**
 * Returns GMT timestamp from binary encoded parquet timestamp (12 bytes - julian date + time of day nanos).
 *
 * @param timestampBinary INT96 parquet timestamp
 * @return timestamp in millis, GMT timezone
 */
public static long getTimestampMillis(Binary timestampBinary)
{
  if (timestampBinary.length() != 12) {
    throw new PrestoException(HIVE_BAD_DATA, "Parquet timestamp must be 12 bytes, actual " + timestampBinary.length());
  }
  byte[] bytes = timestampBinary.getBytes();
  // little endian encoding - need to invert byte order
  long timeOfDayNanos = Longs.fromBytes(bytes[7], bytes[6], bytes[5], bytes[4], bytes[3], bytes[2], bytes[1], bytes[0]);
  int julianDay = Ints.fromBytes(bytes[11], bytes[10], bytes[9], bytes[8]);
  return julianDayToMillis(julianDay) + (timeOfDayNanos / NANOS_PER_MILLISECOND);
}

代码示例来源:origin: prestodb/presto

/**
 * Returns GMT timestamp from binary encoded parquet timestamp (12 bytes - julian date + time of day nanos).
 *
 * @param timestampBinary INT96 parquet timestamp
 * @return timestamp in millis, GMT timezone
 */
public static long getTimestampMillis(Binary timestampBinary)
{
  if (timestampBinary.length() != 12) {
    throw new PrestoException(NOT_SUPPORTED, "Parquet timestamp must be 12 bytes, actual " + timestampBinary.length());
  }
  byte[] bytes = timestampBinary.getBytes();
  // little endian encoding - need to invert byte order
  long timeOfDayNanos = Longs.fromBytes(bytes[7], bytes[6], bytes[5], bytes[4], bytes[3], bytes[2], bytes[1], bytes[0]);
  int julianDay = Ints.fromBytes(bytes[11], bytes[10], bytes[9], bytes[8]);
  return julianDayToMillis(julianDay) + (timeOfDayNanos / NANOS_PER_MILLISECOND);
}

代码示例来源:origin: prestodb/presto

@Override
protected void readValue(BlockBuilder blockBuilder, Type type)
{
  if (definitionLevel == columnDescriptor.getMaxDefinitionLevel()) {
    Binary binary = valuesReader.readBytes();
    Slice value;
    if (binary.length() == 0) {
      value = EMPTY_SLICE;
    }
    else {
      value = wrappedBuffer(binary.getBytes());
    }
    if (isVarcharType(type)) {
      value = truncateToLength(value, type);
    }
    if (isCharType(type)) {
      value = truncateToLengthAndTrimSpaces(value, type);
    }
    type.writeSlice(blockBuilder, value);
  }
  else if (isValueNull()) {
    blockBuilder.appendNull();
  }
}

代码示例来源:origin: prestodb/presto

@Override
protected void readValue(BlockBuilder blockBuilder, Type type)
{
  if (definitionLevel == columnDescriptor.getMaxDefinitionLevel()) {
    long decimalValue;
    // When decimals are encoded with primitive types Parquet stores unscaled values
    if (columnDescriptor.getType().equals(INT32)) {
      decimalValue = valuesReader.readInteger();
    }
    else if (columnDescriptor.getType().equals(INT64)) {
      decimalValue = valuesReader.readLong();
    }
    else {
      decimalValue = getShortDecimalValue(valuesReader.readBytes().getBytes());
    }
    type.writeLong(blockBuilder, decimalValue);
  }
  else if (isValueNull()) {
    blockBuilder.appendNull();
  }
}

代码示例来源:origin: prestodb/presto

Slice minSlice = Slices.wrappedBuffer(binaryStatistics.getMin().getBytes());
Slice maxSlice = Slices.wrappedBuffer(binaryStatistics.getMax().getBytes());
if (minSlice.compareTo(maxSlice) > 0) {
  failWithCorruptionException(failOnCorruptedParquetStatistics, column, id, binaryStatistics);

代码示例来源:origin: com.twitter/parquet-tools

public static BigInteger binaryToBigInteger(Binary value) {
  byte[] data = value.getBytes();
  if (data == null) return null;
  return new BigInteger(data);
}

代码示例来源:origin: com.twitter/parquet-tools

public static String binaryToString(Binary value) {
  byte[] data = value.getBytes();
  if (data == null) return null;
  try {
    CharBuffer buffer = UTF8_DECODER.decode(value.toByteBuffer());
    return buffer.toString();
  } catch (Throwable th) {
  }
  return "<bytes...>";
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

@Override
public String toString(ColumnReader columnReader) {
 return Arrays.toString(columnReader.getBinary().getBytes());
}
@Override

代码示例来源:origin: com.facebook.presto.hive/hive-apache

protected static Binary copy(Binary binary) {
  return Binary.fromByteArray(
    Arrays.copyOf(binary.getBytes(), binary.length()));
 }
}

代码示例来源:origin: org.apache.tajo/tajo-storage

@Override
 final public void addBinary(Binary value) {
  parent.add(new BlobDatum(ByteBuffer.wrap(value.getBytes())));
 }
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

/**
 * {@inheritDoc}
 */
@Override
public void addBinary(Binary value) {
 if (DEBUG) log(Arrays.toString(value.getBytes()));
 delegate.addBinary(value);
}

代码示例来源:origin: org.apache.tajo/tajo-storage

@Override
 final public void addBinary(Binary value) {
  parent.add(DatumFactory.createInet4(value.getBytes()));
 }
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-hive

@Override
public void addBinary(Binary value)
{
  nulls[fieldIndex] = false;
  if (types[fieldIndex] == TIMESTAMP) {
    longs[fieldIndex] = ParquetTimestampUtils.getTimestampMillis(value);
  }
  else {
    slices[fieldIndex] = wrappedBuffer(value.getBytes());
  }
}

代码示例来源:origin: com.twitter/parquet-pig

@Override
final public void addBinary(Binary value) {
 parent.add(new DataByteArray(value.getBytes()));
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

@Override
 public void writeBytes(Binary v) {
  int i = 0;
  byte[] vb = v.getBytes();
  int length = previous.length < vb.length ? previous.length : vb.length;
  for(i = 0; (i < length) && (previous[i] == vb[i]); i++);
  prefixLengthWriter.writeInteger(i);
  suffixWriter.writeBytes(Binary.fromByteArray(vb, i, vb.length - i));
  previous = vb;
 }
}

代码示例来源:origin: com.facebook.presto.hive/hive-apache

@Override
public void writeBytes(Binary v) {
 try {
  lengthWriter.writeInteger(v.length());
  out.write(v.getBytes());
 } catch (IOException e) {
  throw new ParquetEncodingException("could not write bytes", e);
 }
}

代码示例来源:origin: org.apache.tajo/tajo-storage

@Override
 final public void addBinary(Binary value) {
  try {
   ProtobufDatumFactory factory =
     ProtobufDatumFactory.get(dataType.getCode());
   Message.Builder builder = factory.newBuilder();
   builder.mergeFrom(value.getBytes());
   parent.add(factory.createDatum(builder));
  } catch (InvalidProtocolBufferException e) {
   throw new RuntimeException(e);
  }
 }
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-hive

@Override
public void addBinary(Binary value)
{
  addMissingValues();
  if (type == TIMESTAMP) {
    builder.writeLong(ParquetTimestampUtils.getTimestampMillis(value)).closeEntry();
  }
  else {
    VARBINARY.writeSlice(builder, wrappedBuffer(value.getBytes()));
  }
}

相关文章