Package com.salesforce.phoenix.client

Examples of com.salesforce.phoenix.client.ClientKeyValue


    byte[] family = Bytes.toBytes("family");
    byte[] qualifier = Bytes.toBytes("qualifier");
    byte[] value = Bytes.toBytes("value");
    long ts = 10;
    Type type = KeyValue.Type.Put;
    ClientKeyValue kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type,
        wrap(value));
    validate(kv, row, family, qualifier, ts, type, value);

    type = Type.Delete;
    kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value));
    validate(kv, row, family, qualifier, ts, type, value);

    type = Type.DeleteColumn;
    kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value));
    validate(kv, row, family, qualifier, ts, type, value);

    type = Type.DeleteFamily;
    kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value));
    validate(kv, row, family, qualifier, ts, type, value);

    type = Type.Maximum;
    kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value));
    validate(kv, row, family, qualifier, ts, type, value);

    // test a couple different variables, to make sure we aren't faking it
    row = Bytes.toBytes("row-never-seen-before1234");
    family = Bytes.toBytes("family-to-test-more");
    qualifier = Bytes.toBytes("untested-qualifier");
    value = Bytes.toBytes("value-that-we-haven't_tested");
    ts = System.currentTimeMillis();
    kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value));
    validate(kv, row, family, qualifier, ts, type, value);
  }
View Full Code Here


    byte[] qualifier = Bytes.toBytes("qualifier");
    long ts = 10;
    Type type = KeyValue.Type.Put;
    byte[] empty = new byte[0];
    // values can be null
    ClientKeyValue kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, null);
    validate(kv, row, family, qualifier, ts, type, empty);
    kv = new ClientKeyValue(row, family, qualifier, ts, type, null);
    validate(kv, row, family, qualifier, ts, type, empty);
    kv = new ClientKeyValue(row, family, qualifier, ts, type);
    validate(kv, row, family, qualifier, ts, type, empty);

    // qualifiers can also be null and have null values
    kv = new ClientKeyValue(wrap(row), wrap(family), null, ts, type, null);
    validate(kv, row, family, empty, ts, type, empty);
    kv = new ClientKeyValue(row, family, null, ts, type, null);
    validate(kv, row, family, empty, ts, type, empty);
    kv = new ClientKeyValue(row, family, null, ts, type);
    validate(kv, row, family, empty, ts, type, empty);
    // and also have values
    byte[] value = Bytes.toBytes("value");
    kv = new ClientKeyValue(wrap(row), wrap(family), null, ts, type, wrap(value));
    validate(kv, row, family, empty, ts, type, value);
    kv = new ClientKeyValue(row, family, null, ts, type, value);
    validate(kv, row, family, empty, ts, type, value);

    // families can also be null
    kv = new ClientKeyValue(wrap(row), null, null, ts, type, null);
    validate(kv, row, empty, empty, ts, type, empty);
    kv = new ClientKeyValue(row, null, null, ts, type, null);
    validate(kv, row, empty, empty, ts, type, empty);
    kv = new ClientKeyValue(row, null, null, ts, type);
    validate(kv, row, empty, empty, ts, type, empty);
    // but we could have a qualifier
    kv = new ClientKeyValue(wrap(row), null, wrap(qualifier), ts, type, null);
    validate(kv, row, empty, qualifier, ts, type, empty);
    kv = new ClientKeyValue(row, null, qualifier, ts, type, null);
    validate(kv, row, empty, qualifier, ts, type, empty);
    kv = new ClientKeyValue(row, null, qualifier, ts, type);
    validate(kv, row,  empty, qualifier, ts, type, empty);
    // or a real value
    kv = new ClientKeyValue(wrap(row), null, wrap(qualifier), ts, type, wrap(value));
    validate(kv, row, empty, qualifier, ts, type, value);
    kv = new ClientKeyValue(row, null, qualifier, ts, type, value);
    validate(kv, row, empty, qualifier, ts, type, value);
  }
View Full Code Here

    byte [] family1 = Bytes.toBytes("abc");
    byte [] qualifier1 = Bytes.toBytes("def");
    byte [] family2 = Bytes.toBytes("abcd");
    byte [] qualifier2 = Bytes.toBytes("ef");

    KeyValue aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.Put, a);
    assertFalse(aaa.matchingColumn(family2, qualifier2));
    assertTrue(aaa.matchingColumn(family1, qualifier1));
    aaa = new ClientKeyValue(a, family2, qualifier2, 0L, Type.Put, a);
    assertFalse(aaa.matchingColumn(family1, qualifier1));
    assertTrue(aaa.matchingColumn(family2,qualifier2));
    byte [] nullQualifier = new byte[0];
    aaa = new ClientKeyValue(a, family1, nullQualifier, 0L, Type.Put, a);
    assertTrue(aaa.matchingColumn(family1,null));
    assertFalse(aaa.matchingColumn(family2,qualifier2));
  }
View Full Code Here

    byte[] family1 = Bytes.toBytes("abc");
    byte[] qualifier1 = Bytes.toBytes("def");
    byte[] family2 = Bytes.toBytes("ab");
    byte[] qualifier2 = Bytes.toBytes("def");

    KeyValue aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.Put, a);
    assertFalse(aaa.matchingColumn(family2, qualifier2));
  }
View Full Code Here

    final byte[] a = Bytes.toBytes("aaa");
    byte[] family1 = Bytes.toBytes("abc");
    byte[] qualifier1 = Bytes.toBytes("def");

    // works fine - matching row
    KeyValue aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.Put, a);
    Put p = new Put(a);
    p.add(aaa);

    // fails, not a matching row
    try {
      aaa = new ClientKeyValue(family1, family1, qualifier1, 0L, Type.Put, a);
      p.add(aaa);
      fail("Shouldn't have been able to add  a KV with a row mismatch");
    } catch (IOException e) {
      // noop - as expected
    }
View Full Code Here

  public void testUsableWithDelete() throws Exception {
    final byte[] a = Bytes.toBytes("aaa");
    byte[] family1 = Bytes.toBytes("abc");
    byte[] qualifier1 = Bytes.toBytes("def");

    KeyValue aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.Delete, a);
    Delete d = new Delete(a);
    // simple cases should work fine
    d.addDeleteMarker(aaa);
    aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.DeleteColumn, a);
    d.addDeleteMarker(aaa);
    aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.DeleteFamily, a);
    d.addDeleteMarker(aaa);

    // fails, not a matching row
    try {
      aaa = new ClientKeyValue(family1, family1, qualifier1, 0L, Type.DeleteFamily, a);
      d.addDeleteMarker(aaa);
      fail("Shouldn't have been able to add  a KV with a row mismatch");
    } catch (IOException e) {
      // noop - as expected
    }

    aaa = new ClientKeyValue(a, family1, qualifier1, 0L, Type.Put, a);
    try {
      d.addDeleteMarker(aaa);
      fail("Shouldn't have been able to add a KV of type Put");
    } catch (IOException e) {
      // noop
View Full Code Here

TOP

Related Classes of com.salesforce.phoenix.client.ClientKeyValue

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.