public void clearColumnBuffer() throws IOException { decompressBuffer.reset(); }
/** * Reads bytes from this stream into the byte array <code>buffer</code>. This * method will block until <code>buffer.length</code> number of bytes have * been read. * * @param buffer * to read bytes into * * @throws IOException * If a problem occurs reading from this DataInputStream. * */ @Override public final void readFully(byte[] buffer) throws IOException { readFully(buffer, 0, buffer.length); }
/** * Reads a 32-bit <code>float</code> value from this stream. * * @return the next <code>float</code> value from the source stream. * * @throws IOException * If a problem occurs reading from this DataInputStream. * */ @Override public final float readFloat() throws IOException { return Float.intBitsToFloat(readInt()); }
/** * Reads a UTF format String from this Stream. * * @return the next UTF String from the source stream. * * @throws IOException * If a problem occurs reading from this DataInputStream. * */ @Override public final String readUTF() throws IOException { return decodeUTF(readUnsignedShort()); }
switch (r.nextInt(numCases)) { case 0: assertEquals((byte)(r.nextInt() & 0xFF), in.readByte()); break; case 1: assertEquals((short)(r.nextInt() & 0xFFFF), in.readShort()); break; case 2: assertEquals(r.nextInt(), in.readInt()); break; case 3: assertEquals(r.nextLong(), in.readLong()); break; case 4: assertEquals(Double.doubleToLongBits(r.nextDouble()), Double.doubleToLongBits(in.readDouble())); break; case 5: assertEquals(Float.floatToIntBits(r.nextFloat()), Float.floatToIntBits(in.readFloat())); break; case 6: int len = r.nextInt(1024); r.nextBytes(vb); final byte[] b = new byte[len]; in.readFully(b, 0, len); assertArrayEquals(vb, b); in.read(b, 0, len); assertArrayEquals(vb, b); in.readFully(b); assertArrayEquals(vb, b); break;
/** * Tests methods of {@link NonSyncDataInputBuffer}. * @throws IOException */ @Test public void testBaseBuffers() throws IOException { NonSyncDataOutputBuffer dob = new NonSyncDataOutputBuffer(); final Random r = new Random(); final long seed = 0x0123456789ABCDEFL; // hardcoded for reproducibility. r.setSeed(seed); System.out.println("SEED: " + seed); writeJunk(dob, r, seed, 1000); NonSyncDataInputBuffer dib = new NonSyncDataInputBuffer(); dib.reset(dob.getData(), 0, dob.getLength()); assertEquals(0, dib.getPosition()); assertEquals(dob.getLength(), dib.getLength()); readJunk(dib, r, seed, 1000); dob.reset(); writeJunk(dob, r, seed, 1000); dib.reset(dob.getData(), dob.getLength()); assertEquals(0, dib.getPosition()); assertEquals(dob.getLength(), dib.getLength()); readJunk(dib, r, seed, 1000); }
public void testReadAndWrite() throws IOException { String testString = "test_hive_input_output_number_0"; byte[] string_bytes = testString.getBytes(); NonSyncDataInputBuffer inBuffer = new NonSyncDataInputBuffer(); NonSyncDataOutputBuffer outBuffer = new NonSyncDataOutputBuffer(); try { outBuffer.write(string_bytes); inBuffer.reset(outBuffer.getData(), 0, outBuffer.getLength()); byte[] readBytes = new byte[string_bytes.length]; inBuffer.read(readBytes); String readString = new String(readBytes); assertEquals("Field testReadAndWrite()", readString, testString); } finally { inBuffer.close(); outBuffer.close(); } }
tbOut = new TypedBytesWritableOutput(barrStr); inBarrStr = new NonSyncDataInputBuffer(); tbIn = new TypedBytesWritableInput(inBarrStr);
keyTempBuffer.reset(); keyTempBuffer.write(in, compressedKeyLen); keyDecompressBuffer.reset(keyTempBuffer.getData(), compressedKeyLen); CompressionInputStream deflatFilter = codec.createInputStream( keyDecompressBuffer, keyDecompressor); keyDecompressedData.reset(); keyDecompressedData.write(compressedIn, currentKeyLength); keyDataIn.reset(keyDecompressedData.getData(), currentKeyLength); currentKey.readFields(keyDataIn); } else { int colIx = col.colIndex; NonSyncDataOutputBuffer buf = currentKey.allCellValLenBuffer[colIx]; colValLenBufferReadIn[selIx].reset(buf.getData(), buf.getLength()); col.rowReadIndex = 0; col.runLength = 0; col.prvLength = -1; col.isNulled = colValLenBufferReadIn[selIx].getLength() == 0;
@Override public final char readChar() throws IOException { if (readToBuff(2) < 0) { throw new EOFException(); } return (char) (((buff[0] & 0xff) << 8) | (buff[1] & 0xff)); }
String decodeUTF(int utfSize) throws IOException { return decodeUTF(utfSize, this); }
/** * Reads a 64-bit <code>double</code> value from this stream. * * @return the next <code>double</code> value from the source stream. * * @throws IOException * If a problem occurs reading from this DataInputStream. * */ @Override public final double readDouble() throws IOException { return Double.longBitsToDouble(readLong()); }
private static String decodeUTF(int utfSize, DataInput in) throws IOException { byte[] buf = new byte[utfSize]; char[] out = new char[utfSize]; in.readFully(buf, 0, utfSize); return convertUTF8WithBuf(buf, out, 0, utfSize); }
col.rowReadIndex = 0; selectedColumns[j] = col; colValLenBufferReadIn[j] = new NonSyncDataInputBuffer(); revPrjColIDs[i] = j; j++;
keyTempBuffer.reset(); keyTempBuffer.write(in, compressedKeyLen); keyDecompressBuffer.reset(keyTempBuffer.getData(), compressedKeyLen); CompressionInputStream deflatFilter = codec.createInputStream( keyDecompressBuffer, keyDecompressor); keyDecompressedData.reset(); keyDecompressedData.write(compressedIn, currentKeyLength); keyDataIn.reset(keyDecompressedData.getData(), currentKeyLength); currentKey.readFields(keyDataIn); } else { int colIx = col.colIndex; NonSyncDataOutputBuffer buf = currentKey.allCellValLenBuffer[colIx]; colValLenBufferReadIn[selIx].reset(buf.getData(), buf.getLength()); col.rowReadIndex = 0; col.runLength = 0; col.prvLength = -1; col.isNulled = colValLenBufferReadIn[selIx].getLength() == 0;
/** * Reads a UTF format String from this Stream. * * @return the next UTF String from the source stream. * * @throws IOException * If a problem occurs reading from this DataInputStream. * */ @Override public final String readUTF() throws IOException { return decodeUTF(readUnsignedShort()); }
@Override public final char readChar() throws IOException { if (readToBuff(2) < 0) { throw new EOFException(); } return (char) (((buff[0] & 0xff) << 8) | (buff[1] & 0xff)); }
String decodeUTF(int utfSize) throws IOException { return decodeUTF(utfSize, this); }
/** * Reads a 64-bit <code>double</code> value from this stream. * * @return the next <code>double</code> value from the source stream. * * @throws IOException * If a problem occurs reading from this DataInputStream. * */ @Override public final double readDouble() throws IOException { return Double.longBitsToDouble(readLong()); }
private static String decodeUTF(int utfSize, DataInput in) throws IOException { byte[] buf = new byte[utfSize]; char[] out = new char[utfSize]; in.readFully(buf, 0, utfSize); return convertUTF8WithBuf(buf, out, 0, utfSize); }