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

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

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

Binary.length介绍

暂无

代码示例

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

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

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

  1. @Override
  2. int sizeOf(Object value) {
  3. return ((Binary) value).length();
  4. }
  5. }

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

  1. @Override
  2. public boolean isSmallerThan(long size) {
  3. return !hasNonNullValue() || ((min.length() + max.length()) < size);
  4. }

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

  1. @Override
  2. public final void writeBytes(Binary v) {
  3. if (v.length() != length) {
  4. throw new IllegalArgumentException("Fixed Binary size " + v.length() +
  5. " does not match field type length " + length);
  6. }
  7. try {
  8. v.writeTo(out);
  9. } catch (IOException e) {
  10. throw new ParquetEncodingException("could not write fixed bytes", e);
  11. }
  12. }

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

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

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

  1. @Override
  2. public void addBinary(Binary value) {
  3. final int length = value.length();
  4. final byte[] bytes = value.getBytes();
  5. /* set the bytes in LE format in the buffer of decimal vector, we will swap
  6. * the bytes while writing into the vector.
  7. */
  8. writer.writeBigEndianBytesToDecimal(bytes);
  9. }
  10. }

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

  1. @Override
  2. String stringifyNotNull(Binary value) {
  3. if (value.length() != 12) {
  4. return BINARY_INVALID;
  5. }
  6. ByteBuffer buffer = value.toByteBuffer().order(ByteOrder.LITTLE_ENDIAN);
  7. int pos = buffer.position();
  8. String months = UNSIGNED_STRINGIFIER.stringify(buffer.getInt(pos));
  9. String days = UNSIGNED_STRINGIFIER.stringify(buffer.getInt(pos + 4));
  10. String millis = UNSIGNED_STRINGIFIER.stringify(buffer.getInt(pos + 8));
  11. return "interval(" + months + " months, " + days + " days, " + millis + " millis)";
  12. }
  13. };

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

  1. @Override
  2. public void addBinary(Binary value) {
  3. holder.buffer = buf = buf.reallocIfNeeded(value.length());
  4. buf.setBytes(0, value.toByteBuffer());
  5. holder.start = 0;
  6. holder.end = value.length();
  7. writer.writeVarChar(holder.start, holder.end, holder.buffer);
  8. }
  9. }

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

  1. @Override
  2. String stringifyNotNull(Binary value) {
  3. if (value.length() != 12) {
  4. return BINARY_INVALID;
  5. }
  6. ByteBuffer buffer = value.toByteBuffer().order(ByteOrder.LITTLE_ENDIAN);
  7. int pos = buffer.position();
  8. String months = UNSIGNED_STRINGIFIER.stringify(buffer.getInt(pos));
  9. String days = UNSIGNED_STRINGIFIER.stringify(buffer.getInt(pos + 4));
  10. String millis = UNSIGNED_STRINGIFIER.stringify(buffer.getInt(pos + 8));
  11. return "interval(" + months + " months, " + days + " days, " + millis + " millis)";
  12. }
  13. };

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

  1. @Override
  2. public void addBinary(Binary value) {
  3. holder.buffer = buf.reallocIfNeeded(value.length());
  4. holder.buffer.setBytes(0, value.toByteBuffer());
  5. holder.start = 0;
  6. holder.end = value.length();
  7. writer.write(holder);
  8. }

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

  1. public void writeBytes(Binary v) {
  2. //for rawdata, length(4 bytes int) is stored, followed by the binary content itself
  3. rawDataByteSize += v.length() + 4;
  4. currentWriter.writeBytes(v);
  5. checkFallback();
  6. }

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

  1. @Override
  2. public void addBinary(Binary value) {
  3. holder.buffer = buf = buf.reallocIfNeeded(value.length());
  4. buf.setBytes(0, value.toByteBuffer());
  5. holder.start = 0;
  6. holder.end = value.length();
  7. writer.writeVarBinary(holder.start, holder.end, holder.buffer);
  8. }
  9. }

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

  1. @Override
  2. public void addBinary(Binary value) {
  3. holder.buffer = buf = buf.reallocIfNeeded(value.length());
  4. buf.setBytes(0, value.toByteBuffer());
  5. holder.start = 0;
  6. holder.end = value.length();
  7. writer.write(holder);
  8. }
  9. }

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

  1. @Override
  2. public void addBinary(Binary value) {
  3. holder.buffer = buf = buf.reallocIfNeeded(value.length());
  4. buf.setBytes(0, value.toByteBuffer());
  5. holder.start = 0;
  6. holder.end = value.length();
  7. writer.write(holder);
  8. }
  9. }

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

  1. @Override
  2. public void writeBytes(Binary v) {
  3. try {
  4. lengthWriter.writeInteger(v.length());
  5. v.writeTo(out);
  6. } catch (IOException e) {
  7. throw new ParquetEncodingException("could not write bytes", e);
  8. }
  9. }

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

  1. @Override
  2. public final void writeBytes(Binary v) {
  3. try {
  4. out.writeInt(v.length());
  5. v.writeTo(out);
  6. } catch (IOException e) {
  7. throw new ParquetEncodingException("could not write bytes", e);
  8. }
  9. }

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

  1. @Override
  2. public boolean setSafe(int index, ArrowBuf value, int start, int length) {
  3. if (index >= vector.getValueCapacity()) {
  4. return false;
  5. }
  6. if (usingDictionary) {
  7. ByteBuffer buf = currDictValToWrite.toByteBuffer();
  8. vector.setSafe(index, buf, buf.position(), currDictValToWrite.length());
  9. } else {
  10. vector.setSafe(index, 1, start, start + length, value);
  11. }
  12. return true;
  13. }

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

  1. @Override
  2. public boolean setSafe(int index, DrillBuf value, int start, int length) {
  3. if (index >= nullableVarBinaryVector.getValueCapacity()) {
  4. return false;
  5. }
  6. if (usingDictionary) {
  7. ByteBuffer buf = currDictValToWrite.toByteBuffer();
  8. mutator.setSafe(index, buf, buf.position(), currDictValToWrite.length());
  9. } else {
  10. mutator.setSafe(index, 1, start, start + length, value);
  11. }
  12. return true;
  13. }

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

  1. @Override
  2. public void writeBytes(Binary v) {
  3. int id = binaryDictionaryContent.getInt(v);
  4. if (id == -1) {
  5. id = binaryDictionaryContent.size();
  6. binaryDictionaryContent.put(v.copy(), id);
  7. // length as int (4 bytes) + actual bytes
  8. dictionaryByteSize += 4 + v.length();
  9. }
  10. encodedValues.add(id);
  11. }

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

  1. @Override
  2. public void writeBytes(Binary v) {
  3. int id = binaryDictionaryContent.getInt(v);
  4. if (id == -1) {
  5. id = binaryDictionaryContent.size();
  6. binaryDictionaryContent.put(v.copy(), id);
  7. // length as int (4 bytes) + actual bytes
  8. dictionaryByteSize += 4 + v.length();
  9. }
  10. encodedValues.add(id);
  11. }

相关文章