Package org.kiji.schema.layout

Examples of org.kiji.schema.layout.KijiTableLayout


  private KijiTable mTable = null;

  @Before
  public void setupTestResourceUtils() throws IOException {
    final KijiTableLayout layout = KijiTableLayout.newLayout(
        KijiTableLayouts.getLayout(KijiTableLayouts.ROW_DATA_TEST));
    new InstanceBuilder(getKiji())
        .withTable("row_data_test_table", layout)
            .withRow("foo")
                .withFamily("family")
View Full Code Here


  }

  @Test
  public void testGetFromTable() throws Exception {
    final Kiji kiji = getKiji();
    final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.SIMPLE);
    kiji.createTable(layout.getName(), layout);

    new InstanceBuilder(kiji)
        .withTable(layout.getName(), layout)
            .withRow("hashed")
                .withFamily("family").withQualifier("column").withValue(314L, "value")
        .build();

    final KijiTable table = kiji.openTable(layout.getName());
    try {
      assertEquals(BaseTool.SUCCESS, runTool(new GetTool(), table.getURI().toString(),
          "--entity-id=hashed"));
    } finally {
      ResourceUtils.releaseOrLog(table);
View Full Code Here

  }

  @Test
  public void testGetFromTableMore() throws Exception {
    final Kiji kiji = getKiji();
    final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FOO_TEST);
    final long timestamp = 10L;
    new InstanceBuilder(kiji)
        .withTable(layout.getName(), layout)
            .withRow("gwu@usermail.example.com")
                .withFamily("info")
                    .withQualifier("email").withValue(timestamp, "gwu@usermail.example.com")
                    .withQualifier("name").withValue(timestamp, "Garrett Wu")
            .withRow("aaron@usermail.example.com")
                .withFamily("info")
                    .withQualifier("email").withValue(timestamp, "aaron@usermail.example.com")
                    .withQualifier("name").withValue(timestamp, "Aaron Kimball")
            .withRow("christophe@usermail.example.com")
                .withFamily("info")
                    .withQualifier("email")
                        .withValue(timestamp, "christophe@usermail.example.com")
                    .withQualifier("name").withValue(timestamp, "Christophe Bisciglia")
            .withRow("kiyan@usermail.example.com")
                .withFamily("info")
                    .withQualifier("email").withValue(timestamp, "kiyan@usermail.example.com")
                    .withQualifier("name").withValue(timestamp, "Kiyan Ahmadizadeh")
            .withRow("john.doe@gmail.com")
                .withFamily("info")
                    .withQualifier("email").withValue(timestamp, "john.doe@gmail.com")
                    .withQualifier("name").withValue(timestamp, "John Doe")
            .withRow("jane.doe@gmail.com")
                .withFamily("info")
                    .withQualifier("email").withValue(timestamp, "jane.doe@gmail.com")
                    .withQualifier("name").withValue(timestamp, "Jane Doe")
        .build();

    final KijiTable table = kiji.openTable(layout.getName());
    try {
      assertEquals(BaseTool.SUCCESS, runTool(new GetTool(), table.getURI().toString(),
          "--entity-id=[\"jane.doe@gmail.com\"]"));
      assertEquals(5, mToolOutputLines.length);
      EntityId eid = EntityIdFactory.getFactory(layout).getEntityId("gwu@usermail.example.com");
View Full Code Here

  }

  @Test
  public void testGetFormattedRKF() throws Exception {
    final Kiji kiji = getKiji();
    final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FORMATTED_RKF);
    new InstanceBuilder(kiji)
        .withTable(layout.getName(), layout)
            .withRow("NYC", "Technology", "widget", 1, 2)
                .withFamily("family").withQualifier("column")
                    .withValue("Candaules")
            .withRow("NYC", "Technology", "widget", 1, 20)
                .withFamily("family").withQualifier("column")
                    .withValue("Croesus")
            .withRow("NYC", "Technology", "thingie", 2)
                .withFamily("family").withQualifier("column")
                    .withValue("Gyges")
            .withRow("DC", "Technology", "stuff", 123)
                .withFamily("family").withQualifier("column")
                    .withValue("Glaucon")
            .withRow("DC", "Technology", "stuff", 124, 1)
                .withFamily("family").withQualifier("column")
                    .withValue("Lydia")
        .build();

    final KijiTable table = kiji.openTable(layout.getName());
    try {
      assertEquals(BaseTool.SUCCESS, runTool(new GetTool(), table.getURI().toString(),
          "--entity-id=['NYC','Technology','widget',1,2]"
          ));
      assertEquals(3, mToolOutputLines.length);
View Full Code Here

    final KijiMetaTable metaTable = kiji.getMetaTable();
    final KijiSchemaTable schemaTable = kiji.getSchemaTable();
    final KijiSystemTable systemTable = kiji.getSystemTable();

    final TableLayoutDesc layout = KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST);
    final KijiTableLayout updatedLayout = metaTable.updateTableLayout("foo", layout);
    metaTable.putValue("foo", "key", BYTES_VALUE);

    systemTable.putValue("testKey", Bytes.toBytes("testValue"));
    assertEquals(1, metaTable.listTables().size());
    assertEquals(1, metaTable.tableSet().size());
    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 =
        backup.getMetaTable().getTables().get("foo").getKeyValueBackup().getKeyValues();
    assertEquals(1, keyValues.size());
    assertEquals("key", keyValues.get(0).getKey());
    assertArrayEquals(BYTES_VALUE, keyValues.get(0).getValue().array());

    // make sure layouts are what we expect.
    List<TableLayoutBackupEntry> layoutBackups =
        backup.getMetaTable().getTables().get("foo").getTableLayoutsBackup().getLayouts();
    assertEquals(1, layoutBackups.size());
    assertEquals(updatedLayout.getDesc(), layoutBackups.get(0).getLayout());

    metaTable.deleteTable("foo");
    assertTrue(!metaTable.tableSet().contains("foo"));
    assertEquals(0, metaTable.listTables().size());
    assertEquals(0, metaTable.tableSet().size());
