Examples of EntityIdFactory


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

Examples of org.kiji.schema.EntityIdFactory

  @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

Examples of org.kiji.schema.EntityIdFactory

  @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

Examples of org.kiji.schema.EntityIdFactory

  @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

Examples of org.kiji.schema.EntityIdFactory

        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

Examples of org.kiji.schema.EntityIdFactory

   */
  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

Examples of org.sonatype.nexus.component.services.id.EntityIdFactory

public class DefaultEntityIdFactoryTest
{
  @Test
  public void restoredIdsAreEqual() {
    final EntityIdFactory factory = new DefaultEntityIdFactory();

    final EntityId id = factory.newId();

    final EntityId restored = new EntityId(id.asUniqueString());

    assertThat(id, is(equalTo(restored)));
  }
View Full Code Here

Examples of org.sonatype.nexus.component.services.id.EntityIdFactory

    assertThat(id, is(equalTo(restored)));
  }

  @Test
  public void subsequentIdsAreNotEqual() {
    final EntityIdFactory factor = new DefaultEntityIdFactory();

    Set<EntityId> ids = Sets.newHashSet();

    final int NUMBER_OF_IDS = 100;

    for (int i = 0; i < NUMBER_OF_IDS; i++) {
      ids.add(factor.newId());
    }

    assertThat(ids.size(), is(equalTo(NUMBER_OF_IDS)));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.