Package org.kiji.schema.avro

Examples of org.kiji.schema.avro.HashSpec


    final RowKeyFormat2 format = makeDefaultSaltRowKeyFormat();

    // Test that the salt field is populated with the default value we expect. It's an incompatible
    // change if this ever changes. In effect, the next few asserts test that the Avro IDL is not
    // incompatibly changed.
    HashSpec spec = format.getSalt();
    assertNotNull("Didn't get a default HashSpec, got null!", spec);
    assertEquals("Default hash spec doesn't have the well-defined default size",
        2, (int) spec.getHashSize());
    assertEquals("Default hash spec doesn't have the well-defined default algorithm",
        HashType.MD5, spec.getHashType());
    assertFalse("Default hash spec should have suppressKeyMaterialization false",
        spec.getSuppressKeyMaterialization());

    // And test that FormattedEntityId itself no longer has theNPE.
    final FormattedEntityId formattedEntityId = makeId(format, "one", 1, 7L);
    byte[] hbaseRowKey = formattedEntityId.getHBaseRowKey();
View Full Code Here


  private static RowKeyFormat2 createRowKeyFormat(int hashLength, ComponentType... componentTypes) {
    RowKeyFormat2.Builder builder = RowKeyFormat2.newBuilder()
        .setEncoding(RowKeyEncoding.FORMATTED);
    if (hashLength > 0) {
      builder.setSalt(new HashSpec(HashType.MD5, hashLength, false));
    }
    List<RowKeyComponent> components = Lists.newArrayList();
    char field = 'a';
    for (ComponentType componentType : componentTypes) {
      components.add(new RowKeyComponent(String.valueOf(field), componentType));
View Full Code Here

  @Test
  public void testHashIsCalculatedWhenAllHashComponentsAreSpecified() throws Exception {
    final int hashLength = 2;
    RowKeyFormat2.Builder builder = RowKeyFormat2.newBuilder()
        .setEncoding(RowKeyEncoding.FORMATTED)
        .setSalt(new HashSpec(HashType.MD5, hashLength, false))
        .setRangeScanStartIndex(1);

    List<RowKeyComponent> components = ImmutableList.of(
            new RowKeyComponent("id", INTEGER), // this one is included in the hash
            new RowKeyComponent("ts", LONG));   // this one is not
View Full Code Here

  @Test
  public void testFormattedEntityIdRowFilter() throws Exception {
    runTest(new FormattedEntityIdRowFilter(
        RowKeyFormat2.newBuilder()
            .setEncoding(RowKeyEncoding.FORMATTED)
            .setSalt(new HashSpec(HashType.MD5, 1, false))
            .setComponents(ImmutableList.of(
                new RowKeyComponent("a", ComponentType.INTEGER),
                new RowKeyComponent("b", ComponentType.LONG),
                new RowKeyComponent("c", ComponentType.STRING)))
            .build(),
View Full Code Here

    // components of the row key
    ArrayList<RowKeyComponent> components = new ArrayList<RowKeyComponent>();
    components.add(RowKeyComponent.newBuilder()
        .setName("NAME").setType(ComponentType.STRING).build());

    HashSpec hs = HashSpec.newBuilder()
        .setHashSize(20).build();

    // build the row key format
    RowKeyFormat2 format = RowKeyFormat2.newBuilder().setEncoding(RowKeyEncoding.FORMATTED)
        .setSalt(hs)
View Full Code Here

    Object keysFormatRaw = descOut.getKeysFormat();
    assertNotNull("Unexpected null RowKeyFormat2 field", keysFormatRaw);
    assertTrue("keys_format should be an RKF2", keysFormatRaw instanceof RowKeyFormat2);

    RowKeyFormat2 rkf2 = (RowKeyFormat2) keysFormatRaw;
    HashSpec salt = rkf2.getSalt();
    assertNotNull("Expected non-null salt", salt);

    // Test that the null salt element specified above is replaced with the default
    // values we specified.
    assertEquals(2, (int) salt.getHashSize());
    assertFalse(salt.getSuppressKeyMaterialization());
    assertEquals(HashType.MD5, salt.getHashType());
  }
View Full Code Here

      return new JsonEntityIdParser(
          false,
          layout,
          Bytes.toString((byte[]) entityId.getComponentByIndex(0)));
    case FORMATTED:
      final HashSpec hashSpec = ((RowKeyFormat2) keysFormat).getSalt();
      if (hashSpec.getSuppressKeyMaterialization()) {
        return new JsonEntityIdParser(
            String.format("hbase=%s", Bytes.toStringBinary(entityId.getHBaseRowKey())),
            layout);
      } else {
        return new JsonEntityIdParser(false, layout, entityId.getComponents());
View Full Code Here

TOP

Related Classes of org.kiji.schema.avro.HashSpec

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.