Java Code Examples for org.apache.hadoop.hbase.KeyValue.Type#Maximum

The following examples show how to use org.apache.hadoop.hbase.KeyValue.Type#Maximum . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestCellComparator.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void testCompareCells() {
  KeyValue kv1 = new KeyValue(row1, fam1, qual1, val);
  KeyValue kv2 = new KeyValue(row2, fam1, qual1, val);
  assertTrue((comparator.compare(kv1, kv2)) < 0);

  kv1 = new KeyValue(row1, fam2, qual1, val);
  kv2 = new KeyValue(row1, fam1, qual1, val);
  assertTrue((comparator.compareFamilies(kv1, kv2) > 0));

  kv1 = new KeyValue(row1, fam1, qual1, 1L, val);
  kv2 = new KeyValue(row1, fam1, qual1, 2L, val);
  assertTrue((comparator.compare(kv1, kv2) > 0));

  kv1 = new KeyValue(row1, fam1, qual1, 1L, Type.Put);
  kv2 = new KeyValue(row1, fam1, qual1, 1L, Type.Maximum);
  assertTrue((comparator.compare(kv1, kv2) > 0));

  kv1 = new KeyValue(row1, fam1, qual1, 1L, Type.Put);
  kv2 = new KeyValue(row1, fam1, qual1, 1L, Type.Put);
  assertTrue((CellUtil.equals(kv1, kv2)));
}
 
Example 2
Source File: TestCellComparator.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Test
public void testCompareCellWithKey() throws Exception {
  KeyValue kv1 = new KeyValue(row1, fam1, qual1, val);
  KeyValue kv2 = new KeyValue(row2, fam1, qual1, val);
  assertTrue(
    (PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length)) < 0);

  kv1 = new KeyValue(row1, fam2, qual1, val);
  kv2 = new KeyValue(row1, fam1, qual1, val);
  assertTrue(
    (PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length)) > 0);

  kv1 = new KeyValue(row1, fam1, qual1, 1L, val);
  kv2 = new KeyValue(row1, fam1, qual1, 2L, val);
  assertTrue(
    (PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length)) > 0);

  kv1 = new KeyValue(row1, fam1, qual1, 1L, Type.Put);
  kv2 = new KeyValue(row1, fam1, qual1, 1L, Type.Maximum);
  assertTrue(
    (PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length)) > 0);

  kv1 = new KeyValue(row1, fam1, qual1, 1L, Type.Put);
  kv2 = new KeyValue(row1, fam1, qual1, 1L, Type.Put);
  assertTrue(
    (PrivateCellUtil.compare(comparator, kv1, kv2.getKey(), 0, kv2.getKey().length)) == 0);
}
 
Example 3
Source File: TestClientKeyValueLocal.java    From phoenix with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testReadWrite() throws IOException {
  byte[] row = Bytes.toBytes("row");
  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);
}
 
Example 4
Source File: SkipScanFilter.java    From phoenix with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public KeyValue getNextKeyHint(KeyValue kv) {
    // TODO: don't allocate new key value every time here if possible
    return isDone ? null : new KeyValue(startKey, 0, startKeyLength,
            null, 0, 0, null, 0, 0, HConstants.LATEST_TIMESTAMP, Type.Maximum, null, 0, 0);
}
 
Example 5
Source File: KeyValueUtil.java    From hbase with Apache License 2.0 3 votes vote down vote up
/**
 * Create a KeyValue for the specified row, family and qualifier that would be
 * smaller than all other possible KeyValues that have the same row,
 * family, qualifier.
 * Used for seeking.
 * @param row row key
 * @param roffset row offset
 * @param rlength row length
 * @param family family name
 * @param foffset family offset
 * @param flength family length
 * @param qualifier column qualifier
 * @param qoffset qualifier offset
 * @param qlength qualifier length
 * @return First possible key on passed Row, Family, Qualifier.
 */
public static KeyValue createFirstOnRow(final byte [] row,
    final int roffset, final int rlength, final byte [] family,
    final int foffset, final int flength, final byte [] qualifier,
    final int qoffset, final int qlength) {
  return new KeyValue(row, roffset, rlength, family,
      foffset, flength, qualifier, qoffset, qlength,
      HConstants.LATEST_TIMESTAMP, Type.Maximum, null, 0, 0);
}
 
Example 6
Source File: KeyValueUtil.java    From hbase with Apache License 2.0 2 votes vote down vote up
/**
 * Create a KeyValue that is smaller than all other possible KeyValues
 * for the given row. That is any (valid) KeyValue on 'row' would sort
 * _after_ the result.
 *
 * @param row - row key (arbitrary byte array)
 * @return First possible KeyValue on passed <code>row</code>
 */
public static KeyValue createFirstOnRow(final byte [] row, int roffset, short rlength) {
  return new KeyValue(row, roffset, rlength,
      null, 0, 0, null, 0, 0, HConstants.LATEST_TIMESTAMP, Type.Maximum, null, 0, 0);
}
 
Example 7
Source File: KeyValueUtil.java    From hbase with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a KeyValue that is smaller than all other KeyValues that
 * are older than the passed timestamp.
 * @param row - row key (arbitrary byte array)
 * @param ts - timestamp
 * @return First possible key on passed <code>row</code> and timestamp.
 */
public static KeyValue createFirstOnRow(final byte [] row,
    final long ts) {
  return new KeyValue(row, null, null, ts, Type.Maximum);
}
 
Example 8
Source File: KeyValueUtil.java    From hbase with Apache License 2.0 2 votes vote down vote up
/**
 * Create a KeyValue for the specified row, family and qualifier that would be
 * smaller than all other possible KeyValues that have the same row,family,qualifier.
 * Used for seeking.
 * @param row - row key (arbitrary byte array)
 * @param family - family name
 * @param qualifier - column qualifier
 * @return First possible key on passed <code>row</code>, and column.
 */
public static KeyValue createFirstOnRow(final byte [] row, final byte [] family,
    final byte [] qualifier) {
  return new KeyValue(row, family, qualifier, HConstants.LATEST_TIMESTAMP, Type.Maximum);
}
 
Example 9
Source File: KeyValueUtil.java    From hbase with Apache License 2.0 2 votes vote down vote up
/**
 * @param row - row key (arbitrary byte array)
 * @param f - family name
 * @param q - column qualifier
 * @param ts - timestamp
 * @return First possible key on passed <code>row</code>, column and timestamp
 */
public static KeyValue createFirstOnRow(final byte [] row, final byte [] f,
    final byte [] q, final long ts) {
  return new KeyValue(row, f, q, ts, Type.Maximum);
}