milleruntime commented on a change in pull request #2347:
URL: https://github.com/apache/accumulo/pull/2347#discussion_r743769254
##########
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:
I thought about changing the `AtomicBoolean` to be final but now I am
wondering if it was written this way with performance in mind. We do a lot of
passing around of the flag across the iterator stack but only ever set it in
one place. If we were to make it final, then I think that would be a lot of
extra memory accesses to the atomic value vs just passing around a reference.
I thought of doing something like this in the setter, but like I said, I
think it would be less efficient:
<pre>
public void setInterruptFlag(AtomicBoolean flag) {
boolean newFlag = flag.get();
boolean previousFlag = this.interruptFlag.getAndSet(newFlag);
if (previousFlag == newFlag && newFlag)
log.warn("Interrupt called on iterator that was previously
interrupted.");
}
</pre>
--
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]