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

x33g5p2x  于2022-01-16 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(149)

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

Binary.toByteBuffer介绍

暂无

代码示例

代码示例来源:origin: apache/hive

private Timestamp convert(Binary binary) {
 ByteBuffer buf = binary.toByteBuffer();
 buf.order(ByteOrder.LITTLE_ENDIAN);
 long timeOfDayNanos = buf.getLong();
 int julianDay = buf.getInt();
 NanoTime nt = new NanoTime(julianDay, timeOfDayNanos);
 return NanoTimeUtils.getTimestamp(nt, skipTimestampConversion);
}

代码示例来源:origin: apache/incubator-druid

/**
 * convert parquet binary decimal to BigDecimal, lifted from
 * https://github.com/apache/parquet-mr/blob/master/parquet-pig/src/main/java/org/apache/parquet/pig/convert/DecimalUtils.java#L38
 */
private static BigDecimal convertBinaryToDecimal(Binary value, int precision, int scale)
{
 // based on parquet-mr pig conversion which is based on spark conversion... yo dawg?
 if (precision <= 18) {
  ByteBuffer buffer = value.toByteBuffer();
  byte[] bytes = buffer.array();
  int start = buffer.arrayOffset() + buffer.position();
  int end = buffer.arrayOffset() + buffer.limit();
  long unscaled = 0L;
  int i = start;
  while (i < end) {
   unscaled = (unscaled << 8 | bytes[i] & 0xff);
   i++;
  }
  int bits = 8 * (end - start);
  long unscaledNew = (unscaled << (64 - bits)) >> (64 - bits);
  if (unscaledNew <= -Math.pow(10, 18) || unscaledNew >= Math.pow(10, 18)) {
   return new BigDecimal(unscaledNew);
  } else {
   return BigDecimal.valueOf(unscaledNew / Math.pow(10, scale));
  }
 } else {
  return new BigDecimal(new BigInteger(value.getBytes()), scale);
 }
}

代码示例来源:origin: apache/hive

public static NanoTime fromBinary(Binary bytes) {
 Preconditions.checkArgument(bytes.length() == 12, "Must be 12 bytes");
 ByteBuffer buf = bytes.toByteBuffer();
 buf.order(ByteOrder.LITTLE_ENDIAN);
 long timeOfDayNanos = buf.getLong();
 int julianDay = buf.getInt();
 return new NanoTime(julianDay, timeOfDayNanos);
}

代码示例来源:origin: apache/incubator-druid

IntBuffer intBuf = intervalVal.toByteBuffer().order(ByteOrder.LITTLE_ENDIAN).asIntBuffer();
int months = intBuf.get(0);
int days = intBuf.get(1);

代码示例来源:origin: org.apache.parquet/parquet-thrift

@Override
 public ByteBuffer readBinary() throws TException {
  return value.toByteBuffer();
 }
});

代码示例来源:origin: Netflix/iceberg

@Override
 public UUID read(UUID ignored) {
  ByteBuffer buffer = column.nextBinary().toByteBuffer();
  buffer.order(ByteOrder.BIG_ENDIAN);
  long mostSigBits = buffer.getLong();
  long leastSigBits = buffer.getLong();
  return new UUID(mostSigBits, leastSigBits);
 }
}

代码示例来源:origin: org.apache.parquet/parquet-column

public static NanoTime fromInt96(Int96Value int96) {
 ByteBuffer buf = int96.getInt96().toByteBuffer();
 return new NanoTime(buf.getInt(), buf.getLong());
}

代码示例来源:origin: org.apache.parquet/parquet-column

public static NanoTime fromBinary(Binary bytes) {
 Preconditions.checkArgument(bytes.length() == 12, "Must be 12 bytes");
 ByteBuffer buf = bytes.toByteBuffer();
 buf.order(ByteOrder.LITTLE_ENDIAN);
 long timeOfDayNanos = buf.getLong();
 int julianDay = buf.getInt();
 return new NanoTime(julianDay, timeOfDayNanos);
}

代码示例来源:origin: org.lasersonlab.apache.parquet/parquet-column

public static NanoTime fromBinary(Binary bytes) {
 Preconditions.checkArgument(bytes.length() == 12, "Must be 12 bytes");
 ByteBuffer buf = bytes.toByteBuffer();
 buf.order(ByteOrder.LITTLE_ENDIAN);
 long timeOfDayNanos = buf.getLong();
 int julianDay = buf.getInt();
 return new NanoTime(julianDay, timeOfDayNanos);
}

