Package org.kiji.schema

Examples of org.kiji.schema.EntityId


  protected int run(List<String> nonFlagArgs) throws Exception {
    final KijiColumnName column = mColumnURI.getColumns().get(0);
    final KijiTableLayout layout = mTable.getLayout();
    final CellSchema cellSchema = layout.getCellSchema(column);

    final EntityId entityId =
        ToolUtils.createEntityIdFromUserInputs(mEntityId, layout);

    final KijiTableWriter writer = mTable.openTableWriter();
    try {
      if (cellSchema.getType() == SchemaType.COUNTER) {
View Full Code Here


    builder.newColumnsDef().withMaxVersions(1).add("info", "name");
    builder.newColumnsDef().withMaxVersions(2).addFamily("purchases");
    builder.withTimeRange(1L, 3L);
    KijiDataRequest request = builder.build();

    EntityId entityId = mEntityIdFactory.getEntityId("entity");
    Get expectedGet = new Get(entityId.getHBaseRowKey());
    HBaseColumnName hbaseColumn = mColumnNameTranslator.toHBaseColumnName(
        KijiColumnName.create("info:name"));
    expectedGet.addColumn(hbaseColumn.getFamily(), hbaseColumn.getQualifier());
    HBaseColumnName hPurchasesColumn = mColumnNameTranslator.toHBaseColumnName(
        KijiColumnName.create("purchases"));
View Full Code Here

  public void testViewGet(
      final KijiDataRequest request,
      final Iterable<? extends Entry<Long, ?>> expected
  ) throws Exception {
    final EntityId eid = mTable.getEntityId(ROW);
    final KijiResult<Object> view = mReader.getResult(eid, request);
    try {
      testViewGet(view, expected);
    } finally {
      view.close();
View Full Code Here

    KijiDataRequestBuilder builder = KijiDataRequest.builder().addColumns(ColumnsDef.create()
        .withMaxVersions(10)
        .add(PRIMITIVE_STRING, null)
            .add(STRING_MAP_1, null));
    KijiDataRequest request = builder.build();
    final EntityId eid = mTable.getEntityId(ROW);
    KijiResult<Object> view = mReader.getResult(eid, request);
    SortedMap<KijiColumnName, List<KijiCell<Object>>> map =
        KijiResult.Helpers.getMaterializedContents(view);
    for (KijiColumnName col: map.keySet()) {
      KijiResult<Object> newResult = view.narrowView(col);
View Full Code Here

  @Test
  public void testRowScannerWithTokenRanges() throws Exception {
    final KijiTable table = mKiji.openTable("users");
    try {
      // Reuse these entity IDs for puts and for gets.
      final EntityId alice = table.getEntityId("Alice2");
      final EntityId bob = table.getEntityId("Bob2");
      final EntityId cathy = table.getEntityId("Cathy2");
      final EntityId david = table.getEntityId("David2");

      final String pets = "pets";
      final String cat = "cat";
      final String dog = "dog";
      final String rabbit = "rabbit";
View Full Code Here

    // There is a small enough amount of data that we can just put all of the rows into a hash
    // from entity ID to row data.
    HashMap<EntityId, KijiRowData> allData = new HashMap<EntityId, KijiRowData>();

    for (KijiRowData row : scanner) {
      EntityId eid = row.getEntityId();
      assert (!allData.containsKey(eid));
      allData.put(eid, row);
    }

    assertTrue(allData.containsKey(alice));
View Full Code Here

  public void testRowScannerSparseData() throws Exception {
    final KijiTable table = mKiji.openTable("users");
    try {

      // Reuse these entity IDs for puts and for gets.
      final EntityId alice = table.getEntityId("Alice");
      final EntityId bob = table.getEntityId("Bob");
      final EntityId cathy = table.getEntityId("Cathy");
      final EntityId david = table.getEntityId("David");

      final String pets = "pets";
      final String cat = "cat";
      final String dog = "dog";
      final String rabbit = "rabbit";
      final String fish = "fish";
      final String bird = "bird";

      final KijiTableWriter writer = table.openTableWriter();
      try {
        // Insert some data into the table.  Give various users different pets.
        writer.put(alice, pets, cat, 0L, "Alister");
        writer.put(bob, pets, cat, 0L, "Buffy");
        writer.put(cathy, pets, cat, 0L, "Mr Cat");
        writer.put(david, pets, cat, 0L, "Dash");

        writer.put(alice, pets, dog, 0L, "Amour");
        writer.put(bob, pets, rabbit, 0L, "Bounce");
        writer.put(cathy, pets, fish, 0L, "Catfish");
        writer.put(david, pets, bird, 0L, "Da Bird");
      } finally {
        writer.close();
      }

      final KijiDataRequest dataRequest = KijiDataRequest.builder()
          .addColumns(
              ColumnsDef
                  .create()
                  .withMaxVersions(100)
                  .add(pets, cat)
                  .add(pets, dog)
                  .add(pets, rabbit)
                  .add(pets, fish)
                  .add(pets, bird)
          ).build();

      final KijiTableReader reader = table.openTableReader();
      try {
        // Fire up a row scanner!
        final KijiRowScanner scanner = reader.getScanner(dataRequest);
        try {
          // There is a small enough amount of data that we can just put all of the rows into a hash
          // from entity ID to row data.
          HashMap<EntityId, KijiRowData> allData = new HashMap<EntityId, KijiRowData>();

          for (KijiRowData row : scanner) {
            EntityId eid = row.getEntityId();
            assert (!allData.containsKey(eid));
            allData.put(eid, row);
          }

          assertTrue(allData.containsKey(alice));
View Full Code Here

  public void testBulkGet() throws Exception {
    // Write data for a bunch of rows.
    final int numRows = 10;
    ArrayList<EntityId> entityIds = new ArrayList<EntityId>();
    for (int rowNum = 0; rowNum < numRows; rowNum++) {
      EntityId eid = mTable.getEntityId("row#" + rowNum);
      mWriter.put(eid, "family", "column", "This is row " + rowNum + ".");
      entityIds.add(eid);
    }

    KijiDataRequest request = KijiDataRequest.create("family", "column");

    List<KijiRowData> dataList = mReader.bulkGet(entityIds, request);

    assertEquals(numRows, dataList.size());

    for (int rowNum = 0; rowNum < numRows; rowNum++) {
      KijiRowData data = dataList.get(rowNum);
      EntityId eid = mTable.getEntityId("row#" + rowNum);
      assertEquals(eid, data.getEntityId());
      assertEquals(
          "This is row " + rowNum + ".",
          data.getMostRecentValue("family", "column").toString()
      );
View Full Code Here

    final State state = mState.get();
    Preconditions.checkState(state == State.OPEN,
        "Cannot get scanner from KijiTableReader instance %s in state %s.", this, state);

    try {
      EntityId startRow = kijiScannerOptions.getStartRow();
      EntityId stopRow = kijiScannerOptions.getStopRow();
      KijiRowFilter rowFilter = kijiScannerOptions.getKijiRowFilter();
      HBaseScanOptions scanOptions = kijiScannerOptions.getHBaseScanOptions();

      final ReaderLayoutCapsule capsule = mReaderLayoutCapsule;
      final HBaseDataRequestAdapter dataRequestAdapter =
          new HBaseDataRequestAdapter(dataRequest, capsule.getColumnNameTranslator());
      final KijiTableLayout tableLayout = capsule.getLayout();
      validateRequestAgainstLayout(dataRequest, tableLayout);
      final Scan scan = dataRequestAdapter.toScan(tableLayout, scanOptions);

      if (null != startRow) {
        scan.setStartRow(startRow.getHBaseRowKey());
      }
      if (null != stopRow) {
        scan.setStopRow(stopRow.getHBaseRowKey());
      }
      scan.setCaching(kijiScannerOptions.getRowCaching());

      if (null != rowFilter) {
        final KijiRowFilterApplicator applicator = KijiRowFilterApplicator.create(
View Full Code Here

  ) throws IOException {
    List<KijiRowData> rowDataList = new ArrayList<KijiRowData>(results.length);

    for (int i = 0; i < results.length; i++) {
      Result result = results[i];
      EntityId entityId = entityIds.get(i);

      final HBaseKijiRowData rowData = (null == result)
          ? null
          : new HBaseKijiRowData(mTable, dataRequest, entityId, result,
                mReaderLayoutCapsule.getCellDecoderProvider());
View Full Code Here

TOP

Related Classes of org.kiji.schema.EntityId

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.