Examples of KijiTable


Examples of org.kiji.schema.KijiTable

      throws IOException {

    final Configuration conf = job.getConfiguration();
    // As a precaution, be sure the table exists and can be opened.
    final Kiji kiji = Kiji.Factory.open(tableURI, conf);
    final KijiTable table = kiji.openTable(tableURI.getTable());
    ResourceUtils.releaseOrLog(table);
    ResourceUtils.releaseOrLog(kiji);

    // TODO: Check for jars config:
    // GenericTableMapReduceUtil.initTableInput(hbaseTableName, scan, job);
View Full Code Here

Examples of org.kiji.schema.KijiTable

    final HBaseKiji kiji = (HBaseKiji) Kiji.Factory.open(uri);
    try {
      Assert.assertNotNull(kiji.getZKClient());

      kiji.createTable(KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST));
      final KijiTable table = kiji.openTable("foo");
      try {
        final TableLayoutDesc layoutUpdate =
            TableLayoutDesc.newBuilder(table.getLayout().getDesc()).build();
        layoutUpdate.setReferenceLayout(layoutUpdate.getLayoutId());
        layoutUpdate.setLayoutId("2");

        final KijiTableLayout newLayout = kiji.modifyTableLayout(layoutUpdate);

      } finally {
        table.release();
      }

    } finally {
      kiji.release();
    }
View Full Code Here

Examples of org.kiji.schema.KijiTable

  @Test
  public void testOpenUnknownTable() throws Exception {
    final Kiji kiji = getKiji();

    try {
      final KijiTable table = kiji.openTable("unknown");
      Assert.fail("Should not be able to open a table that does not exist!");
    } catch (KijiTableNotFoundException ktnfe) {
      // Expected!
      LOG.debug("Expected error: {}", ktnfe);
      Assert.assertEquals("unknown", ktnfe.getTableURI().getTable());
View Full Code Here

Examples of org.kiji.schema.KijiTable

  public void testDeletingKijiTableWithUsersDoesNotFail() throws Exception {
    final Kiji kiji = getKiji();
    final TableLayoutDesc layoutDesc = KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST);
    final String tableName = layoutDesc.getName();
    kiji.createTable(layoutDesc);
    final KijiTable table = kiji.openTable(tableName);
    try {
      kiji.deleteTable(tableName);
    } finally {
      table.release();
    }
  }
View Full Code Here

Examples of org.kiji.schema.KijiTable

    try {
      tracker.start();
      // Initial user map should be empty:
      assertEquals(ImmutableSetMultimap.<String, String>of(), queue.poll(1, TimeUnit.SECONDS));

      final KijiTable table = kiji.openTable(tableName);
      try {
        // We opened a table, user map must contain exactly one entry:
        final Multimap<String, String> umap = queue.poll(1, TimeUnit.SECONDS);
        assertEquals(ImmutableSet.of(layoutId1), ImmutableSet.copyOf(umap.values()));
      } finally {
        table.release();
      }
      // Table is now closed, the user map should become empty:
      assertEquals(ImmutableSetMultimap.<String, String>of(), queue.poll(1, TimeUnit.SECONDS));
    } finally {
      tracker.close();
View Full Code Here

Examples of org.kiji.schema.KijiTable

        .build();
  }

  @Test
  public void testOpenReaders() throws IOException {
    final KijiTable table = mKiji.openTable("user");
    try {
      final HBaseKijiTable htable = HBaseKijiTable.downcast(table);
      final TableLayoutMonitor monitor = htable.getTableLayoutMonitor();
      assertTrue(monitor.getLayoutConsumers().isEmpty());
      // Readers should register with the table as they open.
      final KijiTableReader reader = table.openTableReader();
      // Check that all readers are accounted for.
      assertTrue(monitor.getLayoutConsumers().size() == 1);
      // Readers should unregister as they close.
      reader.close();
      // Check that no readers remain.
      assertTrue(monitor.getLayoutConsumers().isEmpty());
    } finally {
      table.release();
    }
  }
View Full Code Here

Examples of org.kiji.schema.KijiTable

    }
  }

  @Test
  public void testOpenWriters() throws IOException {
    final KijiTable table = mKiji.openTable("user");
    try {
      final HBaseKijiTable htable = HBaseKijiTable.downcast(table);
      final TableLayoutMonitor monitor = htable.getTableLayoutMonitor();
      assertTrue(monitor.getLayoutConsumers().isEmpty());
      // Writers should register with the table as they open.
      final KijiTableWriter writer = table.openTableWriter();
      final KijiBufferedWriter bufferedWriter = table.getWriterFactory().openBufferedWriter();
      final AtomicKijiPutter atomicPutter = table.getWriterFactory().openAtomicPutter();

      // Check that all writers are accounted for.
      final Set<LayoutConsumer> consumers = monitor.getLayoutConsumers();
      assertTrue(consumers.size() == 3);

      // Writers should unregister as they close.
      writer.close();
      bufferedWriter.close();
      atomicPutter.close();

      // Check that no writers remain.
      assertTrue(monitor.getLayoutConsumers().isEmpty());
    } finally {
      table.release();
    }
  }
