ctubbsii commented on a change in pull request #2347:
URL: https://github.com/apache/accumulo/pull/2347#discussion_r745061737



##########
File path: 
core/src/main/java/org/apache/accumulo/core/iterators/SortedMapIterator.java
##########
@@ -36,28 +37,40 @@
  *
  * Note that this class is intended as an in-memory replacement for 
RFile$Reader, so its behavior
  * reflects the same assumptions; namely, that this iterator is not 
responsible for respecting the
- * columnFamilies passed into seek().
+ * columnFamilies passed into seek(). If you want a Map-backed Iterator that 
returns only sought
+ * CFs, construct a new ColumnFamilySkippingIterator(new 
SortedMapIterator(map)).
+ *
+ * @see org.apache.accumulo.core.iterators.ColumnFamilySkippingIterator
  */
-public class SortedMapIterator implements SortedKeyValueIterator<Key,Value> {
+public class SortedMapIterator implements InterruptibleIterator {
   private Iterator<Entry<Key,Value>> iter;
   private Entry<Key,Value> entry;
 
   private SortedMap<Key,Value> map;
   private Range range;
 
+  private AtomicBoolean interruptFlag;

Review comment:
       It's not a performance thing. It's an implementation injection mechanism 
(see where we're notifying the iterators by changing the value in the scan 
code: `grep -lR 'interruptFlag.set(true)' .`. AtomicBoolean is being used like 
a BooleanSupplier. This was probably fine at one point, since BooleanSupplier 
was introduced in Java 8, and before that, AtomicBoolean was an attractive 
alternative to a built-in supplier. But, having the type be AtomicBoolean 
implies atomicity, and that can be confusing, since atomicity guarantees are 
clearly broken by having a setter that can swap out the reference itself in 
addition to the value. We're not actually relying on the atomicity guarantees 
in these cases, though, as far as I can tell, so BooleanSupplier would suffice 
as the type.
   
   Your code above wouldn't work. I had a similar idea initially 
(`this.interruptFlag.set(flag.get())`). However, it's not sufficient to set the 
value. We need to set the containing object reference, so we can communicate 
the change in value when the caller updates the source.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to