Package org.kiji.schema

Examples of org.kiji.schema.EntityIdFactory$HashedEntityIdFactory


  }

  @Test
  public void testAllCases() throws Exception {
    for (RowKeyFormat2 rowKeyFormat : TEST_CASES) {
      EntityIdFactory factory = EntityIdFactory.getFactory(rowKeyFormat);
      List<FilterAndTestValues> filterAndTestValues =
          createFilterAndTestValues(rowKeyFormat.getComponents());
      for (FilterAndTestValues filterAndTest : filterAndTestValues) {
        FormattedEntityIdRowFilter filter =
            createFilter(rowKeyFormat, filterAndTest.mFilterValues.toArray());
View Full Code Here


  }

  @Test
  public void testPrefixNumberMatching() throws Exception {
    RowKeyFormat2 rowKeyFormat = createRowKeyFormat(1, LONG, LONG);
    EntityIdFactory factory = EntityIdFactory.getFactory(rowKeyFormat);
    FormattedEntityIdRowFilter filter = createFilter(rowKeyFormat, 4224L, null);
    runTest(rowKeyFormat, filter, factory, INCLUDE, 4224L, 5005L);
    runTest(rowKeyFormat, filter, factory, INCLUDE, 4224L, null);
    runTest(rowKeyFormat, filter, factory, INCLUDE, 4224L, Long.MAX_VALUE);
    runTest(rowKeyFormat, filter, factory, INCLUDE, 4224L, Long.MIN_VALUE);
View Full Code Here

  }

  @Test
  public void testUnicodeStringInFilterMatching() throws Exception {
    RowKeyFormat2 rowKeyFormat = createRowKeyFormat(1, STRING);
    EntityIdFactory factory = EntityIdFactory.getFactory(rowKeyFormat);
    String match = "This is a star: \u2605";
    String noMatch = "This is not a star";
    FormattedEntityIdRowFilter filter = createFilter(rowKeyFormat, match);
    runTest(rowKeyFormat, filter, factory, INCLUDE, match);
    runTest(rowKeyFormat, filter, factory, EXCLUDE, noMatch);
View Full Code Here

  }

  @Test
  public void testUnicodeStringInEntityIdMatching() throws Exception {
    RowKeyFormat2 rowKeyFormat = createRowKeyFormat(1, STRING);
    EntityIdFactory factory = EntityIdFactory.getFactory(rowKeyFormat);
    String match = "This is not a star";
    String noMatch = "This is a star: \u2605";
    FormattedEntityIdRowFilter filter = createFilter(rowKeyFormat, match);
    runTest(rowKeyFormat, filter, factory, INCLUDE, match);
    runTest(rowKeyFormat, filter, factory, EXCLUDE, noMatch);
View Full Code Here

  }

  @Test
  public void testLatinNewlineCharacterInclusion() throws Exception {
    RowKeyFormat2 rowKeyFormat = createRowKeyFormat(1, INTEGER, LONG);
    EntityIdFactory factory = EntityIdFactory.getFactory(rowKeyFormat);

    // Create and serialize a filter.
    FormattedEntityIdRowFilter filter = createFilter(rowKeyFormat, 10);
    byte[] serializedFilter = filter.toHBaseFilter(null).toByteArray();

    // Deserialize the filter.
    Filter deserializedFilter = FilterList.parseFrom(serializedFilter);

    // Filter an entity with the deserialized filter.
    EntityId entityId = factory.getEntityId(10, 10L);
    byte[] hbaseKey = entityId.getHBaseRowKey();
    boolean filtered = deserializedFilter.filterRowKey(hbaseKey, 0, hbaseKey.length);
    assertEquals(INCLUDE, filtered);
  }
View Full Code Here

            new RowKeyComponent("id", INTEGER), // this one is included in the hash
            new RowKeyComponent("ts", LONG));   // this one is not
    builder.setComponents(components);
    RowKeyFormat2 rowKeyFormat = builder.build();

    EntityIdFactory factory = EntityIdFactory.getFactory(rowKeyFormat);
    FormattedEntityIdRowFilter filter = createFilter(rowKeyFormat, 100);
    Object[] componentValues = new Object[] { Integer.valueOf(100), Long.valueOf(900000L) };
    runTest(rowKeyFormat, filter, factory, INCLUDE, componentValues);

    EntityId entityId = factory.getEntityId(componentValues);
    byte[] hbaseKey = entityId.getHBaseRowKey();
    Filter hbaseFilter = filter.toHBaseFilter(null);

    // A row key with a different hash but the same first component should be
    // excluded by the filter. The hash is 0x9f0f
View Full Code Here

  @Test
  public void testHashWildcardIsUsedForMissingHashComponents() throws Exception {
    RowKeyFormat2 rowKeyFormat = createRowKeyFormat(1, INTEGER, LONG, STRING);
    rowKeyFormat.setRangeScanStartIndex(2);
    EntityIdFactory factory = EntityIdFactory.getFactory(rowKeyFormat);

    FormattedEntityIdRowFilter filter = createFilter(rowKeyFormat, 100, null, "value");
    runTest(rowKeyFormat, filter, factory, INCLUDE, 100, 2000L, "value");
    runTest(rowKeyFormat, filter, factory, EXCLUDE, 100, null, null);
    runTest(rowKeyFormat, filter, factory, EXCLUDE, 0, null, null);
View Full Code Here

  }

  @Test
  public void testPrefixFilterHaltsFiltering() throws Exception {
    RowKeyFormat2 rowKeyFormat = createRowKeyFormat(1, INTEGER, LONG, LONG);
    EntityIdFactory factory = EntityIdFactory.getFactory(rowKeyFormat);
    FormattedEntityIdRowFilter filter = createFilter(rowKeyFormat, 100, null, 9000L);
    Filter hbaseFilter = filter.toHBaseFilter(null);

    EntityId passingEntityId = factory.getEntityId(100, 100L, 9000L);
    byte[] passingHbaseKey = passingEntityId.getHBaseRowKey();
    doInclusionAssert(rowKeyFormat, filter, passingEntityId, hbaseFilter, passingHbaseKey, INCLUDE);
    boolean filterAllRemaining = hbaseFilter.filterAllRemaining();
    String message = createFailureMessage(rowKeyFormat, filter, passingEntityId, hbaseFilter,
        passingHbaseKey, filterAllRemaining);
    assertEquals(message, false, filterAllRemaining);

    EntityId failingEntityId = factory.getEntityId(101, 100L, 9000L);
    byte[] failingHbaseKey = failingEntityId.getHBaseRowKey();
    doInclusionAssert(rowKeyFormat, filter, failingEntityId, hbaseFilter, failingHbaseKey, EXCLUDE);
    filterAllRemaining = hbaseFilter.filterAllRemaining();
    message = createFailureMessage(rowKeyFormat, filter, failingEntityId, hbaseFilter,
        failingHbaseKey, filterAllRemaining);
View Full Code Here

      assertEquals(BaseTool.SUCCESS, runTool(new ScanTool(),
              table.getURI().toString() + "info:name,info:email"
          ));
      assertEquals(30, mToolOutputLines.length);

        EntityIdFactory eif = EntityIdFactory.getFactory(layout);
        EntityId startEid = eif.getEntityId("christophe@usermail.example.com"); //second row
        EntityId limitEid = eif.getEntityId("john.doe@gmail.com"); //second to last row
        String startHbaseRowKey = Hex.encodeHexString(startEid.getHBaseRowKey());
        String limitHbaseRowKey = Hex.encodeHexString(limitEid.getHBaseRowKey());
      assertEquals(BaseTool.SUCCESS, runTool(new ScanTool(),
          table.getURI().toString() + "info:name",
          "--start-row=hbase=hex:" + startHbaseRowKey,  // start at the second row.
View Full Code Here

    }
  }

  @Test
  public void testIntForLong() throws Exception {
    final EntityIdFactory factory = EntityIdFactory.getFactory((RowKeyFormat2) mFormattedLayout
        .getDesc().getKeysFormat());
    final EntityId eid = factory.getEntityId("dummy", "str1", "str2", 5, 10);

    assertEquals(eid, ToolUtils.createEntityIdFromUserInputs("['dummy', 'str1', 'str2', 5, 10]",
        mFormattedLayout));
  }
View Full Code Here

TOP

Related Classes of org.kiji.schema.EntityIdFactory$HashedEntityIdFactory

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.