Package org.kiji.schema

Examples of org.kiji.schema.EntityIdFactory


  @Test
  public void testShouldWorkWithRKFRawLayout() throws Exception {
    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


  @Test
  public void testShouldWorkWithRKFHashedLayout() throws Exception {
    final TableLayoutDesc desc =
        KijiTableLayouts.getLayout(KijiTableLayouts.FOODS);
    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);
View Full Code Here

  @Test
  public void testShouldWorkWithRKFHashPrefixedLayout() throws Exception {
    final TableLayoutDesc desc =
        KijiTableLayouts.getLayout(KijiTableLayouts.HASH_PREFIXED_RKF);
    final KijiTableLayout layout = KijiTableLayout.newLayout(desc);
    final EntityIdFactory factory = EntityIdFactory.getFactory(layout);

    // Byte array representations of row keys should work.
    // Prepend appropriate hashed prefix to UNUSUAL_STRING_EID.
    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);
View Full Code Here

  @Test
  public void testShouldWorkWithRKF2RawLayout() throws Exception {
    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

        throw new IllegalArgumentException(
            "Entity id must be fully specified for resolution, i.e. without wildcards.");
      }
      return EntityIdFactory.getFactory(mLayout).getEntityId(mComponents);
    } else {
      final EntityIdFactory factory = EntityIdFactory.getFactory(mLayout);
      return factory.getEntityIdFromHBaseRowKey(parseBytes(getStringEntityId()));
    }
  }
View Full Code Here

   */
  public static EntityId createEntityIdFromUserInputs(String entityFlag, KijiTableLayout layout)
      throws IOException {
    Preconditions.checkNotNull(entityFlag);

    final EntityIdFactory factory = EntityIdFactory.getFactory(layout);

    if (entityFlag.startsWith(HBASE_ROW_KEY_SPEC_PREFIX)) {
      // HBase row key specification
      final String hbaseSpec = entityFlag.substring(HBASE_ROW_KEY_SPEC_PREFIX.length());
      final byte[] hbaseRowKey = parseBytesFlag(hbaseSpec);
      return factory.getEntityIdFromHBaseRowKey(hbaseRowKey);

    } else {
      // Kiji row key specification
      final String kijiSpec = entityFlag.startsWith(KIJI_ROW_KEY_SPEC_PREFIX)
          ? entityFlag.substring(KIJI_ROW_KEY_SPEC_PREFIX.length())
View Full Code Here

TOP

Related Classes of org.kiji.schema.EntityIdFactory

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.