/** * Create a KVPair that can be used to issue a delete on an index record associated with the given * main table mutation. * * @param mutation the incoming modification. Its rowKey is used to get the the row in the base * table that will be updated. Once we have that, we can create a new KVPair of type {@link * KVPair.Type#DELETE DELETE} and call {@link #translate(KVPair)} to translate it to the * index's rowKey. * @param ctx the write context of the modification. Used to get transaction and region info. * @param indexedColumns the columns which are part of this index. Used to filter the Get. * @return An index row KVPair that can be used to delete the associated index row, or null if the * mutated row is not found (may have already been deleted). * @throws IOException for encoding/decoding problems. */ public KVPair createIndexDelete(KVPair mutation, WriteContext ctx, BitSet indexedColumns) throws IOException { // do a Get() on all the indexed columns of the base table DataResult result = fetchBaseRow(mutation, ctx, indexedColumns); // EntryPredicateFilter predicateFilter = new EntryPredicateFilter(indexedColumns, new // ObjectArrayList<Predicate>(),true); // get.setAttribute(SpliceConstants.ENTRY_PREDICATE_LABEL,predicateFilter.toBytes()); // DataResult result = ctx.getRegion().get(get); if (result == null || result.size() <= 0) { // we can't find the old row, may have been deleted already return null; } DataCell resultValue = result.userData(); if (resultValue == null) { // we can't find the old row, may have been deleted already return null; } // transform the results into an index row (as if we were inserting it) but create a delete for // it KVPair toTransform = new KVPair( resultValue.keyArray(), resultValue.keyOffset(), resultValue.keyLength(), resultValue.valueArray(), resultValue.valueOffset(), resultValue.valueLength(), KVPair.Type.DELETE); return translate(toTransform); }