示例#1
0
  @Test
  public void testScanTable() throws Exception {
    final Kiji kiji = getKiji();
    final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.SIMPLE);
    kiji.createTable(layout.getName(), layout);
    final KijiTable table = kiji.openTable(layout.getName());
    try {
      // Table is empty:
      assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), "--kiji=" + table.getURI()));
      assertEquals(1, mToolOutputLines.length);
      assertTrue(mToolOutputLines[0].startsWith("Scanning kiji table: "));

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

      // Table has now one row:
      assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), "--kiji=" + table.getURI()));
      assertEquals(3, mToolOutputLines.length);
      assertTrue(mToolOutputLines[0].startsWith("Scanning kiji table: "));
      assertTrue(mToolOutputLines[1].startsWith("entity-id=hbase='"));

    } finally {
      table.close();
    }
  }
示例#2
0
  @Test
  public void testMultipleArguments() 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 KijiTableLayout layoutTwo = KijiTableLayouts.getTableLayout(KijiTableLayouts.FOO_TEST);
    kiji.createTable(layoutTwo.getDesc());

    final KijiTable table = kiji.openTable(layout.getName());
    try {
      final KijiTable tableTwo = kiji.openTable(layoutTwo.getName());
      try {
        assertEquals(
            BaseTool.SUCCESS,
            runTool(new LsTool(), table.getURI().toString(), tableTwo.getURI().toString()));
        assertEquals(9, mToolOutputLines.length);
        assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), kiji.getURI().toString()));
        assertEquals(2, mToolOutputLines.length);
        assertEquals(
            BaseTool.SUCCESS,
            runTool(new LsTool(), kiji.getURI().toString(), table.getURI().toString()));
        assertEquals(3, mToolOutputLines.length);
      } finally {
        tableTwo.release();
      }
    } finally {
      table.release();
    }
  }
  @Test
  public void testJSONBulkImporter() throws Exception {
    // Prepare input file:
    File inputFile = File.createTempFile("TestJSONImportInput", ".txt", getLocalTempDir());
    TestingResources.writeTextFile(
        inputFile, TestingResources.get(BulkImporterTestUtils.JSON_IMPORT_DATA));

    Configuration conf = getConf();
    conf.set(
        DescribedInputTextBulkImporter.CONF_FILE,
        BulkImporterTestUtils.localResource(BulkImporterTestUtils.FOO_IMPORT_DESCRIPTOR));

    // Run the bulk-import:
    final KijiMapReduceJob job =
        KijiBulkImportJobBuilder.create()
            .withConf(conf)
            .withBulkImporter(JSONBulkImporter.class)
            .withInput(MapReduceJobInputs.newTextMapReduceJobInput(new Path(inputFile.toString())))
            .withOutput(new DirectKijiTableMapReduceJobOutput(mTable.getURI()))
            .build();
    assertTrue(job.run());

    final Counters counters = job.getHadoopJob().getCounters();
    assertEquals(
        3, counters.findCounter(JobHistoryCounters.BULKIMPORTER_RECORDS_PROCESSED).getValue());
    assertEquals(
        1, counters.findCounter(JobHistoryCounters.BULKIMPORTER_RECORDS_INCOMPLETE).getValue());
    assertEquals(
        0, counters.findCounter(JobHistoryCounters.BULKIMPORTER_RECORDS_REJECTED).getValue());

    // Validate output:
    final KijiRowScanner scanner = mReader.getScanner(KijiDataRequest.create("info"));
    BulkImporterTestUtils.validateImportedRows(scanner, false);
    scanner.close();
  }
示例#4
0
 @Test
 public void testTableNoFamilies() throws Exception {
   final Kiji kiji =
       new InstanceBuilder(getKiji())
           .withTable(KijiTableLayouts.getLayout(KijiTableLayouts.NOFAMILY))
           .build();
   final KijiTable table = kiji.openTable("nofamily");
   try {
     assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), table.getURI().toString()));
   } finally {
     table.release();
   }
 }
示例#5
0
 @Test
 public void testKijiLsStartAndLimitRow() throws Exception {
   final Kiji kiji = getKiji();
   final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.FOO_TEST);
   kiji.createTable(layout.getDesc());
   final KijiTable table = kiji.openTable(layout.getName());
   try {
     assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), table.getURI().toString()));
     // TODO: Validate output
   } finally {
     ResourceUtils.releaseOrLog(table);
   }
 }
示例#6
0
 @Test
 public void testTableColumns() throws Exception {
   final Kiji kiji = getKiji();
   final KijiTableLayout layout = KijiTableLayouts.getTableLayout(KijiTableLayouts.SIMPLE);
   kiji.createTable(layout.getDesc());
   final KijiTable table = kiji.openTable(layout.getName());
   try {
     // Table is empty:
     assertEquals(BaseTool.SUCCESS, runTool(new LsTool(), table.getURI().toString()));
     assertEquals(1, mToolOutputLines.length);
     assertTrue(mToolOutputLines[0].contains("family:column"));
   } finally {
     ResourceUtils.releaseOrLog(table);
   }
 }
示例#7
0
  @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 LsTool(), "--kiji=" + table.getURI()));
      // TODO: Validate LsTool output
    } finally {
      table.close();
    }
  }
示例#8
0
  @Test
  public void testKijiLsStartAndLimitRow() 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("*****@*****.**")
        .withFamily("info")
        .withQualifier("email")
        .withValue(timestamp, "*****@*****.**")
        .withQualifier("name")
        .withValue(timestamp, "Garrett Wu")
        .withRow("*****@*****.**")
        .withFamily("info")
        .withQualifier("email")
        .withValue(timestamp, "*****@*****.**")
        .withQualifier("name")
        .withValue(timestamp, "Aaron Kimball")
        .withRow("*****@*****.**")
        .withFamily("info")
        .withQualifier("email")
        .withValue(timestamp, "*****@*****.**")
        .withQualifier("name")
        .withValue(timestamp, "Christophe Bisciglia")
        .withRow("*****@*****.**")
        .withFamily("info")
        .withQualifier("email")
        .withValue(timestamp, "*****@*****.**")
        .withQualifier("name")
        .withValue(timestamp, "Kiyan Ahmadizadeh")
        .withRow("*****@*****.**")
        .withFamily("info")
        .withQualifier("email")
        .withValue(timestamp, "*****@*****.**")
        .withQualifier("name")
        .withValue(timestamp, "John Doe")
        .withRow("*****@*****.**")
        .withFamily("info")
        .withQualifier("email")
        .withValue(timestamp, "*****@*****.**")
        .withQualifier("name")
        .withValue(timestamp, "Jane Doe")
        .build();

    final KijiTable table = kiji.openTable(layout.getName());
    try {
      assertEquals(
          BaseTool.SUCCESS,
          runTool(new LsTool(), "--kiji=" + table.getURI(), "--columns=info:name"));
      // TODO: Validate output

      assertEquals(
          BaseTool.SUCCESS,
          runTool(
              new LsTool(),
              "--kiji=" + table.getURI(),
              "--columns=info:name",
              "--start-row=hex:50000000000000000000000000000000", // after the second row.
              "--limit-row=hex:e0000000000000000000000000000000" // before the last row.
              ));
      // TODO: Validate output
    } finally {
      table.close();
    }
  }