public void flushGroup() throws IOException { if (prevValueLength >= 0) { WritableUtils.writeVLong(valLenBuffer, prevValueLength); if (runLength > 0) { WritableUtils.writeVLong(valLenBuffer, ~runLength); } runLength = -1; prevValueLength = -1; } } }
public void flushGroup() throws IOException { if (prevValueLength >= 0) { WritableUtils.writeVLong(valLenBuffer, prevValueLength); if (runLength > 0) { WritableUtils.writeVLong(valLenBuffer, ~runLength); } runLength = -1; prevValueLength = -1; } } }
@Override public void write(DataOutput out) throws IOException { WritableUtils.writeVLong(out, value); }
/** * Serializes an integer to a binary stream with zero-compressed encoding. * For -112 <= i <= 127, only one byte is used with the actual value. * For other values of i, the first byte value indicates whether the * integer is positive or negative, and the number of bytes that follow. * If the first byte value v is between -113 and -116, the following integer * is positive, with number of bytes that follow are -(v+112). * If the first byte value v is between -121 and -124, the following integer * is negative, with number of bytes that follow are -(v+120). Bytes are * stored in the high-non-zero-byte-first order. * * @param stream Binary output stream * @param i Integer to be serialized * @throws java.io.IOException */ public static void writeVInt(DataOutput stream, int i) throws IOException { writeVLong(stream, i); }
@Override public void write(DataOutput out) throws IOException { // out.writeInt(numberRows); WritableUtils.writeVLong(out, numberRows); for (int i = 0; i < eachColumnValueLen.length; i++) { WritableUtils.writeVLong(out, eachColumnValueLen[i]); WritableUtils.writeVLong(out, eachColumnUncompressedValueLen[i]); NonSyncDataOutputBuffer colRowsLenBuf = allCellValLenBuffer[i]; int bufLen = colRowsLenBuf.getLength(); WritableUtils.writeVLong(out, bufLen); out.write(colRowsLenBuf.getData(), 0, bufLen); } }
@Override public void write(DataOutput out) throws IOException { // out.writeInt(numberRows); WritableUtils.writeVLong(out, numberRows); for (int i = 0; i < eachColumnValueLen.length; i++) { WritableUtils.writeVLong(out, eachColumnValueLen[i]); WritableUtils.writeVLong(out, eachColumnUncompressedValueLen[i]); NonSyncDataOutputBuffer colRowsLenBuf = allCellValLenBuffer[i]; int bufLen = colRowsLenBuf.getLength(); WritableUtils.writeVLong(out, bufLen); out.write(colRowsLenBuf.getData(), 0, bufLen); } }
@Override public void write(DataOutput dataOutput) throws IOException { WritableUtils.writeVLong(dataOutput, chainId); WritableUtils.writeVLong(dataOutput, order); }
@Override public void write(DataOutput dataOutput) throws IOException { WritableUtils.writeVLong(dataOutput, rk); WritableUtils.writeVLong(dataOutput, next); }
@Override public void write(DataOutput out) throws IOException { WritableUtils.writeVInt(out, id); WritableUtils.writeVLong(out, expirationDate); if (secret == null) { WritableUtils.writeVInt(out, -1); } else { byte[] keyBytes = secret.getEncoded(); WritableUtils.writeVInt(out, keyBytes.length); out.write(keyBytes); } }
@VisibleForTesting void writeImpl(DataOutput out) throws IOException { out.writeByte(VERSION); owner.write(out); renewer.write(out); realUser.write(out); WritableUtils.writeVLong(out, issueDate); WritableUtils.writeVLong(out, maxDate); WritableUtils.writeVInt(out, sequenceNumber); WritableUtils.writeVInt(out, masterKeyId); }
/** */ @Override public void write(DataOutput out) throws IOException { WritableUtils.writeVInt(out, keyId); WritableUtils.writeVLong(out, expiryDate); if (keyBytes == null) { WritableUtils.writeVInt(out, -1); } else { WritableUtils.writeVInt(out, keyBytes.length); out.write(keyBytes); } }
@Override public void write(DataOutput out) throws IOException { // write totalSeconds, nanos to DataOutput WritableUtils.writeVLong(out, intervalValue.getTotalSeconds()); WritableUtils.writeVInt(out, intervalValue.getNanos()); }
/** * Writes the field values to the output. * * @param out The output to write to. * @throws IOException When writing the values to the output fails. */ @Override public void write(DataOutput out) throws IOException { WritableUtils.writeVInt(out, VERSION.code); Bytes.writeByteArray(out, tableName.getName()); Bytes.writeByteArray(out, startRow); Bytes.writeByteArray(out, endRow); Bytes.writeByteArray(out, Bytes.toBytes(regionLocation)); Bytes.writeByteArray(out, Bytes.toBytes(scan)); WritableUtils.writeVLong(out, length); Bytes.writeByteArray(out, Bytes.toBytes(encodedRegionName)); }
currentCell.getLength()); if (includesMvcc) { WritableUtils.writeVLong(out, cell.getSequenceId());
@Test public void testConsistencyWithHadoopVLong() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); for (long l : testNumbers) { baos.reset(); ByteBuffer b = ByteBuffer.allocate(MAX_VLONG_LENGTH); ByteBufferUtils.writeVLong(b, l); String bufStr = Bytes.toStringBinary(b.array(), b.arrayOffset(), b.position()); WritableUtils.writeVLong(dos, l); String baosStr = Bytes.toStringBinary(baos.toByteArray()); assertEquals(baosStr, bufStr); } }
public void testReadAsVLong() throws Exception { long [] longs = {-1l, 123l, Long.MIN_VALUE, Long.MAX_VALUE}; for (int i = 0; i < longs.length; i++) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream output = new DataOutputStream(baos); WritableUtils.writeVLong(output, longs[i]); byte[] long_bytes_no_offset = baos.toByteArray(); assertEquals(longs[i], Bytes.readAsVLong(long_bytes_no_offset, 0)); byte[] long_bytes_with_offset = bytesWithOffset(long_bytes_no_offset); assertEquals(longs[i], Bytes.readAsVLong(long_bytes_with_offset, 1)); } }
public int write(Cell cell) throws IOException { // We write tags seperately because though there is no tag in KV // if the hfilecontext says include tags we need the tags length to be // written int size = KeyValueUtil.oswrite(cell, out, false); // Write the additional tag into the stream if (encodingCtx.getHFileContext().isIncludesTags()) { int tagsLength = cell.getTagsLength(); out.writeShort(tagsLength); if (tagsLength > 0) { PrivateCellUtil.writeTags(out, cell, tagsLength); } size += tagsLength + KeyValue.TAGS_LENGTH_SIZE; } if (encodingCtx.getHFileContext().isIncludesMvcc()) { WritableUtils.writeVLong(out, cell.getSequenceId()); size += WritableUtils.getVIntSize(cell.getSequenceId()); } return size; }
out.writeFloat(agg.getFloat()); } else if ("long".equals(t)) { WritableUtils.writeVLong(out, agg.getLong()); } else if ("double".equals(t)) { out.writeDouble(agg.getDouble());
private static Slice writeVintOld(SliceOutput output, long value) throws IOException { output.reset(); WritableUtils.writeVLong(output, value); Slice vLongOld = Slices.copyOf(output.slice()); output.reset(); RcFileDecoderUtils.writeVLong(output, value); Slice vLongNew = Slices.copyOf(output.slice()); assertEquals(vLongNew, vLongOld); if (value == (int) value) { output.reset(); WritableUtils.writeVInt(output, (int) value); Slice vIntOld = Slices.copyOf(output.slice()); assertEquals(vIntOld, vLongOld); output.reset(); RcFileDecoderUtils.writeVInt(output, (int) value); Slice vIntNew = Slices.copyOf(output.slice()); assertEquals(vIntNew, vLongOld); } return vLongOld; } }
WritableUtils.writeVLong(out, memstoreTS);