Package org.kiji.schema

Examples of org.kiji.schema.KijiTable


                        .withValue(1L, "value")
                    .withQualifier("qual1")
                        .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


                .withFamily("family")
                    .withQualifier("qual1")
                        .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

                .withFamily("family")
                    .withQualifier("qual1")
                        .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

                .withFamily("family")
                    .withQualifier("qual2")
                        .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

                .withFamily("family")
                    .withQualifier("qual2")
                        .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)
                .addFamily("map"))
            .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

    final Kiji kiji = Kiji.Factory.open(uri);
    try {
      kiji.createTable(layout1);

      final KijiTable table = kiji.openTable("table_name");
      try {
        final BlockingQueue<String> layoutQueue = Queues.newArrayBlockingQueue(1);

        final TableLayoutTracker tracker =
            new TableLayoutTracker(((HBaseKiji) kiji).getZKClient(), table.getURI(),
                new QueuingTableLayoutUpdateHandler(layoutQueue))
              .start();

        Assert.assertEquals("1", layoutQueue.poll(5, TimeUnit.SECONDS));

        final HBaseTableLayoutUpdater updater =
            new HBaseTableLayoutUpdater((HBaseKiji) kiji, table.getURI(), layout2);
        try {
          final Thread thread =
              new Thread() {
                /** {@inheritDoc} */
                @Override
                public void run() {
                  try {
                    updater.update();
                  } catch (Exception exn) {
                    throw new RuntimeException(exn);
                  }
                }
              };
          thread.start();
          thread.join(5000);

          Assert.assertEquals("2", layoutQueue.poll(5, TimeUnit.SECONDS));

          tracker.close();
        } finally {
          updater.close();
        }
      } finally {
        table.release();
      }
      kiji.deleteTable("table_name");
    } finally {
      kiji.release();
    }
View Full Code Here

    assertNotNull(kiji.getSchemaTable());
    assertNotNull(kiji.getMetaTable());

    kiji.createTable(KijiTableLayouts.getLayout(KijiTableLayouts.SIMPLE_FORMATTED_EID));

    final KijiTable table = kiji.openTable("table");
    try {

      final KijiTableWriter writer = table.openTableWriter();
      try {
        writer.put(table.getEntityId("row1"), "family", "column", 0L, "Value at timestamp 0.");
        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

      return true;
    }
    if (!getClass().equals(obj.getClass())) {
      return false;
    }
    final KijiTable other = (KijiTable) obj;

    // Equal if the two tables have the same URI:
    return mTableURI.equals(other.getURI());
  }
View Full Code Here

      return FAILURE;
    }

    final Kiji kiji = Kiji.Factory.open(argURI, getConf());
    try {
      final KijiTable table = kiji.openTable(argURI.getTable());
      try {
        final KijiTableLayout tableLayout = table.getLayout();

        final Map<FamilyLayout, List<String>> mapTypeFamilies =
            ToolUtils.getMapTypeFamilies(argURI.getColumns(), tableLayout);

        final Map<FamilyLayout, List<ColumnLayout>> groupTypeColumns =
            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

              "Deleting entire families/columns across all rows is not implemented");
        }

      } else {
        // Delete is targeting one specific row:
        final KijiTable table = kiji.openTable(mTargetURI.getTable());
        try {
          final EntityId entityId =
              ToolUtils.createEntityIdFromUserInputs(mEntityIdFlag, table.getLayout());
          return deleteFromRow(table, entityId, columns, mTimestampMode, mTimestamp);
        } finally {
          table.release();
        }
      }

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

TOP

Related Classes of org.kiji.schema.KijiTable

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.