buffer = new UnsynchronizedBuffer.Writer(); for (int i = 0; i < localEntries; i++) { byte[] cf = oldReadBytes(din);
/** * Adds bytes to this writer's buffer. * * @param bytes * byte array * @param off * offset into array to start copying bytes * @param length * number of bytes to add * @throws IndexOutOfBoundsException * if off or length are invalid */ public void add(byte[] bytes, int off, int length) { reserve(length); System.arraycopy(bytes, off, data, offset, length); offset += length; }
throw new IllegalStateException("Can not add to mutation after serializing it"); long estimatedSizeAfterPut = estRowAndLargeValSize + buffer.size() + cfLength + cqLength + cv.length + (hasts ? 8 : 0) + valLength + 2 + 4 * SERIALIZATION_OVERHEAD; Preconditions.checkArgument(
buffer = new UnsynchronizedBuffer.Writer(); for (int i = 0; i < localEntries; i++) { byte[] cf = oldReadBytes(din);
reserve(9); if (i >= -112 && i <= 127) { data[offset++] = (byte) i;
/** * Creates a new mutation. A defensive copy is made. * * @param row * byte array containing row ID * @param start * starting index of row ID in byte array * @param length * length of row ID in byte array * @param initialBufferSize * the initial size, in bytes, of the internal buffer for serializing * @throws IndexOutOfBoundsException * if start or length is invalid * @since 1.7.0 */ public Mutation(byte[] row, int start, int length, int initialBufferSize) { this.row = new byte[length]; System.arraycopy(row, start, this.row, 0, length); buffer = new UnsynchronizedBuffer.Writer(initialBufferSize); }
/** * Adds bytes to this writer's buffer. * * @param bytes * byte array * @param off * offset into array to start copying bytes * @param length * number of bytes to add * @throws IndexOutOfBoundsException * if off or length are invalid */ public void add(byte[] bytes, int off, int length) { reserve(length); System.arraycopy(bytes, off, data, offset, length); offset += length; }
public ByteBuffer compress(IteratorSetting[] iterators) { UnsynchronizedBuffer.Writer out = new UnsynchronizedBuffer.Writer(iterators.length * 8); out.writeVInt(iterators.length); for (IteratorSetting is : iterators) { out.writeVInt(getSymbolID(is.getName())); out.writeVInt(getSymbolID(is.getIteratorClass())); out.writeVInt(is.getPriority()); Map<String,String> opts = is.getOptions(); out.writeVInt(opts.size()); for (Entry<String,String> entry : opts.entrySet()) { out.writeVInt(getSymbolID(entry.getKey())); out.writeVInt(getSymbolID(entry.getValue())); } } return out.toByteBuffer(); }
private void put(int i) { buffer.writeVLong(i); }
private void put(boolean b) { buffer.add(b); }
private void put(byte b[], int length) { buffer.writeVLong(length); buffer.add(b, 0, length); }
/** * Adds a Boolean value to this writer's buffer. * * @param b * Boolean value */ public void add(boolean b) { reserve(1); if (b) data[offset++] = 1; else data[offset++] = 0; }
private void put(long l) { buffer.writeVLong(l); }
private void serialize() { if (buffer != null) { data = buffer.toArray(); buffer = null; } }
/** * This is so hashCode and equals can be called without changing this object. * * It will return a copy of the current data buffer if serialized has not been called previously. * Otherwise, this.data will be returned since the buffer is null and will not change. */ private ByteBuffer serializedSnapshot() { if (buffer != null) { return this.buffer.toByteBuffer(); } else { return ByteBuffer.wrap(this.data); } }
/** * Adds an integer value to this writer's buffer. The integer is encoded as a variable-length * list of bytes. See {@link #writeVLong(long)} for a description of the encoding. * * @param i * integer value */ public void writeVInt(int i) { writeVLong(i); }
/** * Creates a new mutation. A defensive copy is made. * * @param row * byte array containing row ID * @param start * starting index of row ID in byte array * @param length * length of row ID in byte array * @param initialBufferSize * the initial size, in bytes, of the internal buffer for serializing * @throws IndexOutOfBoundsException * if start or length is invalid * @since 1.7.0 */ public Mutation(byte[] row, int start, int length, int initialBufferSize) { this.row = new byte[length]; System.arraycopy(row, start, this.row, 0, length); buffer = new UnsynchronizedBuffer.Writer(initialBufferSize); estRowAndLargeValSize = length + SERIALIZATION_OVERHEAD; }
public ByteBuffer compress(IteratorSetting[] iterators) { UnsynchronizedBuffer.Writer out = new UnsynchronizedBuffer.Writer(iterators.length * 8); out.writeVInt(iterators.length); for (IteratorSetting is : iterators) { out.writeVInt(getSymbolID(is.getName())); out.writeVInt(getSymbolID(is.getIteratorClass())); out.writeVInt(is.getPriority()); Map<String,String> opts = is.getOptions(); out.writeVInt(opts.size()); for (Entry<String,String> entry : opts.entrySet()) { out.writeVInt(getSymbolID(entry.getKey())); out.writeVInt(getSymbolID(entry.getValue())); } } return out.toByteBuffer(); }
private void fill(boolean b) { buffer.add(b); }
private void fill(long l) { buffer.writeVLong(l); }