Examples of KijiSchemaTable


Examples of org.kiji.schema.KijiSchemaTable

   * @param kiji the connected Kiji instance.
   * @throws java.io.IOException if there is an error communicating with HBase.
   */
  public void restoreSchemas(MetadataBackup backup, Kiji kiji) throws IOException {
    // Restore all Schema table entries in the file.
    final KijiSchemaTable schemaTable = kiji.getSchemaTable();
    LOG.info("Restoring schema table entries...");
    schemaTable.fromBackup(backup.getSchemaTable());
    LOG.info("Restored " + backup.getSchemaTable().getEntries().size() + " entries.");
  }
View Full Code Here

Examples of org.kiji.schema.KijiSchemaTable

    assertTrue(results.getCauses().contains(result3));
  }

  @Test
  public void testAvroSchemaEquals() throws IOException {
    final KijiSchemaTable schemaTable = getKiji().getSchemaTable();

    final long stringUID = schemaTable.getOrCreateSchemaId(STRING_SCHEMA);
    final long intUID = schemaTable.getOrCreateSchemaId(INT_SCHEMA);
    final String stringJSON = STRING_SCHEMA.toString();
    final String intJSON = INT_SCHEMA.toString();

    final AvroSchema stringUIDAS = AvroSchema.newBuilder().setUid(stringUID).build();
    final AvroSchema stringJSONAS = AvroSchema.newBuilder().setJson(stringJSON).build();
View Full Code Here

Examples of org.kiji.schema.KijiSchemaTable

    assertFalse(AvroUtils.avroSchemaEquals(schemaTable, stringJSONAS, intUIDAS));
  }

  @Test
  public void testAvroSchemaListContains() throws IOException {
    final KijiSchemaTable schemaTable = getKiji().getSchemaTable();

    final long stringUID = schemaTable.getOrCreateSchemaId(STRING_SCHEMA);
    final long intUID = schemaTable.getOrCreateSchemaId(INT_SCHEMA);
    final String stringJSON = STRING_SCHEMA.toString();
    final String intJSON = INT_SCHEMA.toString();

    final AvroSchema stringUIDAS = AvroSchema.newBuilder().setUid(stringUID).build();
    final AvroSchema stringJSONAS = AvroSchema.newBuilder().setJson(stringJSON).build();
View Full Code Here

Examples of org.kiji.schema.KijiSchemaTable

  private KijiURI mKijiURI;
  private HBaseTableLayoutDatabase mTableLayoutDatabase;

  @Before
  public final void setupTest() throws IOException {
    final KijiSchemaTable schemaTable = getKiji().getSchemaTable();

    final KijiURI hbaseURI = createTestHBaseURI();
    final String instanceName =
        String.format("%s_%s", getClass().getSimpleName(), mTestName.getMethodName());
    mKijiURI = KijiURI.newBuilder(hbaseURI).withInstanceName(instanceName).build();
View Full Code Here

Examples of org.kiji.schema.KijiSchemaTable

  @Test
  public void testBackupAndRestore() throws InterruptedException, IOException {
    final Kiji kiji = getKiji();
    final KijiMetaTable metaTable = kiji.getMetaTable();
    final KijiSchemaTable schemaTable = kiji.getSchemaTable();
    final KijiSystemTable systemTable = kiji.getSystemTable();

    // Update the layout for table foo.
    final TableLayoutDesc layout =
        KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST_FORMATTED_EID);
    final KijiTableLayout updatedLayout = metaTable.updateTableLayout("foo", layout);

    // Insert a user-level key-value pair for table foo.
    metaTable.putValue("foo", "key", BYTES_VALUE);

    // Insert a key-value pair in the system table
    systemTable.putValue("testKey", Bytes.toBytes("testValue"));

    // The meta table should have a single table, foo, in it.
    assertEquals(1, metaTable.listTables().size());
    assertEquals(1, metaTable.tableSet().size());

    // The meta table should have a single key-value pair, "key"/"value", for table foo.
    assertEquals(1, metaTable.keySet("foo").size());
    assertArrayEquals(BYTES_VALUE, metaTable.getValue("foo", "key"));

    // write to backupBuilder
    final MetadataBackup.Builder backupBuilder = MetadataBackup.newBuilder()
        .setLayoutVersion(kiji.getSystemTable().getDataVersion().toString())
        .setMetaTable(
            MetaTableBackup.newBuilder()
                .setTables(new HashMap<String, TableBackup>())
                .build())
        .setSchemaTable(
            SchemaTableBackup.newBuilder()
                .setEntries(new ArrayList<SchemaTableEntry>())
                .build())
        .setSystemTable(
            SystemTableBackup.newBuilder()
                .setEntries(new ArrayList<SystemTableEntry>())
                .build());
    backupBuilder.setMetaTable(metaTable.toBackup());
    backupBuilder.setSchemaTable(schemaTable.toBackup());
    backupBuilder.setSystemTable(systemTable.toBackup());
    final MetadataBackup backup = backupBuilder.build();

    // make sure metadata key-value pairs are what we expect.
    List<KeyValueBackupEntry> keyValues =
View Full Code Here

Examples of org.kiji.schema.KijiSchemaTable

   *
   * @return Tool exit code.
   * @throws IOException in case of an error.
   */
  private int registerSchema() throws IOException {
    final KijiSchemaTable table = mKiji.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()) {
View Full Code Here

Examples of org.kiji.schema.KijiSchemaTable

   *
   * @return Tool exit code.
   * @throws IOException in case of an error.
   */
  private int lookupSchema() throws IOException {
    final KijiSchemaTable table = mKiji.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: ");
    }
View Full Code Here

Examples of org.kiji.schema.KijiSchemaTable

   *
   * @return Tool exit code.
   * @throws IOException in case of an error.
   */
  private int getById() throws IOException {
    final KijiSchemaTable table = mKiji.getSchemaTable();
    final Schema schema = table.getSchema(mGetByIdFlag);
    Preconditions.checkArgument(
        schema != null, "No schema definition with ID: %s", mGetByIdFlag);

    if (isInteractive()) {
      getPrintStream().print("Schema hash of the given schema is: ");
    }
    getPrintStream().println(table.getSchemaHash(schema));
    if (mOutputFlag != null && !mOutputFlag.isEmpty()) {
      // Attempt to write to the output file.
      try {
        if (writeDefinitionToFile(schema)) {
          if (isInteractive()) {
View Full Code Here

Examples of org.kiji.schema.KijiSchemaTable

   *
   * @return Tool exit code.
   * @throws IOException in case of an error.
   */
  private int getByHash() throws IOException {
    final KijiSchemaTable table = mKiji.getSchemaTable();
    final BytesKey bytesKey = new BytesKey(ByteArrayFormatter.parseHex(mGetByHashFlag, ':'));
    final SchemaEntry sEntry = table.getSchemaEntry(bytesKey);
    final Schema schema = sEntry.getSchema();

    if (isInteractive()) {
      getPrintStream().print("Schema ID for the given schema is: ");
    }
View Full Code Here

Examples of org.kiji.schema.KijiSchemaTable

   *
   * @return The Tool exit code.
   * @throws IOException in case of an error.
   */
  private int list() throws IOException {
    final KijiSchemaTable schemaTable = mKiji.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;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.