Package org.kiji.schema

Examples of org.kiji.schema.EntityId


  @Test
  public void testHBaseEIDtoHashPrefixedEID() throws Exception {
    final EntityIdFactory factory =
      EntityIdFactory.getFactory((RowKeyFormat) mHashPrefixedLayout.getDesc().getKeysFormat());
    final EntityId hpeid = factory.getEntityId("hashPrefixedEID");
    final EntityId hbeid = HBaseEntityId.fromHBaseRowKey(hpeid.getHBaseRowKey());

    assertEquals(hpeid,
        ToolUtils.createEntityIdFromUserInputs(hbeid.toShellString(), mHashPrefixedLayout));
  }
View Full Code Here


  @Test
  public void testHBaseEIDtoFormattedEID() throws Exception {
    final EntityIdFactory factory =
        EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout.getDesc().getKeysFormat());
    final EntityId feid = factory.getEntityId("dummy", "str1", "str2", 5, 10);
    final EntityId hbeid = HBaseEntityId.fromHBaseRowKey(feid.getHBaseRowKey());

    assertEquals(feid,
        ToolUtils.createEntityIdFromUserInputs(hbeid.toShellString(), mFormattedLayout));
  }
View Full Code Here

    final TableLayoutDesc desc =
        KijiTableLayouts.getLayout(KijiTableLayouts.COUNTER_TEST);
    final KijiTableLayout layout = KijiTableLayout.newLayout(desc);
    final EntityIdFactory factory = EntityIdFactory.getFactory(layout);
    final byte[] rowKey = Bytes.toBytes(UNUSUAL_STRING_EID);
    final EntityId originalEid = factory.getEntityIdFromHBaseRowKey(rowKey);
    final JsonEntityIdParser restEid1 = JsonEntityIdParser.create(originalEid, layout);
    final JsonEntityIdParser restEid2 = JsonEntityIdParser.create(
        String.format("hbase=%s", Bytes.toStringBinary(rowKey)), layout);
    final JsonEntityIdParser restEid3 = JsonEntityIdParser.create(
        String.format("hbase_hex=%s", new String(Hex.encodeHex((rowKey)))), layout);
View Full Code Here

    final KijiTableLayout layout = KijiTableLayout.newLayout(desc);
    final EntityIdFactory factory = EntityIdFactory.getFactory(layout);

    // Byte array representations of row keys should work.
    final byte[] rowKey = Bytes.toBytes(UNUSUAL_STRING_EID);
    final EntityId originalEid = factory.getEntityIdFromHBaseRowKey(rowKey);
    final JsonEntityIdParser restEid1 = JsonEntityIdParser.create(originalEid, layout);
    final JsonEntityIdParser restEid2 = JsonEntityIdParser.create(
        String.format("hbase=%s", Bytes.toStringBinary(rowKey)), layout);
    final JsonEntityIdParser restEid3 = JsonEntityIdParser.create(
        String.format("hbase_hex=%s", new String(Hex.encodeHex((rowKey)))), layout);

    // Resolved entity id should match origin entity id.
    assertEquals(originalEid, restEid1.getEntityId());
    assertEquals(originalEid, restEid2.getEntityId());
    assertEquals(originalEid, restEid3.getEntityId());

    // Component representation of entities should work.
    final JsonEntityIdParser restEid4 = JsonEntityIdParser.create(SINGLE_COMPONENT_EID, layout);
    final EntityId resolvedEid = restEid4.getEntityId();
    final String recoveredComponent = Bytes.toString(
        Bytes.toBytesBinary(
            resolvedEid.toShellString().substring(
                ToolUtils.KIJI_ROW_KEY_SPEC_PREFIX.length())));
    assertEquals(UNUSUAL_STRING_EID, recoveredComponent);
    assertEquals(resolvedEid, restEid4.getEntityId());
  }
View Full Code Here

    final byte[] rowKey = Bytes.toBytes(UNUSUAL_STRING_EID);
    final byte[] hash = Hasher.hash(Bytes.toBytes(UNUSUAL_STRING_EID));
    final byte[] hbaseRowKey = new byte[rowKey.length + 2];
    System.arraycopy(hash, 0, hbaseRowKey, 0, 2);
    System.arraycopy(rowKey, 0, hbaseRowKey, 2, rowKey.length);
    final EntityId originalEid = factory.getEntityIdFromHBaseRowKey(hbaseRowKey);
    final JsonEntityIdParser restEid1 = JsonEntityIdParser.create(originalEid, layout);
    final JsonEntityIdParser restEid2 = JsonEntityIdParser.create(
        String.format("hbase=%s", Bytes.toStringBinary(hbaseRowKey)), layout);
    final JsonEntityIdParser restEid3 = JsonEntityIdParser.create(
        String.format("hbase_hex=%s", new String(Hex.encodeHex((hbaseRowKey)))), layout);

    // Resolved entity id should match origin entity id.
    assertEquals(originalEid, restEid1.getEntityId());
    assertEquals(originalEid, restEid2.getEntityId());
    assertEquals(originalEid, restEid3.getEntityId());

    // Component representation of entities should work.
    final JsonEntityIdParser restEid4 = JsonEntityIdParser.create(SINGLE_COMPONENT_EID, layout);
    final EntityId resolvedEid = restEid4.getEntityId();
    final String recoveredComponent = Bytes.toString(
        Bytes.toBytesBinary(
            resolvedEid.toShellString().substring(
                ToolUtils.KIJI_ROW_KEY_SPEC_PREFIX.length())));
    assertEquals(UNUSUAL_STRING_EID, recoveredComponent);
    assertEquals(resolvedEid, restEid4.getEntityId());
  }
