accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From keith-turner <...@git.apache.org>
Subject [GitHub] accumulo pull request: Implementation of SeekingFilter, CfCqSliceF...
Date Fri, 14 Aug 2015 18:41:23 GMT
Github user keith-turner commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/42#discussion_r37106437
  
    --- Diff: core/src/main/java/org/apache/accumulo/core/iterators/user/CfCqSliceSeekingFilter.java
---
    @@ -0,0 +1,132 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.accumulo.core.iterators.user;
    +
    +import org.apache.accumulo.core.data.Key;
    +import org.apache.accumulo.core.data.PartialKey;
    +import org.apache.accumulo.core.data.Value;
    +import org.apache.accumulo.core.iterators.IteratorEnvironment;
    +import org.apache.accumulo.core.iterators.OptionDescriber;
    +import org.apache.accumulo.core.iterators.SortedKeyValueIterator;
    +
    +import java.io.IOException;
    +import java.util.Map;
    +
    +/**
    + * Filters key/value pairs for a range of column families and a range of column qualifiers.
Only keys which fall in both ranges will be passed by the filter.
    + * Note that if you have a small, well-defined set of column families it will be much
more efficient to configure locality groups to isolate that data instead
    + * of configuring this iterator to seek over it.
    + *
    + * This filter may be more efficient than the CfCqSliceFilter or the ColumnSlice filter
for small slices of large rows as it will seek to the next potential
    + * match once it determines that it has iterated past the end of a slice.
    + *
    + * @see org.apache.accumulo.core.iterators.user.CfCqSliceOpts for a description of this
iterator's options.
    + */
    +public class CfCqSliceSeekingFilter extends SeekingFilter implements OptionDescriber
{
    +
    +  private static final FilterResult SKIP_TO_HINT = new FilterResult(false, AdvanceResult.USE_HINT);
    +  private static final FilterResult SKIP_TO_NEXT = new FilterResult(false, AdvanceResult.NEXT);
    +  private static final FilterResult SKIP_TO_NEXT_ROW = new FilterResult(false, AdvanceResult.NEXT_ROW);
    +  private static final FilterResult SKIP_TO_NEXT_CF = new FilterResult(false, AdvanceResult.NEXT_CF);
    +  private static final FilterResult INCLUDE_AND_NEXT = new FilterResult(true, AdvanceResult.NEXT);
    +  private static final FilterResult INCLUDE_AND_NEXT_CF = new FilterResult(true, AdvanceResult.NEXT_CF);
    +
    +  private CfCqSliceOpts cso;
    +
    +  @Override
    +  public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String>
options, IteratorEnvironment env) throws IOException {
    +    super.init(source, options, env);
    +    cso = new CfCqSliceOpts(options);
    +  }
    +
    +  @Override
    +  public FilterResult filter(Key k, Value v) {
    +    if (cso.minCf.getLength() > 0) {
    +      int minCfCmp = k.compareColumnFamily(cso.minCf);
    +      if (minCfCmp < 0) {
    +        return SKIP_TO_HINT; // hint will be the min CF in this row.
    +      }
    +      if (minCfCmp == 0 && !cso.minInclusive) {
    +        return SKIP_TO_NEXT;
    +      }
    +    }
    +    if (cso.maxCf.getLength() > 0) {
    +      int maxCfCmp = k.compareColumnFamily(cso.maxCf);
    +      if (maxCfCmp > 0 || (maxCfCmp == 0 && !cso.maxInclusive)) {
    +        return SKIP_TO_NEXT_ROW;
    +      }
    +    }
    +    // at this point we're in the correct CF range, now check the CQ.
    +    if (cso.minCq.getLength() > 0) {
    +      int minCqCmp = k.compareColumnQualifier(cso.minCq);
    +      if (minCqCmp < 0) {
    +        return SKIP_TO_HINT; // hint will be the min CQ in this CF in this row.
    +      }
    +      if (minCqCmp == 0 && !cso.minInclusive) {
    +        return SKIP_TO_NEXT;
    --- End diff --
    
    Noticed this case was not covered by unit test


---
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