Java Code Examples for org.apache.hadoop.hbase.KeyValue.Type#equals()

The following examples show how to use org.apache.hadoop.hbase.KeyValue.Type#equals() . 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: CoveredColumnIndexer.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public Collection<Pair<Mutation, byte[]>> getIndexUpdateForFilteredRows(
    Collection<KeyValue> filtered) throws IOException {

  // stores all the return values
  IndexUpdateManager updateMap = new IndexUpdateManager();
  // batch the updates by row to make life easier and ordered
  Collection<Batch> batches = batchByRow(filtered);

  for (Batch batch : batches) {
    KeyValue curKV = batch.getKvs().iterator().next();
    Put p = new Put(curKV.getRowArray(), curKV.getRowOffset(), curKV.getRowLength());
    for (KeyValue kv : batch.getKvs()) {
      // we only need to cleanup Put entries
      byte type = kv.getTypeByte();
      Type t = KeyValue.Type.codeToType(type);
      if (!t.equals(Type.Put)) {
        continue;
      }

      // add the kv independently
      p.add(kv);
    }

    // do the usual thing as for deletes
    Collection<Batch> timeBatch = createTimestampBatchesFromMutation(p);
    LocalTableState state = new LocalTableState(env, localTable, p);
    for (Batch entry : timeBatch) {
      //just set the timestamp on the table - it already has all the future state
      state.setCurrentTimestamp(entry.getTimestamp());
      this.addDeleteUpdatesToMap(updateMap, state, entry.getTimestamp());
    }
  }
  return updateMap.toMap();
}
 
Example 2
Source File: CoveredColumnIndexer.java    From phoenix with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Collection<Pair<Mutation, byte[]>> getIndexUpdateForFilteredRows(
    Collection<KeyValue> filtered) throws IOException {

  // stores all the return values
  IndexUpdateManager updateMap = new IndexUpdateManager();
  // batch the updates by row to make life easier and ordered
  Collection<Batch> batches = batchByRow(filtered);

  for (Batch batch : batches) {
    Put p = new Put(batch.getKvs().iterator().next().getRow());
    for (KeyValue kv : batch.getKvs()) {
      // we only need to cleanup Put entries
      byte type = kv.getType();
      Type t = KeyValue.Type.codeToType(type);
      if (!t.equals(Type.Put)) {
        continue;
      }

      // add the kv independently
      p.add(kv);
    }

    // do the usual thing as for deletes
    Collection<Batch> timeBatch = createTimestampBatchesFromMutation(p);
    LocalTableState state = new LocalTableState(env, localTable, p);
    for (Batch entry : timeBatch) {
      //just set the timestamp on the table - it already has all the future state
      state.setCurrentTimestamp(entry.getTimestamp());
      this.addDeleteUpdatesToMap(updateMap, state, entry.getTimestamp());
    }
  }
  return updateMap.toMap();
}