View Full Code Here

Examples of org.kiji.schema.KijiTable

    }
  }

  @Test
  public void testUpdateLayout() throws IOException {
    final KijiTable table = mKiji.openTable("user");
    try {
      final HBaseKijiTable htable = HBaseKijiTable.downcast(table);
      final TableLayoutMonitor monitor = htable.getTableLayoutMonitor();
      assertTrue(monitor.getLayoutConsumers().isEmpty());
      final KijiTableWriter writer = table.openTableWriter();
      try {
        assertTrue(monitor.getLayoutConsumers().size() == 1);

        // We can write to info:name, but not family:column.
        writer.put(table.getEntityId("foo"), "info", "name", "new-val");
        try {
          writer.put(table.getEntityId("foo"), "family", "column", "foo-val");
          fail("writer.put() should have thrown an IOException.");
        } catch (NoSuchColumnException nsce) {
          assertEquals("family:column", nsce.getMessage());
        }

        // Update the table layout.
        final KijiTableLayout newLayout =
            KijiTableLayout.newLayout(KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE));
        monitor.updateLayoutConsumers(newLayout);

        // Now we can write to family:column, but not info:name.
        writer.put(table.getEntityId("foo"), "family", "column", "foo-val");
        try {
          writer.put(table.getEntityId("foo"), "info", "name", "two-val");
          fail("writer.put() should have thrown an IOException.");
        } catch (NoSuchColumnException nsce) {
          assertEquals("info:name", nsce.getMessage());
        }
      } finally {
        writer.close();
      }
    } finally {
      table.release();
    }
  }
View Full Code Here

Examples of org.kiji.schema.KijiTable

      try {
        tracker.start();
        // Initial user map should be empty:
        assertEquals(ImmutableSetMultimap.<String, String>of(), queue.poll(2, TimeUnit.SECONDS));

        KijiTable kijiTable = kiji.openTable(tableName);
        try {
          // We opened a table, user map must contain exactly one entry:
          assertEquals(ImmutableSet.of(layoutId1),
              ImmutableSet.copyOf(queue.poll(2, TimeUnit.SECONDS).values()));

          // Push a layout update (a no-op, but with a new layout ID):
          final TableLayoutDesc newLayoutDesc =
              KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST);
          newLayoutDesc.setReferenceLayout(layoutId1);
          newLayoutDesc.setLayoutId(layoutId2);
          newLayoutDesc.setName(tableName);

          kiji.modifyTableLayout(newLayoutDesc);

          // The new user map should eventually reflect the new layout ID. There may be an
          // intermediate state of no registered users, and then the table user is re-registered
          // with the new layout.
          Collection<String> users = queue.take().values();
          if (users.isEmpty()) {
            users = queue.take().values();
          }
          assertEquals(ImmutableSet.of(layoutId2),
            ImmutableSet.copyOf(users));

        } finally {
          kijiTable.release();
        }

        // Table is now closed, the user map should become empty:
        assertEquals(ImmutableSetMultimap.<String, String>of(), queue.poll(2, TimeUnit.SECONDS));
      } finally {
View Full Code Here

Examples of org.kiji.schema.KijiTable

                        .withValue(1L, "value-1")
                        .withValue(2L, "value-2")
                        .withValue(3L, "value-3")
        .build();

    final KijiTable table = kiji.openTable("row_data_test_table");
    try {
      final KijiTableReader reader = table.openTableReader();
      try {
        final KijiDataRequest dataRequest = KijiDataRequest.builder()
            .addColumns(ColumnsDef.create()
                .withMaxVersions(1)
                .add("family", "qual0"))
            .addColumns(ColumnsDef.create()
                .withMaxVersions(2)
                .add("family", "qual1"))
            .addColumns(ColumnsDef.create()
                .withMaxVersions(3)
                .add("family", "qual2"))
            .build();
        final KijiRowData row = reader.get(table.getEntityId("row0"), dataRequest);
        assertEquals(1, row.getValues("family", "qual0").size());
        assertEquals(2, row.getValues("family", "qual1").size());
        assertEquals(3, row.getValues("family", "qual2").size());
      } finally {
        reader.close();
      }
    } finally {
      table.release();
    }
  }
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.