/** * Initializes a TableLayoutUpdateValidator which interprets schema IDs from the schema table of * the given Fiji instance. * * @param fiji the Fiji instance from which to get schema definitions. * @throws IOException in case of an error reading from the schema table. */ public TableLayoutUpdateValidator(Fiji fiji) throws IOException { mFiji = fiji; mSchemaTable = mFiji.getSchemaTable(); }
/** {@inheritDoc} */ @Override public FijiSchemaTable getFijiSchemaTable(String instance) { final State state = mState.get(); Preconditions.checkState(state == State.STARTED, "Can not get a schema table while in state %s.", state); try { return getFiji(instance).getSchemaTable(); } catch (IOException e) { throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR); } }
/** * 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; }
/** * Restores all SchemaTable entries from the metadata backup. * * @param backup the deserialized backup of the metadata. * @param fiji the connected Fiji instance. * @throws IOException if there is an error communicating with HBase. */ public void restoreSchemas(MetadataBackup backup, Fiji fiji) throws IOException { // Restore all Schema table entries in the file. final FijiSchemaTable schemaTable = fiji.getSchemaTable(); LOG.info("Restoring schema table entries..."); schemaTable.fromBackup(backup.getSchemaTable()); LOG.info("Restored " + backup.getSchemaTable().getEntries().size() + " entries."); }
/** * Restores all SchemaTable entries from the metadata backup. * * @param backup the deserialized backup of the metadata. * @param fiji the connected Fiji instance. * @throws java.io.IOException if there is an error communicating with HBase. */ public void restoreSchemas(MetadataBackup backup, Fiji fiji) throws IOException { // Restore all Schema table entries in the file. final FijiSchemaTable schemaTable = fiji.getSchemaTable(); LOG.info("Restoring schema table entries..."); schemaTable.fromBackup(backup.getSchemaTable()); LOG.info("Restored " + backup.getSchemaTable().getEntries().size() + " entries."); }
/** * Lookup a schema. * * @return Tool exit code. * @throws IOException in case of an error. */ private int lookupSchema() throws IOException { final FijiSchemaTable table = mFiji.getSchemaTable(); final File file = new File(mLookupFlag); final Schema schema = new Schema.Parser().parse(file); final SchemaEntry sEntry = table.getSchemaEntry(schema); final long id = sEntry.getId(); final BytesKey hash = sEntry.getHash(); 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; }
/** * 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; }
final FijiSchemaTable table = mFiji.getSchemaTable(); final Schema schema = table.getSchema(mGetByIdFlag); Preconditions.checkArgument(
@Override protected int run(List<String> nonFlagArgs) throws Exception { Fiji fiji = null; FijiTable fijiTable = null; FijiSchemaTable schemaTable = null; try { fiji = Fiji.Factory.open(mTableURI); fijiTable = fiji.openTable(mTableURI.getTable()); FijiTableLayout fijiTableLayout = fijiTable.getLayout(); schemaTable = fiji.getSchemaTable(); getPrintStream().println(generateHiveDDLStatement(mTableURI, fijiTableLayout, schemaTable)); } catch (IOException ioe) { LOG.warn(ioe.getMessage()); return FAILURE; } finally { if (null != fiji) { ResourceUtils.releaseOrLog(fiji); } if (null != fijiTable) { ResourceUtils.releaseOrLog(fijiTable); } } return SUCCESS; } }
final FijiSchemaTable table = mFiji.getSchemaTable(); final BytesKey bytesKey = new BytesKey(ByteArrayFormatter.parseHex(mGetByHashFlag, ':')); final SchemaEntry sEntry = table.getSchemaEntry(bytesKey);
tableURI, layout, mTable.getFiji().getSchemaTable(), DefaultFijiCellEncoderFactory.get());
mTable.getURI(), layout, mTable.getFiji().getSchemaTable(), DefaultFijiCellEncoderFactory.get());
provider = CellDecoderProvider.create( layout, mTable.getFiji().getSchemaTable(), SpecificCellDecoderFactory.get(), mCellSpecOverrides);
mTable.getURI(), layout, mTable.getFiji().getSchemaTable(), DefaultFijiCellEncoderFactory.get());
.setLayoutVersion(fiji.getSystemTable().getDataVersion().toString()) .setSystemTable(fiji.getSystemTable().toBackup()) .setSchemaTable(fiji.getSchemaTable().toBackup()) .setMetaTable(fiji.getMetaTable().toBackup()) .build();
.setLayoutVersion(fiji.getSystemTable().getDataVersion().toString()) .setSystemTable(fiji.getSystemTable().toBackup()) .setSchemaTable(fiji.getSchemaTable().toBackup()) .setMetaTable(fiji.getMetaTable().toBackup()) .build();
mTable.getURI(), layout, mTable.getFiji().getSchemaTable(), DefaultFijiCellEncoderFactory.get());
provider = CellDecoderProvider.create( layout, mTable.getFiji().getSchemaTable(), SpecificCellDecoderFactory.get(), mCellSpecOverrides);
/** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public <T> void put(EntityId entityId, String family, String qualifier, long timestamp, T value) throws IOException { final FijiColumnName fijiColumn = new FijiColumnName(family, qualifier); final HBaseColumnName hbaseColumn = mColumnNameTranslator.toHBaseColumnName(fijiColumn); final CellSpec cellSpec = mTable.getLayout().getCellSpec(fijiColumn) .setSchemaTable(mFiji.getSchemaTable()); final FijiCellEncoder encoder = DefaultFijiCellEncoderFactory.get().create(cellSpec); final HFileKeyValue mrKey = new HFileKeyValue( entityId.getHBaseRowKey(), hbaseColumn.getFamily(), hbaseColumn.getQualifier(), timestamp, encoder.encode(value)); write(mrKey); }
+ Versions.LAYOUT_VALIDATION_VERSION + " and up; this layout is " + layoutVersion); mSchemaTable = fiji.getSchemaTable(); mSchemaResolver = new SchemaTableAvroResolver(mSchemaTable); mDescBuilder = TableLayoutDesc.newBuilder(tableLayoutDesc)