View Full Code Here

    final TableLayoutDesc desc =
        KijiTableLayouts.getLayout(KijiTableLayouts.PAGING_TEST);
    final KijiTableLayout layout = KijiTableLayout.newLayout(desc);
    final EntityIdFactory factory = EntityIdFactory.getFactory(layout);
    final byte[] rowKey = Bytes.toBytes(UNUSUAL_STRING_EID);
    final EntityId originalEid = factory.getEntityIdFromHBaseRowKey(rowKey);
    final JsonEntityIdParser restEid1 = JsonEntityIdParser.create(originalEid, layout);
    final JsonEntityIdParser restEid2 = JsonEntityIdParser.create(
        String.format("hbase=%s", Bytes.toStringBinary(rowKey)), layout);
    final JsonEntityIdParser restEid3 = JsonEntityIdParser.create(
        String.format("hbase_hex=%s", new String(Hex.encodeHex((rowKey)))), layout);
View Full Code Here

        JSONObject.quote(UNUSUAL_STRING_EID),
        JSONObject.quote(UNUSUAL_STRING_EID),
        JSONObject.quote(UNUSUAL_STRING_EID),
        Integer.MIN_VALUE,
        Long.MAX_VALUE);
    final EntityId originalEid = ToolUtils.createEntityIdFromUserInputs(eidString, layout);
    final JsonEntityIdParser restEid1 = JsonEntityIdParser.create(originalEid, layout);
    final JsonEntityIdParser restEid2 = JsonEntityIdParser.create(eidString, layout);
    final JsonEntityIdParser restEid3 = JsonEntityIdParser.create(
        String.format("hbase_hex=%s",
            new String(Hex.encodeHex((originalEid.getHBaseRowKey())))), layout);
    final JsonEntityIdParser restEid4 = JsonEntityIdParser.create(
        String.format("hbase=%s", Bytes.toStringBinary(originalEid.getHBaseRowKey()))
        , layout);

    // Resolved entity id should match origin entity id.
    assertEquals(originalEid, restEid1.getEntityId());
    assertEquals(originalEid, restEid2.getEntityId());
View Full Code Here

        JSONObject.quote(UNUSUAL_STRING_EID),
        JSONObject.quote(UNUSUAL_STRING_EID),
        JSONObject.quote(UNUSUAL_STRING_EID),
        Integer.MIN_VALUE,
        Long.MAX_VALUE);
    final EntityId originalEid = ToolUtils.createEntityIdFromUserInputs(eidString, layout);
    final JsonEntityIdParser restEid1 = JsonEntityIdParser.create(originalEid, layout);
    final JsonEntityIdParser restEid2 = JsonEntityIdParser.create(eidString, layout);
    final JsonEntityIdParser restEid3 = JsonEntityIdParser.create(
        String.format("hbase_hex=%s",
            new String(Hex.encodeHex((originalEid.getHBaseRowKey())))), layout);
    final JsonEntityIdParser restEid4 = JsonEntityIdParser.create(
        String.format("hbase=%s", Bytes.toStringBinary(originalEid.getHBaseRowKey())), layout);
    final EntityId toolUtilsEid = ToolUtils.createEntityIdFromUserInputs(eidString, layout);

    // Resolved entity id should match origin entity id.
    assertEquals(originalEid, restEid1.getEntityId());
    assertEquals(originalEid, restEid2.getEntityId());
    assertEquals(originalEid, restEid3.getEntityId());
View Full Code Here

    final KijiTable table = kiji.openTable(layout.getName());
    try {
      assertEquals(BaseTool.SUCCESS, runTool(new GetTool(), table.getURI().toString(),
          "--entity-id=[\"jane.doe@gmail.com\"]"));
      assertEquals(5, mToolOutputLines.length);
      EntityId eid = EntityIdFactory.getFactory(layout).getEntityId("gwu@usermail.example.com");
      String hbaseRowKey = Hex.encodeHexString(eid.getHBaseRowKey());
      assertEquals(BaseTool.SUCCESS, runTool(new GetTool(),
          table.getURI() + "info:name",
              "--entity-id=hbase=hex:" + hbaseRowKey
          ));
      assertEquals(3, mToolOutputLines.length);
View Full Code Here

      // Prefetch the next row for hasNext():
      mNextResult = getNextResult();

      // Decode the HBase result into a KijiRowData:
      try {
        final EntityId entityId = mEntityIdFactory.getEntityIdFromHBaseRowKey(result.getRow());
        return new HBaseKijiRowData(mTable, mDataRequest, entityId, result, mCellDecoderProvider);
      } catch (IOException ioe) {
        throw new KijiIOException(ioe);
      }
    }
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.