Search in sources :

Example 1 with Batch

use of org.apache.phoenix.hbase.index.covered.Batch in project phoenix by apache.

the class CoveredColumnIndexer method getIndexUpdateForFilteredRows.

@Override
public Collection<Pair<Mutation, byte[]>> getIndexUpdateForFilteredRows(Collection<KeyValue> filtered, IndexMetaData indexMetaData) throws IOException {
    // stores all the return values
    IndexUpdateManager updateMap = new IndexUpdateManager(indexMetaData);
    // batch the updates by row to make life easier and ordered
    Collection<Batch> batches = batchByRow(filtered);
    for (Batch batch : batches) {
        Cell curKV = batch.getKvs().iterator().next();
        Put p = new Put(curKV.getRowArray(), curKV.getRowOffset(), curKV.getRowLength());
        for (Cell 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(), indexMetaData);
        }
    }
    return updateMap.toMap();
}
Also used : Type(org.apache.hadoop.hbase.KeyValue.Type) IndexUpdateManager(org.apache.phoenix.hbase.index.covered.update.IndexUpdateManager) Batch(org.apache.phoenix.hbase.index.covered.Batch) Cell(org.apache.hadoop.hbase.Cell) Put(org.apache.hadoop.hbase.client.Put) LocalTableState(org.apache.phoenix.hbase.index.covered.LocalTableState)

Aggregations

Cell (org.apache.hadoop.hbase.Cell)1 Type (org.apache.hadoop.hbase.KeyValue.Type)1 Put (org.apache.hadoop.hbase.client.Put)1 Batch (org.apache.phoenix.hbase.index.covered.Batch)1 LocalTableState (org.apache.phoenix.hbase.index.covered.LocalTableState)1 IndexUpdateManager (org.apache.phoenix.hbase.index.covered.update.IndexUpdateManager)1