/** * Configures this column to decode cells using the default Avro reader schemas. * * <p> For Avro-encoded cells only. </p> * * @return this CellSpec. */ public CellSpec setUseDefaultReaderSchema() { Preconditions.checkState(isAvro()); mReaderSchema = null; mAvroReaderSchema = AvroReaderSchema.DEFAULT; return this; }
/** * Sets the Avro schema to use when decoding cells. * * <p> For Avro-encoded cells only. </p> * * @param readerSchema Avro reader schema. * @return this CellSpec. */ public CellSpec setReaderSchema(final Schema readerSchema) { Preconditions.checkState(isAvro()); mAvroReaderSchema = AvroReaderSchema.EXPLICIT; mReaderSchema = Preconditions.checkNotNull(readerSchema); return this; }
/** * 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(); }
/** * Sets the Avro schema storage. * * <p> For Avro-encoded cells only. </p> * * @param schemaStorage Avro schema storage to use (hash, UID or final). * @return this CellSpec. */ public CellSpec setSchemaStorage(final SchemaStorage schemaStorage) { getOrCreateCellSchema().setStorage(schemaStorage); Preconditions.checkState(isAvro()); return this; }
/** * Configures this column to decode cells using Avro writer schemas. * * <p> This forces the use of generic records. </p> * <p> For Avro-encoded cells only. </p> * * @return this CellSpec. */ public CellSpec setUseWriterSchema() { Preconditions.checkState(isAvro()); mReaderSchema = null; mAvroReaderSchema = AvroReaderSchema.WRITER; setDecoderFactory(GenericCellDecoderFactory.get()); return this; }
/** * Returns the Avro reader schema used to decode cells. * * <p> For Avro-encoded cells only. </p> * * @return the Avro reader schema used to decode cells. * Null means cells are decoded using their writer schema. */ public Schema getAvroSchema() { Preconditions.checkState(isAvro()); switch (mAvroReaderSchema) { case DEFAULT: return getDefaultReaderSchema(); case EXPLICIT: return mReaderSchema; case WRITER: return null; default: throw new InternalFijiError("Invalid Avro reader schema: " + mAvroReaderSchema); } }
/** * Returns the default Avro schema to use to decode cells from this column, if any. * * <p> For Avro-encoded cells only. </p> * * @return the default Avro schema to use to decode cells from this column, if any. */ public Schema getDefaultReaderSchema() { Preconditions.checkState(isAvro()); if ((null == mDefaultReaderSchema) && (mCellSchema.getDefaultReader() != null)) { Preconditions.checkNotNull(mAvroSchemaResolver); mDefaultReaderSchema = mAvroSchemaResolver.apply(mCellSchema.getDefaultReader()); } return mDefaultReaderSchema; }
/** * 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); }
if (isAvro()) { switch (mCellSchema.getType()) { case AVRO: {