public final Object decodeTypedValue() throws IOException { final byte typeDescriptor = readTypeDescriptor(); return decodeTypedValue(typeDescriptor); }
public final Object decodeTypedValue() throws IOException { final byte typeDescriptor = readTypeDescriptor(); return decodeTypedValue(typeDescriptor); }
public final Object decodeTypedValue() throws IOException { final byte typeDescriptor = readTypeDescriptor(); return decodeTypedValue(typeDescriptor); }
public final int decodeNumberOfElements(final byte typeDescriptor) throws IOException { if ( BCF2Utils.sizeIsOverflow(typeDescriptor) ) // -1 ensures we explode immediately with a bad size if the result is missing return decodeInt(readTypeDescriptor(), -1); else // the size is inline, so just decode it return BCF2Utils.decodeSize(typeDescriptor); }
public final int decodeNumberOfElements(final byte typeDescriptor) throws IOException { if ( BCF2Utils.sizeIsOverflow(typeDescriptor) ) // -1 ensures we explode immediately with a bad size if the result is missing return decodeInt(readTypeDescriptor(), -1); else // the size is inline, so just decode it return BCF2Utils.decodeSize(typeDescriptor); }
@Ensures("result >= 0") public final int decodeNumberOfElements(final byte typeDescriptor) throws IOException { if ( BCF2Utils.sizeIsOverflow(typeDescriptor) ) // -1 ensures we explode immediately with a bad size if the result is missing return decodeInt(readTypeDescriptor(), -1); else // the size is inline, so just decode it return BCF2Utils.decodeSize(typeDescriptor); }
@Test(dataProvider = "IntArrays") public void testIntArrays(final List<Integer> ints) throws IOException { final BCF2Encoder encoder = new BCF2Encoder(); encoder.encodeTyped(ints, BCF2Type.INT16); final BCF2Decoder decoder = new BCF2Decoder(encoder.getRecordBytes()); final byte typeDescriptor = decoder.readTypeDescriptor(); // read the int[] with the low-level version final int size = decoder.decodeNumberOfElements(typeDescriptor); final int[] decoded = decoder.decodeIntArray(typeDescriptor, size); if ( isMissing(ints) ) { // we expect that the result is null in this case Assert.assertNull(decoded, "Encoded all missing values -- expected null"); } else { // we expect at least some values to come back Assert.assertTrue(decoded.length > 0, "Must have at least 1 element for non-null encoded data"); // check corresponding values for ( int i = 0; i < ints.size(); i++ ) { final Integer expected = ints.get(i); if ( expected == null ) { Assert.assertTrue(decoded.length <= i, "we expect decoded to be truncated for missing values"); } else { Assert.assertTrue(decoded.length > i, "we expected at least " + i + " values in decoded array"); Assert.assertEquals(decoded[i], (int)expected); } } } }
(Integer)hd.decoder.decodeTypedValue()); final byte type = hd.decoder.readTypeDescriptor(); final int numElems = hd.decoder.decodeNumberOfElements(type);
(Integer)hd.decoder.decodeTypedValue()); final byte type = hd.decoder.readTypeDescriptor(); final int numElems = hd.decoder.decodeNumberOfElements(type);
(Integer)hd.decoder.decodeTypedValue()); final byte type = hd.decoder.readTypeDescriptor(); final int numElems = hd.decoder.decodeNumberOfElements(type);
final byte typeDescriptor = decoder.readTypeDescriptor(); final int numElements = decoder.decodeNumberOfElements(typeDescriptor); final BCF2GenotypeFieldDecoders.Decoder fieldDecoder = codec.getGenotypeFieldDecoder(field);
final byte typeDescriptor = decoder.readTypeDescriptor(); final int numElements = decoder.decodeNumberOfElements(typeDescriptor); final BCF2GenotypeFieldDecoders.Decoder fieldDecoder = codec.getGenotypeFieldDecoder(field);
final byte typeDescriptor = decoder.readTypeDescriptor(); final int numElements = decoder.decodeNumberOfElements(typeDescriptor); final BCF2GenotypeFieldDecoders.Decoder fieldDecoder = codec.getGenotypeFieldDecoder(field);