/** * Batch all the {@link KeyValue}s in a collection of kvs by timestamp. Updates any {@link KeyValue} with a * timestamp == {@link HConstants#LATEST_TIMESTAMP} to the timestamp at the time the method is called. * * @param kvs {@link KeyValue}s to break into batches * @param batches to update with the given kvs */ public static void createTimestampBatchesFromKeyValues(Collection<KeyValue> kvs, Map<Long, Batch> batches) { // batch kvs by timestamp for (KeyValue kv : kvs) { long ts = kv.getTimestamp(); Batch batch = batches.get(ts); if (batch == null) { batch = new Batch(ts); batches.put(ts, batch); } batch.add(kv); } }
long batchTs = batch.getTimestamp(); state.setPendingUpdates(batch.getKvs()); addCleanupForCurrentBatch(updateMap, batchTs, state, indexMetaData);
@Override public int compare(Batch o1, Batch o2) { return Longs.compare(o1.getTimestamp(), o2.getTimestamp()); } });
for (Batch batch : batches) { Mutation mWithSameTS; Cell firstCell = batch.getKvs().get(0); if (KeyValue.Type.codeToType(firstCell.getTypeByte()) == KeyValue.Type.Put) { mWithSameTS = new Put(row); for (Cell cell : batch.getKvs()) { byte[] fam = CellUtil.cloneFamily(cell); List<Cell> famCells = mWithSameTS.getFamilyCellMap().get(fam);
@Override public int compare(Batch o1, Batch o2) { return Longs.compare(o1.getTimestamp(), o2.getTimestamp()); } });
for (Batch batch : batches) { Mutation mWithSameTS; Cell firstCell = batch.getKvs().get(0); if (KeyValue.Type.codeToType(firstCell.getTypeByte()) == KeyValue.Type.Put) { mWithSameTS = new Put(row); for (Cell cell : batch.getKvs()) { byte[] fam = CellUtil.cloneFamily(cell); List<Cell> famCells = mWithSameTS.getFamilyCellMap().get(fam);
/** * Split the mutation into batches based on the timestamps of each keyvalue. We need to check each key-value in the * update to see if it matches the others. Generally, this will be the case, but you can add kvs to a mutation that * don't all have the timestamp, so we need to manage everything in batches based on timestamp. * <p> * Adds all the updates in the {@link Mutation} to the state, as a side-effect. * @param state * current state of the row for the mutation. * @param m * mutation to batch * @param indexMetaData TODO * @param updateMap * index updates into which to add new updates. Modified as a side-effect. * * @throws IOException */ private void batchMutationAndAddUpdates(IndexUpdateManager manager, LocalTableState state, Mutation m, IndexMetaData indexMetaData) throws IOException { // The cells of a mutation are broken up into time stamp batches prior to this call (in Indexer). long ts = m.getFamilyCellMap().values().iterator().next().iterator().next().getTimestamp(); Batch batch = new Batch(ts); for (List<Cell> family : m.getFamilyCellMap().values()) { for (Cell kv : family) { batch.add(kv); if(ts != kv.getTimestamp()) { throw new IllegalStateException("Time stamps must match for all cells in a batch"); } } } addMutationsForBatch(manager, batch, state, indexMetaData); }
long batchTs = batch.getTimestamp(); state.setPendingUpdates(batch.getKvs()); addCleanupForCurrentBatch(updateMap, batchTs, state, indexMetaData);
@Override public int compare(Batch o1, Batch o2) { return Longs.compare(o1.getTimestamp(), o2.getTimestamp()); } });
for (Batch batch : batches) { Mutation mWithSameTS; Cell firstCell = batch.getKvs().get(0); if (KeyValue.Type.codeToType(firstCell.getTypeByte()) == KeyValue.Type.Put) { mWithSameTS = new Put(row); for (Cell cell : batch.getKvs()) { byte[] fam = CellUtil.cloneFamily(cell); List<Cell> famCells = mWithSameTS.getFamilyCellMap().get(fam);
/** * Batch all the {@link KeyValue}s in a collection of kvs by timestamp. Updates any {@link KeyValue} with a * timestamp == {@link HConstants#LATEST_TIMESTAMP} to the timestamp at the time the method is called. * * @param kvs {@link KeyValue}s to break into batches * @param batches to update with the given kvs */ public static void createTimestampBatchesFromKeyValues(Collection<KeyValue> kvs, Map<Long, Batch> batches) { // batch kvs by timestamp for (KeyValue kv : kvs) { long ts = kv.getTimestamp(); Batch batch = batches.get(ts); if (batch == null) { batch = new Batch(ts); batches.put(ts, batch); } batch.add(kv); } }
long batchTs = batch.getTimestamp(); state.setPendingUpdates(batch.getKvs()); addCleanupForCurrentBatch(updateMap, batchTs, state, indexMetaData);
/** * Batch all the {@link KeyValue}s in a collection of kvs by timestamp. Updates any {@link KeyValue} with a * timestamp == {@link HConstants#LATEST_TIMESTAMP} to the timestamp at the time the method is called. * * @param kvs {@link KeyValue}s to break into batches * @param batches to update with the given kvs */ public static void createTimestampBatchesFromKeyValues(Collection<KeyValue> kvs, Map<Long, Batch> batches) { // batch kvs by timestamp for (KeyValue kv : kvs) { long ts = kv.getTimestamp(); Batch batch = batches.get(ts); if (batch == null) { batch = new Batch(ts); batches.put(ts, batch); } batch.add(kv); } }
/** * Split the mutation into batches based on the timestamps of each keyvalue. We need to check each key-value in the * update to see if it matches the others. Generally, this will be the case, but you can add kvs to a mutation that * don't all have the timestamp, so we need to manage everything in batches based on timestamp. * <p> * Adds all the updates in the {@link Mutation} to the state, as a side-effect. * @param state * current state of the row for the mutation. * @param m * mutation to batch * @param indexMetaData TODO * @param updateMap * index updates into which to add new updates. Modified as a side-effect. * * @throws IOException */ private void batchMutationAndAddUpdates(IndexUpdateManager manager, LocalTableState state, Mutation m, IndexMetaData indexMetaData) throws IOException { // The cells of a mutation are broken up into time stamp batches prior to this call (in Indexer). long ts = m.getFamilyCellMap().values().iterator().next().iterator().next().getTimestamp(); Batch batch = new Batch(ts); for (List<Cell> family : m.getFamilyCellMap().values()) { for (Cell kv : family) { batch.add(kv); if(ts != kv.getTimestamp()) { throw new IllegalStateException("Time stamps must match for all cells in a batch"); } } } addMutationsForBatch(manager, batch, state, indexMetaData); }
/** * Split the mutation into batches based on the timestamps of each keyvalue. We need to check each key-value in the * update to see if it matches the others. Generally, this will be the case, but you can add kvs to a mutation that * don't all have the timestamp, so we need to manage everything in batches based on timestamp. * <p> * Adds all the updates in the {@link Mutation} to the state, as a side-effect. * @param state * current state of the row for the mutation. * @param m * mutation to batch * @param indexMetaData TODO * @param updateMap * index updates into which to add new updates. Modified as a side-effect. * * @throws IOException */ private void batchMutationAndAddUpdates(IndexUpdateManager manager, LocalTableState state, Mutation m, IndexMetaData indexMetaData) throws IOException { // The cells of a mutation are broken up into time stamp batches prior to this call (in Indexer). long ts = m.getFamilyCellMap().values().iterator().next().iterator().next().getTimestamp(); Batch batch = new Batch(ts); for (List<Cell> family : m.getFamilyCellMap().values()) { for (Cell kv : family) { batch.add(kv); if(ts != kv.getTimestamp()) { throw new IllegalStateException("Time stamps must match for all cells in a batch"); } } } addMutationsForBatch(manager, batch, state, indexMetaData); }