View Full Code Here

    // Verify that the original KijiMetaTable sees the change.
    final Kiji kiji = getKiji();
    final KijiMetaTable metaTable = kiji.getMetaTable();

    final TableLayoutDesc layout = KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST);
    final KijiTableLayout updatedLayout = metaTable.updateTableLayout("foo", layout);

    final KijiMetaTable outMeta = metaTable.putValue("foo", "key", BYTES_VALUE);
    assertEquals("putValue() exposes the delegate", metaTable, outMeta);

    outMeta.deleteTable("foo");
View Full Code Here

  ) throws IOException;

  @Before
  public final void setupEnvironment() throws Exception {
    // Get the test table layouts.
    final KijiTableLayout layout = KijiTableLayout.newLayout(
        KijiTableLayouts.getLayout(KijiTableLayouts.COUNTER_TEST));

    // Populate the environment.
    mKiji = new InstanceBuilder(getKiji())
        .withTable("user", layout)
View Full Code Here

  private KijiTableReader mReader;

  @Before
  public void setupEnvironment() throws Exception {
    // Get the test table layouts.
    final KijiTableLayout layout = KijiTableLayout.newLayout(
        KijiTableLayouts.getLayout(KijiTableLayouts.COUNTER_TEST));

    // Populate the environment.
    mKiji = new InstanceBuilder(getKiji())
        .withTable("user", layout)
View Full Code Here

    return layoutFile;
  }

  @Test
  public void testChangeRowKeyHashing() throws Exception {
    final KijiTableLayout layout =
            KijiTableLayouts.getTableLayout(KijiTableLayouts.FOO_TEST_LEGACY);
    getKiji().createTable(layout.getDesc());

    final File newLayoutFile = getTempLayoutFile(KijiTableLayouts.getFooChangeHashingTestLayout());
    final KijiURI tableURI =
        KijiURI.newBuilder(getKiji().getURI()).withTableName(layout.getName()).build();

    try {
      runTool(new LayoutTool(),
        "--table=" + tableURI,
        "--do=set",
View Full Code Here

    metaTable.getTableLayout(tableName);

    final KijiURI tableURI = KijiURI.newBuilder(mURI).withTableName(tableName).build();
    LOG.debug("Applying layout update {} on table {}", update, tableURI);

    KijiTableLayout newLayout = null;

    if (dryRun) {
      // Process column ids and perform validation, but don't actually update the meta table.
      final List<KijiTableLayout> layouts = metaTable.getTableLayoutVersions(tableName, 1);
      final KijiTableLayout currentLayout = layouts.isEmpty() ? null : layouts.get(0);
      newLayout = KijiTableLayout.createUpdatedLayout(update, currentLayout);
    } else {
      // Actually set it.
      if (mSystemVersion.compareTo(Versions.SYSTEM_2_0) >= 0) {
        try {
View Full Code Here

TOP

Related Classes of org.kiji.schema.layout.KijiTableLayout

Copyright © 2018 www.massapicom. 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.