/** * Create a new decoder ready to read BCF2 data from the byte[] recordBytes, for testing purposes * * @param recordBytes */ protected BCF2Decoder(final byte[] recordBytes) { setRecordBytes(recordBytes); }
/** * Create a new decoder ready to read BCF2 data from the byte[] recordBytes, for testing purposes * * @param recordBytes */ protected BCF2Decoder(final byte[] recordBytes) { setRecordBytes(recordBytes); }
/** * Create a new decoder ready to read BCF2 data from the byte[] recordBytes, for testing purposes * * @param recordBytes */ protected BCF2Decoder(final byte[] recordBytes) { setRecordBytes(recordBytes); }
/** * Reads the next record from input stream and prepare this decoder to decode values from it * * @param stream * @return */ public void readNextBlock(final int blockSizeInBytes, final InputStream stream) { if ( blockSizeInBytes < 0 ) throw new TribbleException("Invalid block size " + blockSizeInBytes); setRecordBytes(readRecordBytes(blockSizeInBytes, stream)); }
/** * Reads the next record from input stream and prepare this decoder to decode values from it * * @param stream */ public void readNextBlock(final int blockSizeInBytes, final InputStream stream) { if ( blockSizeInBytes < 0 ) throw new TribbleException("Invalid block size " + blockSizeInBytes); setRecordBytes(readRecordBytes(blockSizeInBytes, stream)); }
/** * Reads the next record from input stream and prepare this decoder to decode values from it * * @param stream */ public void readNextBlock(final int blockSizeInBytes, final InputStream stream) { if ( blockSizeInBytes < 0 ) throw new TribbleException("Invalid block size " + blockSizeInBytes); setRecordBytes(readRecordBytes(blockSizeInBytes, stream)); }
hd.decoder.setRecordBytes((byte[])data);
hd.decoder.setRecordBytes((byte[])data);
hd.decoder.setRecordBytes((byte[])data);
public void testReadAndSkipWithMultipleBlocks(final List<BCF2TypedValue> block1, final List<BCF2TypedValue> block2) throws IOException { final byte[] record1 = encodeRecord(block1); final byte[] record2 = encodeRecord(block2); // each record is individually good decodeRecord(block1, record1); decodeRecord(block2, record2); BCF2Decoder decoder = new BCF2Decoder(); // test setting decoder.setRecordBytes(record1); decodeRecord(block1, decoder); decoder.setRecordBytes(record2); decodeRecord(block2, decoder); // test combining the streams final byte[] combined = combineRecords(record1, record2); final List<BCF2TypedValue> combinedObjects = new ArrayList<BCF2TypedValue>(block1); combinedObjects.addAll(block2); // the combined bytes is the same as the combined objects InputStream stream = new ByteArrayInputStream(combined); decoder.readNextBlock(record1.length, stream); decodeRecord(block1, decoder); decoder.readNextBlock(record2.length, stream); decodeRecord(block2, decoder); // skipping the first block allows us to read the second block directly stream = new ByteArrayInputStream(combined); decoder.skipNextBlock(record1.length, stream); decoder.readNextBlock(record2.length, stream); decodeRecord(block2, decoder); }