@Override public Collection<Pair<Mutation, byte[]>> getIndexUpdate(Mutation mutation, IndexMetaData indexMetaData) throws IOException { // create a state manager, so we can manage each batch LocalTableState state = new LocalTableState(localTable, mutation); // build the index updates for each group IndexUpdateManager manager = new IndexUpdateManager(indexMetaData); batchMutationAndAddUpdates(manager, state, mutation, indexMetaData); if (LOG.isTraceEnabled()) { LOG.trace("Found index updates for Mutation: " + mutation + "\n" + manager); } return manager.toMap(); }
public void addPendingUpdates(Cell... kvs) { if (kvs == null) return; addPendingUpdates(Arrays.asList(kvs)); }
@Override public Pair<ValueGetter, IndexUpdate> getIndexUpdateState(Collection<? extends ColumnReference> indexedColumns, boolean ignoreNewerMutations, boolean isStateForDeletes, IndexMetaData indexMetaData) throws IOException { Pair<CoveredDeleteScanner, IndexUpdate> pair = getIndexedColumnsTableState(indexedColumns, ignoreNewerMutations, isStateForDeletes, indexMetaData); ValueGetter valueGetter = IndexManagementUtil.createGetterFromScanner(pair.getFirst(), getCurrentRowKey()); return new Pair<ValueGetter, IndexUpdate>(valueGetter, pair.getSecond()); } }
public void addPendingUpdates(List<Cell> kvs) { if (kvs == null) return; setPendingUpdates(kvs); addUpdate(kvs); }
private void addCleanupForCurrentBatch(IndexUpdateManager updateMap, long batchTs, LocalTableState state, IndexMetaData indexMetaData) throws IOException { // get the cleanup for the current state state.setCurrentTimestamp(batchTs); addDeleteUpdatesToMap(updateMap, state, batchTs, indexMetaData); // ignore any index tracking from the delete state.resetTrackedColumns(); }
LocalTableState table = new LocalTableState(state, m); table.addPendingUpdates(m.get(fam, qual)); table.setCurrentTimestamp(ts); table.getIndexedColumnsTableState(Arrays.asList(col), false, false, indexMetaData);
private void ensureNoUpdatesWhenCoveredByDelete(RegionCoprocessorEnvironment env, IndexCodec codec, List<Cell> currentState, Delete d) throws IOException { LocalHBaseState table = new SimpleTableState(Result.create(currentState)); LocalTableState state = new LocalTableState(table, d); state.setCurrentTimestamp(d.getTimeStamp()); // now we shouldn't see anything when getting the index update state.addPendingUpdates(d.getFamilyCellMap().get(FAMILY)); Iterable<IndexUpdate> updates = codec.getIndexUpserts(state, IndexMetaData.NULL_INDEX_META_DATA, null, null); for (IndexUpdate update : updates) { assertFalse("Had some index updates, though it should have been covered by the delete", update.isValid()); } } }
Put pendingUpdate = new Put(row); pendingUpdate.addColumn(fam, qual, ts, val); LocalTableState table = new LocalTableState(state, pendingUpdate); table.setCurrentTimestamp(ts); Pair<CoveredDeleteScanner, IndexUpdate> p = table.getIndexedColumnsTableState(Arrays.asList(col), false, false, indexMetaData); Scanner s = p.getFirst(); p = table.getIndexedColumnsTableState(Arrays.asList(col), false, false, indexMetaData); s = p.getFirst(); assertEquals("Lost already loaded update!", storedKv, s.next());
state.setPendingUpdates(batch.getKvs()); addCleanupForCurrentBatch(updateMap, batchTs, state, indexMetaData); state.applyPendingUpdates(); addUpdateForGivenTimestamp(batchTs, state, updateMap, indexMetaData);
this.addUpdateCells(this.table.getCurrentRowState(update, toCover, ignoreNewerMutations).listCells(), false); isStateForDeletes && (requiresPriorRowState || insertingData(update))); return new Pair<CoveredDeleteScanner, IndexUpdate>(scanner, new IndexUpdate(tracker));
private long addUpdateForGivenTimestamp(long ts, LocalTableState state, IndexUpdateManager updateMap, IndexMetaData indexMetaData) throws IOException { state.setCurrentTimestamp(ts); ts = addCurrentStateMutationsForBatch(updateMap, state, indexMetaData); return ts; }
/** * Apply the {@link KeyValue}s set in {@link #setPendingUpdates(Collection)}. */ public void applyPendingUpdates() { this.addUpdate(kvs); }
/** * @param group * @param state * @return the update that should be made to the table */ private IndexUpdate getIndexUpdateForGroup(ColumnGroup group, TableState state, IndexMetaData indexMetaData) { List<CoveredColumn> refs = group.getColumns(); try { Pair<CoveredDeleteScanner, IndexUpdate> stateInfo = ((LocalTableState)state).getIndexedColumnsTableState(refs, false, false, indexMetaData); Scanner kvs = stateInfo.getFirst(); Pair<Integer, List<ColumnEntry>> columns = getNextEntries(refs, kvs, state.getCurrentRowKey()); // make sure we close the scanner kvs.close(); if (columns.getFirst().intValue() == 0) { return stateInfo.getSecond(); } // have all the column entries, so just turn it into a Delete for the row // convert the entries to the needed values byte[] rowKey = composeRowKey(state.getCurrentRowKey(), columns.getFirst(), columns.getSecond()); Put p = new Put(rowKey, state.getCurrentTimestamp()); // add the columns to the put addColumnsToPut(p, columns.getSecond()); // update the index info IndexUpdate update = stateInfo.getSecond(); update.setTable(Bytes.toBytes(group.getTable())); update.setUpdate(p); return update; } catch (IOException e) { throw new RuntimeException("Unexpected exception when getting state for columns: " + refs); } }
LocalTableState table = new LocalTableState(state, m); table.addPendingUpdates(m.get(fam, qual)); table.setCurrentTimestamp(ts); Pair<CoveredDeleteScanner, IndexUpdate> p = table.getIndexedColumnsTableState(Arrays.asList(col), false, false, indexMetaData); Scanner s = p.getFirst(); assertEquals("Didn't get the pending mutation's value first", m.get(fam, qual).get(0), s.next());
LocalTableState state = new LocalTableState(table, p); Iterable<IndexUpdate> updates = codec.getIndexDeletes(state, IndexMetaData.NULL_INDEX_META_DATA, null, null); assertFalse("Found index updates without any existing kvs in table!", updates.iterator().next() state.setCurrentTimestamp(1); state.addPendingUpdates(kvs); updates = codec.getIndexUpserts(state, IndexMetaData.NULL_INDEX_META_DATA, null, null); assertTrue("Didn't find index updates for pending primary table update!", updates.iterator() state = new LocalTableState(table, d); state.setCurrentTimestamp(2);
private void addCleanupForCurrentBatch(IndexUpdateManager updateMap, long batchTs, LocalTableState state, IndexMetaData indexMetaData) throws IOException { // get the cleanup for the current state state.setCurrentTimestamp(batchTs); addDeleteUpdatesToMap(updateMap, state, batchTs, indexMetaData); // ignore any index tracking from the delete state.resetTrackedColumns(); }
public void addPendingUpdates(List<Cell> kvs) { if (kvs == null) return; setPendingUpdates(kvs); addUpdate(kvs); }
state.setPendingUpdates(batch.getKvs()); addCleanupForCurrentBatch(updateMap, batchTs, state, indexMetaData); state.applyPendingUpdates(); addUpdateForGivenTimestamp(batchTs, state, updateMap, indexMetaData);
this.addUpdateCells(this.table.getCurrentRowState(update, toCover, ignoreNewerMutations).listCells(), false); isStateForDeletes && (requiresPriorRowState || insertingData(update))); return new Pair<CoveredDeleteScanner, IndexUpdate>(scanner, new IndexUpdate(tracker));