/** * Initializes a new RawBytesCellDecoder. * * @param spec Specification of the cell encoding. */ public RawBytesCellDecoder(BoundColumnReaderSpec spec) { Preconditions.checkNotNull(spec); Preconditions.checkArgument( spec.getColumnReaderSpec().getEncoding() == Encoding.RAW_BYTES); }
/** * Initializes a ProtobufCellDecoder. * * @param layout FijiTableLayout from which to get the Protobuf class name. * @param spec Specification of the cell encoding. * @throws IOException on I/O error. */ public ProtobufCellDecoder(FijiTableLayout layout, BoundColumnReaderSpec spec) throws IOException { Preconditions.checkNotNull(layout); Preconditions.checkNotNull(spec); Preconditions.checkArgument( spec.getColumnReaderSpec().getEncoding() == Encoding.PROTOBUF); final String className = layout.getCellSchema(spec.getColumn()).getProtobufClassName(); try { mProtoClass = Class.forName(className).asSubclass(AbstractMessageLite.class); } catch (ClassNotFoundException cnfe) { throw new IOException(cnfe); } try { mParseFromMethod = mProtoClass.getMethod("parseFrom", byte[].class); } catch (NoSuchMethodException nsme) { throw new IOException(nsme); } }
/** {@inheritDoc} */ @Override public <T> FijiCellDecoder<T> create(FijiTableLayout layout, BoundColumnReaderSpec spec) throws IOException { Preconditions.checkNotNull(layout); Preconditions.checkNotNull(spec); switch (spec.getColumnReaderSpec().getEncoding()) { case RAW_BYTES: return new RawBytesCellDecoder<T>(spec); case AVRO: return new GenericCellDecoder<T>(layout, spec); case PROTOBUF: return new ProtobufCellDecoder<T>(layout, spec); case COUNTER: // purposefully forget the type (long) param of cell decoders for counters. @SuppressWarnings("unchecked") final FijiCellDecoder<T> counterCellDecoder = (FijiCellDecoder<T>) CounterCellDecoder.get(); return counterCellDecoder; default: throw new InternalFijiError( "Unhandled cell encoding in reader spec: " + spec.getColumnReaderSpec()); } } }
/** {@inheritDoc} */ @Override public <T> FijiCellDecoder<T> create(FijiTableLayout layout, BoundColumnReaderSpec spec) throws IOException { Preconditions.checkNotNull(spec); switch (spec.getColumnReaderSpec().getEncoding()) { case RAW_BYTES: return new RawBytesCellDecoder<T>(spec); case AVRO: return new SpecificCellDecoder<T>(layout, spec); case PROTOBUF: return new ProtobufCellDecoder<T>(layout, spec); case COUNTER: // purposefully forget the type (long) param of cell decoders for counters. @SuppressWarnings("unchecked") final FijiCellDecoder<T> counterCellDecoder = (FijiCellDecoder<T>) CounterCellDecoder.get(); return counterCellDecoder; default: throw new InternalFijiError( "Unhandled cell encoding in reader spec: " + spec.getColumnReaderSpec()); } }