/** * Register a (READER | WRITER | WRITTEN) schema to a column. * * <p> The Schema is added even if it already exists. </p> * * @param columnName at which to register the schema. * @param schema to register. * @param schemaRegistrationType of the schema to register: (READER, WRITER, WRITTEN). * @throws IOException If the parameters are invalid. * @return this builder. */ private TableLayoutBuilder withSchema( final FijiColumnName columnName, final Schema schema, final SchemaRegistrationType schemaRegistrationType) throws IOException { Preconditions.checkNotNull(columnName); Preconditions.checkNotNull(schema); Preconditions.checkNotNull(schemaRegistrationType); final long schemaId = mSchemaTable.getOrCreateSchemaId(schema); final List<AvroSchema> schemas = getMutableRegisteredSchemaList(columnName, schemaRegistrationType); schemas.add(AvroSchema.newBuilder().setUid(schemaId).build()); return this; }
/** {@inheritDoc} */ @Override public void encode(final Schema writerSchema) throws IOException { final long schemaId = mCellSpec.getSchemaTable().getOrCreateSchemaId(writerSchema); mByteArrayEncoder.writeFixed(ByteStreamArray.longToVarInt64(schemaId)); } }
/** * Register a schema. * * @return Tool exit code. * @throws IOException in case of an error. */ private int registerSchema() throws IOException { final FijiSchemaTable table = mFiji.getSchemaTable(); final File file = new File(mRegisterFlag); final Schema schema = new Schema.Parser().parse(file); final long id = table.getOrCreateSchemaId(schema); final String hash = table.getSchemaHash(schema).toString(); if (isInteractive()) { getPrintStream().print("Schema ID for the given schema is: "); } getPrintStream().println(id); if (isInteractive()) { getPrintStream().print("Schema hash for the given schema is: "); } getPrintStream().println(hash); return SUCCESS; }
/** {@inheritDoc} */ @Override public Long apply(AvroSchema avroSchema) { if (avroSchema.getJson() != null) { final Schema schema = new Schema.Parser().parse(avroSchema.getJson()); try { return mSchemaTable.getOrCreateSchemaId(schema); } catch (IOException ioe) { throw new FijiIOException(ioe); } } else if (avroSchema.getUid() != null) { return avroSchema.getUid(); } else { throw new FijiIOException( "AvroSchema neither has a schema UID nor a schema JSON descriptor."); } } }
final long schemaId = mSchemaTable.getOrCreateSchemaId(schema); avroSchema.setUid(schemaId); avroSchema.setJson(null);
if (null != counter) { SchemaOption schemaOption = new SchemaOption(schemaTable. getOrCreateSchemaId(Schema.create(Schema.Type.LONG))); returnRow.addCell(counter, schemaOption); if (null != counter) { SchemaOption schemaOption = new SchemaOption(schemaTable. getOrCreateSchemaId(counter.getWriterSchema())); returnRow.addCell(counter, schemaOption); FijiCell<Object> fijiCell = timestampedCell.getValue(); SchemaOption schemaOption = new SchemaOption(schemaTable. getOrCreateSchemaId(fijiCell.getWriterSchema())); returnRow.addCell(fijiCell, schemaOption); for (FijiCell<Object> timestampedCell : e.getValue().values()) { SchemaOption schemaOption = new SchemaOption(schemaTable. getOrCreateSchemaId(timestampedCell.getWriterSchema())); returnRow.addCell(timestampedCell, schemaOption);