代码示例来源:origin: Netflix/iceberg

@Override
 public UTF8String read(UTF8String ignored) {
  Binary binary = column.nextBinary();
  ByteBuffer buffer = binary.toByteBuffer();
  if (buffer.hasArray()) {
   return UTF8String.fromBytes(
     buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
  } else {
   return UTF8String.fromBytes(binary.getBytes());
  }
 }
}

代码示例来源:origin: dremio/dremio-oss

@Override
 public void addBinary(Binary value) {
  holder.buffer.setBytes(0, value.toByteBuffer());
  writer.writeVarBinary(holder.start, holder.end, holder.buffer);
 }
}

代码示例来源:origin: Netflix/iceberg

@Override
 public byte[] read(byte[] reuse) {
  if (reuse != null) {
   column.nextBinary().toByteBuffer().duplicate().get(reuse);
   return reuse;
  } else {
   return column.nextBinary().getBytes();
  }
 }
}

代码示例来源:origin: org.apache.drill.exec/drill-java-exec

@Override
 public void addBinary(Binary value) {
  holder.buffer.setBytes(0, value.toByteBuffer());
  writer.write(holder);
 }
}

代码示例来源:origin: Netflix/iceberg

@Override
 public Fixed read(Fixed reuse) {
  Fixed fixed;
  if (reuse != null) {
   fixed = reuse;
  } else {
   fixed = new Fixed(schema);
  }
  column.nextBinary().toByteBuffer().get(fixed.bytes());
  return fixed;
 }
}

代码示例来源:origin: dremio/dremio-oss

@Override
public boolean setSafe(int index, ArrowBuf value, int start, int length) {
 if (index >= vector.getValueCapacity()) {
  return false;
 }
 if (usingDictionary) {
  ByteBuffer buf = currDictValToWrite.toByteBuffer();
  vector.setSafe(index, buf, buf.position(), currDictValToWrite.length());
 } else {
  vector.setSafe(index, 1, start, start + length, value);
 }
 return true;
}

代码示例来源:origin: dremio/dremio-oss

@Override
public boolean setSafe(int index, ArrowBuf value, int start, int length) {
 if (index >= nullableVarBinaryVector.getValueCapacity()) {
  return false;
 }
 if (usingDictionary) {
  ByteBuffer buf = currDictValToWrite.toByteBuffer();
  nullableVarBinaryVector.setSafe(index, buf, buf.position(), currDictValToWrite.length());
 } else {
  nullableVarBinaryVector.setSafe(index, 1, start, start + length, value);
 }
 return true;
}

代码示例来源:origin: dremio/dremio-oss

@Override
 public void addBinary(Binary value) {
  holder.buffer = buf = buf.reallocIfNeeded(value.length());
  buf.setBytes(0, value.toByteBuffer());
  holder.start = 0;
  holder.end = value.length();
  writer.writeVarChar(holder.start, holder.end, holder.buffer);
 }
}

代码示例来源:origin: dremio/dremio-oss

@Override
 public void addBinary(Binary value) {
  holder.buffer = buf = buf.reallocIfNeeded(value.length());
  buf.setBytes(0, value.toByteBuffer());
  holder.start = 0;
  holder.end = value.length();
  writer.writeVarBinary(holder.start, holder.end, holder.buffer);
 }
}

代码示例来源:origin: org.apache.drill.exec/drill-java-exec

@Override
public void addBinary(Binary value) {
 holder.buffer = buf.reallocIfNeeded(value.length());
 holder.buffer.setBytes(0, value.toByteBuffer());
 holder.start = 0;
 holder.end = value.length();
 writer.write(holder);
}

代码示例来源:origin: io.snappydata/snappy-spark-sql

/**
 * Returns the UTF8String for rowId.
 */
public final UTF8String getUTF8String(int rowId) {
 if (dictionary == null) {
  ColumnVector.Array a = getByteArray(rowId);
  return UTF8String.fromBytes(a.byteArray, a.byteArrayOffset, a.length);
 } else {
  Binary v = dictionary.decodeToBinary(dictionaryIds.getDictId(rowId));
  return org.apache.spark.util.Utils.stringFromBuffer(v.toByteBuffer());
 }
}

相关文章