/** * Produce an Avro schema object depending on what was set (string or UID). * * @param schemaTable is the schema table to use to fetch the Avro schema given a UID * @return the corresponding Avro schema. * @throws IOException if there is a problem fetching the schema from the schema table if the * UID is set. */ public Schema resolve(FijiSchemaTable schemaTable) throws IOException { if (mParsedSchema == null) { return schemaTable.getSchema(mSchemaUid); } else { return mParsedSchema; } }
final Schema schema = table.getSchema(mGetByIdFlag); Preconditions.checkArgument( schema != null, "No schema definition with ID: %s", mGetByIdFlag);
/** {@inheritDoc} */ @Override public Schema decode(ByteStreamArray bstream) throws IOException { final long schemaId = bstream.readVarInt64(); final Schema schema = mSchemaTable.getSchema(schemaId); if (null == schema) { throw new IOException( String.format("Schema with ID %d not found in schema table.", schemaId)); } return schema; } }
/** * List all schemas in the table. * * @return The Tool exit code. * @throws IOException in case of an error. */ private int list() throws IOException { final FijiSchemaTable schemaTable = mFiji.getSchemaTable(); long id = 0; Schema schema = schemaTable.getSchema(id); while (null != schema) { getPrintStream().printf("%d: %s%n", id, schema.toString()); schema = schemaTable.getSchema(++id); } return SUCCESS; }
/** {@inheritDoc} */ @Override public Schema decode(ByteStreamArray bstream) throws IOException { final BytesKey schemaHash = new BytesKey(bstream.readBytes(Hasher.HASH_SIZE_BYTES)); final Schema schema = mSchemaTable.getSchema(schemaHash); if (null == schema) { throw new IOException( String.format("Schema with hash %s not found in schema table.", schemaHash)); } return schema; } }
AvroSchema avroSchema = cellSchema.getDefaultReader(); if (avroSchema.getUid() != null) { return schemaTable.getSchema(avroSchema.getUid()); } else if (avroSchema.getJson() != null) { return parser.parse(avroSchema.getJson());
/** {@inheritDoc} */ @Override public Schema apply(AvroSchema avroSchema) { if (avroSchema.getJson() != null) { return new Schema.Parser().parse(avroSchema.getJson()); } else if (avroSchema.getUid() != null) { try { final Schema schema = mSchemaTable.getSchema(avroSchema.getUid()); if (schema == null) { throw new FijiIOException(String.format( "Schema UID %d unknown in Fiji instance '%s'.", avroSchema.getUid(), mSchemaTable)); } return schema; } catch (IOException ioe) { throw new FijiIOException(ioe); } } else { throw new FijiIOException( "AvroSchema neither has a schema UID nor a schema JSON descriptor."); } } }
AvroSchema as = cellSchema.getDefaultReader(); if (as.getUid() != null) { Schema schema = schemaTable.getSchema(as.getUid()); schemaType = schema.getType(); } else if (as.getJson() != null) {