Package org.kiji.schema

Examples of org.kiji.schema.KijiTableReader


                        .withValue(1L, "value")
        .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()
                .addFamily("family"))
            .build();
        final KijiRowData row = reader.get(table.getEntityId("row0"), dataRequest);
        assertEquals(1, row.getValues("family", "qual0").size());
        assertEquals(1, row.getValues("family", "qual1").size());
      } finally {
        reader.close();
      }
    } finally {
      table.release();
    }
  }
View Full Code Here


                        .withValue("value1")
        .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(HConstants.ALL_VERSIONS)
                .add("family", "qual0"))
            .addColumns(ColumnsDef.create()
                .withMaxVersions(HConstants.ALL_VERSIONS)
                .withPageSize(1)
                .addFamily("map"))
            .build();
        final KijiRowScanner scanner = reader.getScanner(dataRequest);
        try {
          int nrows = 0;
          boolean foundRow0 = false;
          for (KijiRowData row : scanner) {
            LOG.debug("Scanning row: {}", row);

            // All rows but "row3" should be scanned through:
            assertFalse(row.getEntityId().getComponentByIndex(0).equals("row3"));

            // Validate "row0", which contains both paged and non-paged cells:
            if (row.getEntityId().getComponentByIndex(0).equals("row0")) {
              foundRow0 = true;

              // Make sure we can still read the columns that are not paged:
              assertEquals(ImmutableMap.builder()
                  .put(3L, new Utf8("value3"))
                  .put(2L, new Utf8("value2"))
                  .put(1L, new Utf8("value1"))
                  .build(),
                  row.getValues("family", "qual0"));

              // The values for "map:*" should ideally not be retrieved.
              // We cannot use KeyOnlyFilter, but we can use FirstKeyOnlyFilter to limit
              // the number of KeyValues fetched:
              assertEquals(ImmutableMap.builder()
                  .put("int1", ImmutableMap.builder()
                      .put(1L, 11)
                      .build())
                  .build(),
                  row.getValues("map"));
            }

            nrows += 1;
          }
          assertEquals(3, nrows);
          assertTrue(foundRow0);
        } finally {
          scanner.close();
        }
      } finally {
        reader.close();
      }
    } finally {
      table.release();
    }
  }
View Full Code Here

                        .withValue("value1")
        .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(HConstants.ALL_VERSIONS)
                .withPageSize(1)
                .add("family", "qual0"))
            .addColumns(ColumnsDef.create()
                .withMaxVersions(HConstants.ALL_VERSIONS)
                .addFamily("map"))
            .build();
        final KijiRowScanner scanner = reader.getScanner(dataRequest);
        try {
          int nrows = 0;
          boolean foundRow0 = false;
          for (KijiRowData row : scanner) {
            LOG.debug("Scanning row: {}", row);

            // All rows but "row3" should be scanned through:
            assertFalse(row.getEntityId().getComponentByIndex(0).equals("row3"));

            // Validate "row0", which contains both paged and non-paged cells:
            if (row.getEntityId().getComponentByIndex(0).equals("row0")) {
              foundRow0 = true;

              // The values for "family:qual0" should ideally not be retrieved.
              // We cannot use KeyOnlyFilter, but we can use FirstKeyOnlyFilter to limit
              // the number of KeyValues fetched:
              assertEquals(ImmutableMap.builder()
                  .put(3L, new Utf8("value3"))
                  .build(),
                  row.getValues("family", "qual0"));

              // Make sure we can still read the columns that are not paged:
              assertEquals(ImmutableMap.builder()
                  .put("int1", ImmutableMap.builder()
                      .put(0L, 10)
                      .put(1L, 11)
                      .build())
                  .put("int2", ImmutableMap.builder()
                      .put(0L, 20)
                      .put(1L, 21)
                      .build())
                  .build(),
                  row.getValues("map"));
            }

            nrows += 1;
          }
          assertEquals(3, nrows);
          assertTrue(foundRow0);
        } finally {
          scanner.close();
        }
      } finally {
        reader.close();
      }
    } finally {
      table.release();
    }
  }
View Full Code Here

                        .withValue("value2")
        .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()
                .withPageSize(1)
                .add("family", "qual0")
                .add("family", "qual1"))
            .build();
        final KijiRowScanner scanner = reader.getScanner(dataRequest);
        try {
          int nrows = 0;
          for (KijiRowData row : scanner) {
            LOG.debug("Scanning row: {}", row);

            // All rows but "row2" should be scanned through:
            assertFalse(row.getEntityId().getComponentByIndex(0).equals("row2"));
            nrows += 1;
          }
          assertEquals(2, nrows);
        } finally {
          scanner.close();
        }
      } finally {
        reader.close();
      }
    } finally {
      table.release();
    }
  }
View Full Code Here

        writer.put(table.getEntityId("row1"), "family", "column", 1L, "Value at timestamp 1.");
      } finally {
        writer.close();
      }

      final KijiTableReader reader = table.openTableReader();
      try {
        final KijiDataRequest dataRequest = KijiDataRequest.builder()
            .addColumns(ColumnsDef.create().withMaxVersions(100).add("family", "column"))
            .build();

        // Try this as a get.
        final KijiRowData rowData = reader.get(table.getEntityId("row1"), dataRequest);
        String s = rowData.getValue("family", "column", 0L).toString();
        assertEquals(s, "Value at timestamp 0.");

        // Try this as a scan.
        int rowCounter = 0;
        final KijiRowScanner rowScanner = reader.getScanner(dataRequest);
        try {
          // Should be just one row, with two versions.
          for (KijiRowData kijiRowData : rowScanner) {
            LOG.info("Read from scanner! " + kijiRowData.toString());
            // Should see two versions for qualifier "column".
            assertEquals(
                "Value at timestamp 0.", kijiRowData.getValue("family", "column", 0L).toString());
            assertEquals(
                "Value at timestamp 1.", kijiRowData.getValue("family", "column", 1L).toString());
            rowCounter++;
          }
        } finally {
          rowScanner.close();
        }
        assertEquals(1, rowCounter);
      } finally {
        reader.close();
      }
    } finally {
      table.release();
    }
  }
View Full Code Here

            ToolUtils.getGroupTypeColumns(argURI.getColumns(), tableLayout);

        final KijiDataRequest request = ToolUtils.getDataRequest(
            mapTypeFamilies, groupTypeColumns, mMaxVersions, mMinTimestamp, mMaxTimestamp);

        final KijiTableReader reader = table.openTableReader();
        try {
          // Scan from startRow to limitRow.
          final EntityId startRow = (mStartRowFlag != null)
              ? ToolUtils.createEntityIdFromUserInputs(mStartRowFlag, tableLayout)
              : null;
View Full Code Here

TOP

Related Classes of org.kiji.schema.KijiTableReader

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.