accumulo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yamini Joshi <>
Subject Modify Keys within iterator
Date Fri, 30 Sep 2016 17:25:56 GMT
Hello Everyone!

I am trying to write an iterator to modify keys within a table (at scan).
My use case is to select a few records that match a certain criterion and
then modify them within the iterator(using the following class) for some
other succeeding iterator/combiner. The problem is that this iterator does
return any records/keys. I added some primitive prints and found that the
keys (this.key) is changed but the output of iterator is nothing. I'd
appreciate if someone could give me any insight. I'm sure I'm making a
teeny tiny mistake somewhere.

         row                   colF
colQ                 ts                Val
I/P:    r_1                   f                             f_1
         r_1                   fx                            f_1

O/P:  f_1                   r
r_1                                      v1
         f_1                   fx
fx                                        v1

public class KeyModifyIterator implements SortedKeyValueIterator<Key,Value>

  private SortedKeyValueIterator<Key,Value> source;
  private Key key;
  private Value value;

  public void init(SortedKeyValueIterator<Key,Value> source,
Map<String,String> options, IteratorEnvironment env) throws IOException {
    this.source = source;

  public boolean hasTop() {
    return key != null;

  public void next() throws IOException {
        if (source.hasTop()) {
            ByteSequence currentRow = source.getTopKey().getRowData();
            ByteSequence currentColf =
            ByteSequence currentColq =
            long ts = source.getTopKey().getTimestamp();
            String v = source.getTopValue().toString();
            System.out.println("Key = " + currentRow.toString() + " Cf = "
+ currentColf.toString() + " Cq = " + currentColq.toString()  + " val = " +

            if (currentColf.toString().equals("fx")){
                System.out.println("Updating fx" );
                this.key = new Key(currentColq.toArray(),
currentColf.toArray(), currentColf.toArray(), new byte[0], ts);
                this.value = new Value (v.getBytes(UTF_8));
                System.out.println("Updating other" );
                this.key = new Key(currentColq.toArray(),
"r".getBytes(UTF_8), currentRow.toArray(), new byte[0], ts);
                this.value = new Value (v.getBytes(UTF_8));


          } else {
            this.key = null;
            this.value = null;

  public void seek(Range range, Collection<ByteSequence> columnFamilies,
boolean inclusive) throws IOException {, columnFamilies, inclusive);

  public Key getTopKey() {
    return key;

  public Value getTopValue() {
    return value;

  public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment
env) {
    return null;


Best regards,
Yamini Joshi

View raw message