public Writable createRow() throws IOException { bytes = new BytesWritable(); bytes.setCapacity(maxRecordLength); return bytes; }
public Writable createRow() throws IOException { bytes = new BytesWritable(); bytes.setCapacity(maxRecordLength); return bytes; }
/** * Change the size of the buffer. The values in the old range are preserved * and any new values are undefined. The capacity is changed if it is * necessary. * @param size The new number of bytes */ public void setSize(int size) { if (size > getCapacity()) { // Avoid overflowing the int too early by casting to a long. long newSize = Math.min(Integer.MAX_VALUE, (3L * size) / 2L); setCapacity((int) newSize); } this.size = size; }
/** * @param compressionAlgo * The compression algorithm to be used to for compression. * @throws IOException */ public WBlockState(Algorithm compressionAlgo, FSDataOutputStream fsOut, BytesWritable fsOutputBuffer, Configuration conf) throws IOException { this.compressAlgo = compressionAlgo; this.fsOut = fsOut; this.posStart = fsOut.getPos(); fsOutputBuffer.setCapacity(TFile.getFSOutputBufferSize(conf)); this.fsBufferedOutput = new SimpleBufferedOutputStream(this.fsOut, fsOutputBuffer.getBytes()); this.compressor = compressAlgo.getCompressor(); try { this.out = compressionAlgo.createCompressionStream(fsBufferedOutput, compressor, 0); } catch (IOException e) { compressAlgo.returnCompressor(compressor); throw e; } }
public WBlockState(Algorithm compressionAlgo, RateLimitedOutputStream fsOut, BytesWritable fsOutputBuffer, Configuration conf, FileEncrypter encrypter) throws IOException { this.compressAlgo = compressionAlgo; this.fsOut = fsOut; this.posStart = fsOut.position(); fsOutputBuffer.setCapacity(getFSOutputBufferSize(conf)); this.fsBufferedOutput = new SimpleBufferedOutputStream(this.fsOut, fsOutputBuffer.getBytes()); this.compressor = compressAlgo.getCompressor(); try { this.cipherOut = encrypter.encryptStream(fsBufferedOutput); this.out = compressionAlgo.createCompressionStream(cipherOut, compressor, 0); } catch (IOException e) { compressAlgo.returnCompressor(compressor); throw e; } }
public Writable createRow() throws IOException { bytes = new BytesWritable(); bytes.setCapacity(maxRecordLength); return bytes; }
public Writable createRow() throws IOException { bytes = new BytesWritable(); bytes.setCapacity(maxRecordLength); return bytes; }
/** * Change the size of the buffer. The values in the old range are preserved * and any new values are undefined. The capacity is changed if it is * necessary. * @param size The new number of bytes */ public void setSize(int size) { if (size > getCapacity()) { setCapacity(size * 3 / 2); } this.size = size; }
/** * Change the size of the buffer. The values in the old range are preserved * and any new values are undefined. The capacity is changed if it is * necessary. * @param size The new number of bytes */ public void setSize(int size) { if (size > getCapacity()) { setCapacity(size * 3 / 2); } this.size = size; }
/** * Change the size of the buffer. The values in the old range are preserved * and any new values are undefined. The capacity is changed if it is * necessary. * @param size The new number of bytes */ public void setSize(int size) { if (size > getCapacity()) { setCapacity(size * 3 / 2); } this.size = size; }
/** * Change the size of the buffer. The values in the old range are preserved * and any new values are undefined. The capacity is changed if it is * necessary. * @param size The new number of bytes */ public void setSize(int size) { if (size > getCapacity()) { setCapacity(size * 3 / 2); } this.size = size; }
/** * Change the size of the buffer. The values in the old range are preserved * and any new values are undefined. The capacity is changed if it is * necessary. * @param size The new number of bytes */ public void setSize(int size) { if (size > getCapacity()) { setCapacity(size * 3 / 2); } this.size = size; }
ByteSequence() { out.setSize(0); out.setCapacity(200); os = new OutputStream() { @Override public void write(int b) throws IOException { int length = out.getLength(); out.getBytes()[length] = (byte) b; out.setSize(length + 1); } }; dos = new DataOutputStream(os); }
/** * Change the size of the buffer. The values in the old range are preserved * and any new values are undefined. The capacity is changed if it is * necessary. * @param size The new number of bytes */ public void setSize(int size) { if (size > getCapacity()) { // Avoid overflowing the int too early by casting to a long. long newSize = Math.min(Integer.MAX_VALUE, (3L * size) / 2L); setCapacity((int) newSize); } this.size = size; }
public static void encode(int[] sequence, final BytesWritable out) throws IOException { out.setSize(0); out.setCapacity(sequence.length * 10); OutputStream os = new OutputStream() { @Override public void write(int b) throws IOException { int length = out.getLength(); out.getBytes()[length] = (byte) b; out.setSize(length + 1); } }; DataOutputStream dos = new DataOutputStream(os); for (int i : sequence) { WritableUtils.writeVInt(dos, i); } }
@Override public void write(int b) throws IOException { if (target.getCapacity() < uncommittedLength + 1) { assert target.getCapacity() == uncommittedLength; int l = target.getLength(); target.setSize(uncommittedLength); target.setCapacity(uncommittedLength + 1); target.setSize(l); } target.getBytes()[uncommittedLength] = (byte) b; uncommittedLength++; } };
public void testHash() throws Exception { byte[] owen = "owen".getBytes(); BytesWritable buf = new BytesWritable(owen); assertEquals(4347922, buf.hashCode()); buf.setCapacity(10000); assertEquals(4347922, buf.hashCode()); buf.setSize(0); assertEquals(1, buf.hashCode()); }
@Override public void write(int b) throws IOException { if (target.getCapacity() < uncommittedLength + 1) { assert target.getCapacity() == uncommittedLength; int l = target.getLength(); target.setSize(uncommittedLength); target.setCapacity(uncommittedLength + 1); target.setSize(l); } target.getBytes()[uncommittedLength] = (byte) b; uncommittedLength++; } };
@Test public void testHash() throws Exception { byte[] owen = "owen".getBytes(); BytesWritable buf = new BytesWritable(owen); assertEquals(4347922, buf.hashCode()); buf.setCapacity(10000); assertEquals(4347922, buf.hashCode()); buf.setSize(0); assertEquals(1, buf.hashCode()); }
@Test public void testHash() throws Exception { byte[] owen = "owen".getBytes(); BytesWritable buf = new BytesWritable(owen); assertEquals(4347922, buf.hashCode()); buf.setCapacity(10000); assertEquals(4347922, buf.hashCode()); buf.setSize(0); assertEquals(1, buf.hashCode()); }