Package org.kiji.schema.layout

Examples of org.kiji.schema.layout.KijiTableLayout


  @Test
  public void testShouldWorkWithRKF2SuppressedLayout() throws Exception {
    final TableLayoutDesc desc =
        KijiTableLayouts.getLayout(KijiTableLayouts.HASH_PREFIXED_FORMATTED_MULTI_COMPONENT);
    final KijiTableLayout layout = KijiTableLayout.newLayout(desc);

    // Construct complex entity id.
    final String eidString = String.format("[%s,%s,%s,%d,%d]",
        JSONObject.quote(UNUSUAL_STRING_EID),
        JSONObject.quote(UNUSUAL_STRING_EID),
View Full Code Here


  @Test
  public void testShouldWorkWithRKF2FormattedLayout() throws Exception {
    final TableLayoutDesc desc =
        KijiTableLayouts.getLayout(KijiTableLayouts.HASH_PREFIXED_FORMATTED_MULTI_COMPONENT);
    final KijiTableLayout layout = KijiTableLayout.newLayout(desc);

    // Construct complex entity id.
    final String eidString = String.format("[%s,%s,%s,%d,%d]",
        JSONObject.quote(UNUSUAL_STRING_EID),
        JSONObject.quote(UNUSUAL_STRING_EID),
View Full Code Here

  @Test
  public void testIntegerComponentsShouldBePromotableToLong() throws Exception {
    final TableLayoutDesc desc =
        KijiTableLayouts.getLayout(KijiTableLayouts.HASH_PREFIXED_FORMATTED_MULTI_COMPONENT);
    final KijiTableLayout layout = KijiTableLayout.newLayout(desc);

    // Construct complex entity id.
    final String eidString = String.format("[%s,%s,%s,%d,%d]",
        JSONObject.quote(UNUSUAL_STRING_EID),
        JSONObject.quote(UNUSUAL_STRING_EID),
View Full Code Here

  @Test
  public void testLongComponentsShouldNotComplain() throws Exception {
    final TableLayoutDesc desc =
        KijiTableLayouts.getLayout(KijiTableLayouts.HASH_PREFIXED_FORMATTED_MULTI_COMPONENT);
    final KijiTableLayout layout = KijiTableLayout.newLayout(desc);

    // Construct complex entity id.
    final String eidString = String.format("[%s,%s,%s,%d,%d]",
        JSONObject.quote(UNUSUAL_STRING_EID),
        JSONObject.quote(UNUSUAL_STRING_EID),
View Full Code Here

    return getTempLayoutFile(layout.getDesc());
  }

  @Test
  public void testCreateHashedTableWithNumRegions() throws Exception {
    final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FOO_TEST);
    final File layoutFile = getTempLayoutFile(layout);
    final KijiURI tableURI =
        KijiURI.newBuilder(getKiji().getURI()).withTableName(layout.getName()).build();

    assertEquals(BaseTool.SUCCESS, runTool(new CreateTableTool(),
      "--table=" + tableURI,
      "--layout=" + layoutFile,
      "--num-regions=" + 2,
View Full Code Here

    assertTrue(mToolOutputLines[1].startsWith("Creating Kiji table"));
  }

  @Test
  public void testCreateUnhashedTableWithSplitKeys() throws Exception {
    final KijiTableLayout layout =
        KijiTableLayout.newLayout(KijiTableLayouts.getFooUnhashedTestLayout());
    final File layoutFile = getTempLayoutFile(layout);
    final KijiURI tableURI =
        KijiURI.newBuilder(getKiji().getURI()).withTableName(layout.getName()).build();

    final String splitKeyFile =
        getClass().getClassLoader().getResource(REGION_SPLIT_KEY_FILE).getPath();

    assertEquals(BaseTool.SUCCESS, runTool(new CreateTableTool(),
View Full Code Here

  }

  @Test
  public void testCreateHashedTableWithSplitKeys() throws Exception {
    final KijiTableLayout layout =
        KijiTableLayouts.getTableLayout(KijiTableLayouts.FOO_TEST_LEGACY);
    final File layoutFile = getTempLayoutFile(layout);
    final KijiURI tableURI =
        KijiURI.newBuilder(getKiji().getURI()).withTableName(layout.getName()).build();

    final String splitKeyFile =
        getClass().getClassLoader().getResource(REGION_SPLIT_KEY_FILE).getPath();

    try {
View Full Code Here

    }
  }

  @Test
  public void testCreateUnhashedTableWithNumRegions() throws Exception {
    final KijiTableLayout layout =
        KijiTableLayout.newLayout(KijiTableLayouts.getFooUnhashedTestLayout());
    final File layoutFile = getTempLayoutFile(layout);
    final KijiURI tableURI =
        KijiURI.newBuilder(getKiji().getURI()).withTableName(layout.getName()).build();

    try {
      runTool(new CreateTableTool(),
        "--table=" + tableURI,
        "--layout=" + layoutFile,
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

      TableLayoutDesc tableLayout,
      byte[][] splitKeys) throws IOException {
    final KijiURI tableURI = KijiURI.newBuilder(mURI).withTableName(tableLayout.getName()).build();

    // This will validate the layout and may throw an InvalidLayoutException.
    final KijiTableLayout kijiTableLayout = KijiTableLayout.newLayout(tableLayout);

    if (getMetaTable().tableExists(tableLayout.getName())) {
      throw new KijiAlreadyExistsException(
          String.format("Kiji table '%s' already exists.", tableURI), tableURI);
    }

    if (tableLayout.getKeysFormat() instanceof RowKeyFormat) {
      LOG.warn("Usage of 'RowKeyFormat' is deprecated. New tables should use 'RowKeyFormat2'.");
    }

    getMetaTable().updateTableLayout(tableLayout.getName(), tableLayout);

    if (mSystemVersion.compareTo(Versions.SYSTEM_2_0) >= 0) {
      // system-2.0 clients retrieve the table layout from ZooKeeper as a stream of notifications.
      // Invariant: ZooKeeper hold the most recent layout of the table.
      LOG.debug("Writing initial table layout in ZooKeeper for table {}.", tableURI);
      try {
        ZooKeeperUtils.setTableLayout(
            mZKClient,
            tableURI,
            kijiTableLayout.getDesc().getLayoutId());
      } catch (Exception e) {
        ZooKeeperUtils.wrapAndRethrow(e);
      }
    }
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.