gora-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewismc <...@git.apache.org>
Subject [GitHub] gora pull request: GORA-454 Implement FilterList tests
Date Mon, 11 Jan 2016 12:48:55 GMT
Github user lewismc commented on a diff in the pull request:

    https://github.com/apache/gora/pull/48#discussion_r49317117
  
    --- Diff: gora-core/src/main/java/org/apache/gora/filter/FilterList.java ---
    @@ -101,8 +109,25 @@ public void write(DataOutput out) throws IOException {
     
       @Override
       public boolean filter(K key, T persistent) {
    -    // TODO not yet implemented
    -    return false;
    +    boolean filtered = false;
    +    //OR
    +    if (operator.equals(Operator.MUST_PASS_ONE)) {
    +      for (Filter<K, T> filter: filters) {
    +        if (!filter.filter(key, persistent)) {
    +          return !filtered;
    +        }
    +      }
    +      //AND
    +    } else if (operator.equals(Operator.MUST_PASS_ALL)) {
    +      for (Filter<K, T> filter: filters) {
    +        if (filter.filter(key, persistent)) {
    +          return !filtered;
    +        }
    +      }
    +    } else {
    +      throw new IllegalStateException(operator + " not yet implemented!");
    +    }
    +    return filtered;
       }
    --- End diff --
    
    Yes it would, I'll update the PR thanks Renaldo.
    
    On Monday, January 11, 2016, Renato Marroquin <notifications@github.com>
    wrote:
    
    > In gora-core/src/main/java/org/apache/gora/filter/FilterList.java
    > <https://github.com/apache/gora/pull/48#discussion_r49316977>:
    >
    > > +      for (Filter<K, T> filter: filters) {
    > > +        if (!filter.filter(key, persistent)) {
    > > +          return !filtered;
    > > +        }
    > > +      }
    > > +      //AND
    > > +    } else if (operator.equals(Operator.MUST_PASS_ALL)) {
    > > +      for (Filter<K, T> filter: filters) {
    > > +        if (filter.filter(key, persistent)) {
    > > +          return !filtered;
    > > +        }
    > > +      }
    > > +    } else {
    > > +      throw new IllegalStateException(operator + " not yet implemented!");
    > > +    }
    > > +    return filtered;
    > >    }
    >
    > I think this looks good, just being annoying here, but would it look more
    > readable if we have a switch statement instead?
    >
    > —
    > Reply to this email directly or view it on GitHub
    > <https://github.com/apache/gora/pull/48/files#r49316977>.
    >
    
    
    -- 
    *Lewis*



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message