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(); }
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); }
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()); } } }
@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 static IndexUpdate createIndexUpdateForTesting(ColumnTracker tracker, byte[] table, Put p) { IndexUpdate update = new IndexUpdate(tracker); update.setTable(table); update.setUpdate(p); return update; }
public void addPendingUpdates(List<Cell> kvs) { if (kvs == null) return; setPendingUpdates(kvs); addUpdate(kvs); }
@Override public void setup(RegionCoprocessorEnvironment env) throws IOException { super.setup(env); this.indexMetaDataBuilder = new PhoenixIndexMetaDataBuilder(env); }
private void addUpdate(List<Cell> list, boolean overwrite) { if (list == null) return; for (Cell kv : list) { this.memstore.add(kv, overwrite); } }
/** * Rollback all the given values from the underlying state. * * @param values */ public void rollback(Collection<KeyValue> values) { for (KeyValue kv : values) { this.memstore.rollback(kv); } }
/** * By default, we always attempt to index the mutation. Commonly this can be slow (because the framework spends the * time to do the indexing, only to realize that you don't need it) or not ideal (if you want to turn on/off * indexing on a table without completely reloading it). * * @throws IOException */ @Override public boolean isEnabled(Mutation m) throws IOException { // ask the codec to see if we should even attempt indexing return this.codec.isEnabled(m); }
public FilteredKeyValueScanner(Filter filter, KeyValueStore store) { this(filter, store.getScanner()); }
public String serialize() { return CoveredColumn.serialize(familyString, getQualifier()); }
/** * Check to see if any {@link CoveredColumn} in <tt>this</tt> matches the given family * @param family to check * @return <tt>true</tt> if any column covers the family */ public boolean matches(String family) { for (CoveredColumn column : columns) { if (column.matchesFamily(family)) { return true; } } return false; }
@Override public void initialize(Configuration conf, byte[] tableName) { groups = CoveredColumnIndexSpecifierBuilder.getColumns(conf); }
public TableDescriptor build(TableDescriptor desc) throws IOException { return build(desc, CoveredColumnIndexCodec.class); }
private static ColumnEntry toColumnEntry(byte[] bytes) { return new ColumnEntry(bytes, COLUMN_REF); }
/** * Check to see if an row key just contains a list of null values. * * @param bytes * row key to examine * @return <tt>true</tt> if all the values are zero-length, <tt>false</tt> otherwise */ public static boolean checkRowKeyForAllNulls(byte[] bytes) { int keyCount = CoveredColumnIndexCodec.getPreviousInteger(bytes, bytes.length); int pos = bytes.length - Bytes.SIZEOF_INT; for (int i = 0; i < keyCount; i++) { int next = CoveredColumnIndexCodec.getPreviousInteger(bytes, pos); if (next > 0) { return false; } pos -= Bytes.SIZEOF_INT; } return true; }
private void addUpdate(List<Cell> list) { addUpdate(list, true); }
private void addUpdateCells(List<Cell> list, boolean overwrite) { if (list == null) return; // Avoid a copy of the Cell into a KeyValue if it's already a KeyValue for (Cell c : list) { this.memstore.add(c, overwrite); } }