private boolean generatePuts( PhoenixIndexMetaData indexMetaData, Collection<Pair<Mutation, byte[]>> indexUpdates, TxTableState state) throws IOException { state.applyMutation(); byte[] regionStartKey = this.regionStartKey; byte[] regionEndKey = this.regionEndKey; if (services != null && indexMetaData.hasLocalIndexes()) { try { HRegionLocation tableRegionLocation = services.getTableRegionLocation(tableName, state.getCurrentRowKey()); regionStartKey = tableRegionLocation.getRegionInfo().getStartKey(); regionEndKey = tableRegionLocation.getRegionInfo().getEndKey(); } catch (SQLException e) { throw new IOException(e); } } Iterable<IndexUpdate> puts = codec.getIndexUpserts(state, indexMetaData, regionStartKey, regionEndKey); boolean validPut = false; for (IndexUpdate put : puts) { if (put.isValid()) { indexUpdates.add(new Pair<Mutation, byte[]>(put.getUpdate(),put.getTableName())); validPut = true; } } return validPut; }
private void generateDeletes(PhoenixIndexMetaData indexMetaData, Collection<Pair<Mutation, byte[]>> indexUpdates, byte[] attribValue, TxTableState state) throws IOException { byte[] regionStartKey = this.regionStartKey; byte[] regionEndKey = this.regionEndKey; if (services != null && indexMetaData.hasLocalIndexes()) { try { HRegionLocation tableRegionLocation = services.getTableRegionLocation(tableName, state.getCurrentRowKey()); regionStartKey = tableRegionLocation.getRegionInfo().getStartKey(); regionEndKey = tableRegionLocation.getRegionInfo().getEndKey(); } catch (SQLException e) { throw new IOException(e); } } Iterable<IndexUpdate> deletes = codec.getIndexDeletes(state, indexMetaData, regionStartKey, regionEndKey); for (IndexUpdate delete : deletes) { if (delete.isValid()) { delete.getUpdate().setAttribute(PhoenixTransactionContext.TX_ROLLBACK_ATTRIBUTE_KEY, attribValue); indexUpdates.add(new Pair<Mutation, byte[]>(delete.getUpdate(),delete.getTableName())); } } }
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()); } } }
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() .isValid()); .hasNext()); for (IndexUpdate update : updates) { assertTrue("Update marked as invalid, but should be a pending index write!", update.isValid()); Put m = (Put) update.getUpdate(); for (IndexUpdate update : updates) { assertTrue("Didn't have any index cleanup, even though there is current state", update.isValid()); Delete m = (Delete) update.getUpdate();
if (cleanup != null) { for (IndexUpdate d : cleanup) { if (!d.isValid()) { continue;
if (update.isValid()) { byte[] table = update.getTableName(); Mutation mutation = update.getUpdate();
private boolean generatePuts( PhoenixIndexMetaData indexMetaData, Collection<Pair<Mutation, byte[]>> indexUpdates, TxTableState state) throws IOException { state.applyMutation(); Iterable<IndexUpdate> puts = codec.getIndexUpserts(state, indexMetaData); boolean validPut = false; for (IndexUpdate put : puts) { if (put.isValid()) { indexUpdates.add(new Pair<Mutation, byte[]>(put.getUpdate(),put.getTableName())); validPut = true; } } return validPut; }
private void generateDeletes(PhoenixIndexMetaData indexMetaData, Collection<Pair<Mutation, byte[]>> indexUpdates, byte[] attribValue, TxTableState state) throws IOException { Iterable<IndexUpdate> deletes = codec.getIndexDeletes(state, indexMetaData); for (IndexUpdate delete : deletes) { if (delete.isValid()) { delete.getUpdate().setAttribute(PhoenixTransactionContext.TX_ROLLBACK_ATTRIBUTE_KEY, attribValue); indexUpdates.add(new Pair<Mutation, byte[]>(delete.getUpdate(),delete.getTableName())); } } }
private boolean generatePuts( PhoenixIndexMetaData indexMetaData, Collection<Pair<Mutation, byte[]>> indexUpdates, TxTableState state) throws IOException { state.applyMutation(); byte[] regionStartKey = this.regionStartKey; byte[] regionEndKey = this.regionEndKey; if (services != null && indexMetaData.hasLocalIndexes()) { try { HRegionLocation tableRegionLocation = services.getTableRegionLocation(tableName, state.getCurrentRowKey()); regionStartKey = tableRegionLocation.getRegionInfo().getStartKey(); regionEndKey = tableRegionLocation.getRegionInfo().getEndKey(); } catch (SQLException e) { throw new IOException(e); } } Iterable<IndexUpdate> puts = codec.getIndexUpserts(state, indexMetaData, regionStartKey, regionEndKey); boolean validPut = false; for (IndexUpdate put : puts) { if (put.isValid()) { indexUpdates.add(new Pair<Mutation, byte[]>(put.getUpdate(),put.getTableName())); validPut = true; } } return validPut; }
private void generateDeletes(PhoenixIndexMetaData indexMetaData, Collection<Pair<Mutation, byte[]>> indexUpdates, byte[] attribValue, TxTableState state) throws IOException { byte[] regionStartKey = this.regionStartKey; byte[] regionEndKey = this.regionEndKey; if (services != null && indexMetaData.hasLocalIndexes()) { try { HRegionLocation tableRegionLocation = services.getTableRegionLocation(tableName, state.getCurrentRowKey()); regionStartKey = tableRegionLocation.getRegionInfo().getStartKey(); regionEndKey = tableRegionLocation.getRegionInfo().getEndKey(); } catch (SQLException e) { throw new IOException(e); } } Iterable<IndexUpdate> deletes = codec.getIndexDeletes(state, indexMetaData, regionStartKey, regionEndKey); for (IndexUpdate delete : deletes) { if (delete.isValid()) { delete.getUpdate().setAttribute(PhoenixTransactionContext.TX_ROLLBACK_ATTRIBUTE_KEY, attribValue); indexUpdates.add(new Pair<Mutation, byte[]>(delete.getUpdate(),delete.getTableName())); } } }
if (cleanup != null) { for (IndexUpdate d : cleanup) { if (!d.isValid()) { continue;
if (update.isValid()) { byte[] table = update.getTableName(); Mutation mutation = update.getUpdate();
if (cleanup != null) { for (IndexUpdate d : cleanup) { if (!d.isValid()) { continue;
if (update.isValid()) { byte[] table = update.getTableName(); Mutation mutation = update.getUpdate();