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); }
@Override int sizeOf(Object value) { return ((Binary) value).length(); } }
@Override public final void writeBytes(Binary v) { if (v.length() != length) { throw new IllegalArgumentException("Fixed Binary size " + v.length() + " does not match field type length " + length); } try { v.writeTo(out); } catch (IOException e) { throw new ParquetEncodingException("could not write fixed bytes", e); } }
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); }
@Override public void addBinary(Binary value) { final int length = value.length(); final byte[] bytes = value.getBytes(); /* set the bytes in LE format in the buffer of decimal vector, we will swap * the bytes while writing into the vector. */ writer.writeBigEndianBytesToDecimal(bytes); } }
@Override String stringifyNotNull(Binary value) { if (value.length() != 12) { return BINARY_INVALID; } ByteBuffer buffer = value.toByteBuffer().order(ByteOrder.LITTLE_ENDIAN); int pos = buffer.position(); String months = UNSIGNED_STRINGIFIER.stringify(buffer.getInt(pos)); String days = UNSIGNED_STRINGIFIER.stringify(buffer.getInt(pos + 4)); String millis = UNSIGNED_STRINGIFIER.stringify(buffer.getInt(pos + 8)); return "interval(" + months + " months, " + days + " days, " + millis + " millis)"; } };
@Override String stringifyNotNull(Binary value) { if (value.length() != 12) { return BINARY_INVALID; } ByteBuffer buffer = value.toByteBuffer().order(ByteOrder.LITTLE_ENDIAN); int pos = buffer.position(); String months = UNSIGNED_STRINGIFIER.stringify(buffer.getInt(pos)); String days = UNSIGNED_STRINGIFIER.stringify(buffer.getInt(pos + 4)); String millis = UNSIGNED_STRINGIFIER.stringify(buffer.getInt(pos + 8)); return "interval(" + months + " months, " + days + " days, " + millis + " millis)"; } };
public void writeBytes(Binary v) { //for rawdata, length(4 bytes int) is stored, followed by the binary content itself rawDataByteSize += v.length() + 4; currentWriter.writeBytes(v); checkFallback(); }
@Override public void writeBytes(Binary v) { try { lengthWriter.writeInteger(v.length()); v.writeTo(out); } catch (IOException e) { throw new ParquetEncodingException("could not write bytes", e); } }
@Override public final void writeBytes(Binary v) { try { out.writeInt(v.length()); v.writeTo(out); } catch (IOException e) { throw new ParquetEncodingException("could not write bytes", e); } }
@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; }
@Override public boolean setSafe(int index, DrillBuf value, int start, int length) { if (index >= nullableVarBinaryVector.getValueCapacity()) { return false; } if (usingDictionary) { ByteBuffer buf = currDictValToWrite.toByteBuffer(); mutator.setSafe(index, buf, buf.position(), currDictValToWrite.length()); } else { mutator.setSafe(index, 1, start, start + length, value); } return true; }
@Override public void writeBytes(Binary v) { int id = binaryDictionaryContent.getInt(v); if (id == -1) { id = binaryDictionaryContent.size(); binaryDictionaryContent.put(v.copy(), id); // length as int (4 bytes) + actual bytes dictionaryByteSize += 4 + v.length(); } encodedValues.add(id); }
@Override public void writeBytes(Binary v) { int id = binaryDictionaryContent.getInt(v); if (id == -1) { id = binaryDictionaryContent.size(); binaryDictionaryContent.put(v.copy(), id); // length as int (4 bytes) + actual bytes dictionaryByteSize += 4 + v.length(); } encodedValues.add(id); }