Package org.kiji.schema.layout

Examples of org.kiji.schema.layout.KijiTableLayout


    // Always surround with a try {} finally{} so the kiji gets released,
    // no matter what happens.
    try {
      // ----- Create a kiji table. -----
      // First, we need to create a table layout.
      final KijiTableLayout layout =
        KijiTableLayout.newLayout(
          KijiTableLayout.readTableLayoutDescFromJSON(
              new FileInputStream(tableDesc)));

      // Create the kiji table.
View Full Code Here


  }

  @Test
  public void testFormattedRowKey() throws Exception {
    final Kiji kiji = getKiji();
    final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FORMATTED_RKF);
    new InstanceBuilder(kiji)
        .withTable(layout.getName(), layout)
            .withRow("dummy", "str1", "str2", 1, 2L)
                .withFamily("family").withQualifier("column")
                    .withValue(1L, "string-value")
                    .withValue(2L, "string-value2")
            .withRow("dummy", "str1", "str2", 1)
                .withFamily("family").withQualifier("column").withValue(1L, "string-value")
            .withRow("dummy", "str1", "str2")
                .withFamily("family").withQualifier("column").withValue(1L, "string-value")
            .withRow("dummy", "str1")
                .withFamily("family").withQualifier("column").withValue(1L, "string-value")
            .withRow("dummy")
                .withFamily("family").withQualifier("column").withValue(1L, "string-value")
        .build();

    final KijiTable table = kiji.openTable(layout.getName());
    try {
      assertEquals(BaseTool.SUCCESS, runTool(new ScanTool(), table.getURI().toString()));
      assertEquals(15, mToolOutputLines.length);
    } finally {
      ResourceUtils.releaseOrLog(table);
View Full Code Here

    final Kiji kiji = getKiji();

    TableLayoutDesc desc = KijiTableLayouts.getLayout(KijiTableLayouts.FOO_TEST);
    ((RowKeyFormat2)desc.getKeysFormat()).setEncoding(RowKeyEncoding.RAW);

    final KijiTableLayout layout =  KijiTableLayout.newLayout(desc);
    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 ScanTool(),
          table.getURI().toString() + "info:name"
      ));
      assertEquals(18, mToolOutputLines.length);
View Full Code Here

  }

  @Test
  public void testRangeScanFormattedRKF() 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 ScanTool(), table.getURI().toString(),
          "--start-row=['NYC','Technology','widget',1,2]",
          "--limit-row=['NYC','Technology','widget',1,30]",
          "--debug"
View Full Code Here

  private KijiTableReader mReader;

  @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

   * @param layoutDesc The layout descriptor of the Kiji table being added.
   * @return A builder to continue building with.
   * @throws InvalidLayoutException is the layout is invalid.
   */
  public TableBuilder withTable(TableLayoutDesc layoutDesc) throws InvalidLayoutException {
    final KijiTableLayout layout = KijiTableLayout.newLayout(layoutDesc);
    return withTable(layoutDesc.getName(), layout);
  }
View Full Code Here

   *
   * @param table An existing Kiji table to populate.
   * @return A builder to continue building with.
   */
  public TableBuilder withTable(KijiTable table) {
    final KijiTableLayout layout = table.getLayout();
    mCells.put(layout.getName(),
        new HashMap<EntityId, Map<String, Map<String, Map<Long, Object>>>>());
    mLayouts.put(layout.getName(), layout);

    return new TableBuilder(layout.getName());
  }
View Full Code Here

    // Build tables.
    for (Map.Entry<String, Map<EntityId, Map<String, Map<String, Map<Long, Object>>>>> tableEntry
        : mCells.entrySet()) {
      final String tableName = tableEntry.getKey();
      final KijiTableLayout layout = mLayouts.get(tableName);
      final Map<EntityId, Map<String, Map<String, Map<Long, Object>>>> table =
          tableEntry.getValue();

      // Create & open a Kiji table.
      if (kiji.getTableNames().contains(tableName)) {
        LOG.info(String.format("  Populating existing table: %s", tableName));
      } else {
        LOG.info(String.format("  Creating and populating table: %s", tableName));
        kiji.createTable(layout.getDesc());
      }
      final KijiTable kijiTable = kiji.openTable(tableName);
      try {
        final KijiTableWriter writer = kijiTable.openTableWriter();
        try {
View Full Code Here

  private static final Logger LOG = LoggerFactory.getLogger(TestRowDataColumnFamilyOps.class);
  private KijiRowData mRow1;

  @Before
  public void setupInstance() throws Exception {
   final KijiTableLayout layout =
      KijiTableLayout.newLayout(KijiTableLayouts.getLayout(
          KijiTableLayouts.TWO_COLUMN_DIFFERENT_TYPES));
   new InstanceBuilder(getKiji())
        .withTable("table", layout)
            .withRow("row1")
View Full Code Here

     * Constructs a new in-memory Kiji table builder.
     *
     * @param table Desired name of the Kiji table.
     */
    protected TableBuilder(String table) {
      final KijiTableLayout layout = mLayouts.get(table);

      mTableName = table;
      mEntityIdFactory = EntityIdFactory.getFactory(layout);
    }
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.