/** * Initializes an abstract FijiAvroCellDecoder. * * @param cellSpec Specification of the cell encoding. * @throws IOException on I/O error. */ protected AvroCellDecoder(CellSpec cellSpec) throws IOException { Preconditions.checkNotNull(cellSpec); Preconditions.checkArgument(cellSpec.isAvro()); mSchemaDecoder = createSchemaDecoder(cellSpec); mReaderSchema = cellSpec.getAvroSchema(); }
/** {@inheritDoc} */ @Override public Schema getReaderSchema(final String family, final String qualifier) throws IOException { return mTableLayout.getCellSpec(FijiColumnName.create(family, qualifier)).getAvroSchema(); }
/** {@inheritDoc} */ @Override public Schema getReaderSchema(final String family, final String qualifier) throws IOException { return mLayout.getCellSpec(FijiColumnName.create(family, qualifier)).getAvroSchema(); }
/** * Creates a new <code>FijiCellEncoder</code> instance. * * @param cellSpec Specification of the cell to encode. * @throws IOException on I/O error. */ public AvroCellEncoder(final CellSpec cellSpec) throws IOException { mCellSpec = Preconditions.checkNotNull(cellSpec); Preconditions.checkArgument(cellSpec.isAvro()); mReaderSchema = mCellSpec.getAvroSchema(); mSchemaEncoder = createSchemaEncoder(mCellSpec); mRegisteredWriters = flattenAvroUnions(getRegisteredWriters(mCellSpec)); mValidationPolicy = getAvroValidationPolicy(mCellSpec); }
/** * Creates a schema decoder. * * @param cellSpec Specification of the cell encoding. * @return a new schema decoder. * @throws IOException on I/O error. */ private static SchemaDecoder createSchemaDecoder(CellSpec cellSpec) throws IOException { switch (cellSpec.getCellSchema().getStorage()) { case HASH: return new SchemaHashDecoder(cellSpec.getSchemaTable()); case UID: return new SchemaIdDecoder(cellSpec.getSchemaTable()); case FINAL: return new FinalSchemaDecoder(cellSpec.getAvroSchema()); default: throw new InternalFijiError( "Unexpected cell storage in cell schema: " + cellSpec.getCellSchema()); } }