[ 
https://issues.apache.org/jira/browse/ACCUMULO-2501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13954885#comment-13954885
 ] 

Russ Weeks commented on ACCUMULO-2501:
--------------------------------------

Keith, you're right that the unit tests don't invoke deepCopy directly. 
deepCopy is called 
[here|https://github.com/apache/accumulo/blob/master/core/src/main/java/org/apache/accumulo/core/iterators/user/RowFilter.java#L140]
 on the first RowFilter when the 2nd RowFilter is init'ed.

I'm not sure how best to mock up the iterator state for an explicit call to 
deepCopy, so I relied on the implicit call since that was the problem I was 
trying to solve anyways.

I've added another unit test to demonstrate the behaviour you described when 
multiple filters are chained together.

> Add deepCopy to RowFilter
> -------------------------
>
>                 Key: ACCUMULO-2501
>                 URL: https://issues.apache.org/jira/browse/ACCUMULO-2501
>             Project: Accumulo
>          Issue Type: Improvement
>    Affects Versions: 1.5.1
>            Reporter: Russ Weeks
>            Priority: Minor
>              Labels: filter, iterators
>             Fix For: 1.5.2
>
>
> It would be nice for subclasses of RowFilter to be chainable, for this they 
> need to provide an implementation of deepCopy. Adding a base implementation 
> in RowFilter would make things easier.
> Here's a patch (taken from git commit 23980d3)... please let me know if I'm 
> missing something, maybe there's more to it than I can see?
> {code}
> diff --git 
> a/core/src/main/java/org/apache/accumulo/core/iterators/user/RowFilter.java 
> b/core/src/main/java/org/apache/accumulo/core/iterators/user/RowFilter.java
> index a232796..ad1e4a0 100644
> --- 
> a/core/src/main/java/org/apache/accumulo/core/iterators/user/RowFilter.java
> +++ 
> b/core/src/main/java/org/apache/accumulo/core/iterators/user/RowFilter.java
> @@ -139,7 +139,20 @@ public abstract class RowFilter extends WrappingIterator 
> {
>      super.init(source, options, env);
>      this.decisionIterator = new RowIterator(source.deepCopy(env));
>    }
> -  
> +
> +  @Override
> +  public SortedKeyValueIterator<Key,Value> deepCopy(IteratorEnvironment env) 
> {
> +      RowFilter newInstance;
> +      try {
> +          newInstance = getClass().newInstance();
> +      } catch (Exception e) {
> +          throw new RuntimeException(e);
> +      }
> +      newInstance.setSource(getSource().deepCopy(env));
> +      newInstance.decisionIterator = new 
> RowIterator(getSource().deepCopy(env));
> +      return newInstance;
> +  }
> +
>    @Override
>    public boolean hasTop() {
>      return hasTop && super.hasTop();
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to