accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ivakegg <...@git.apache.org>
Subject [GitHub] accumulo pull request #275: ACCUMULO-4667 Reworked the LocalityGroupIterator...
Date Mon, 17 Jul 2017 19:12:51 GMT
Github user ivakegg commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/275#discussion_r127798040
  
    --- Diff: core/src/main/java/org/apache/accumulo/core/iterators/system/LocalityGroupIterator.java
---
    @@ -65,23 +70,55 @@ public InterruptibleIterator getIterator() {
         private InterruptibleIterator iterator;
       }
     
    -  private LocalityGroup groups[];
    -  private Set<ByteSequence> nonDefaultColumnFamilies;
    +  public static class LocalityGroupContext {
    +    final List<LocalityGroup> groups;
    +    final LocalityGroup defaultGroup;
    +    final Map<ByteSequence,LocalityGroup> groupByCf;
    +
    +    public LocalityGroupContext(LocalityGroup[] groups) {
    +      this.groups = Collections.unmodifiableList(Arrays.asList(groups));
    +      this.groupByCf = new HashMap<ByteSequence,LocalityGroup>();
    +      LocalityGroup foundDefault = null;
    +
    +      for (LocalityGroup group : groups) {
    +        if (group.isDefaultLocalityGroup && group.columnFamilies == null) {
    +          if (foundDefault != null) {
    +            throw new IllegalStateException("Found multiple default locality groups");
    +          }
    +          foundDefault = group;
    +        } else {
    +          for (Entry<ByteSequence,MutableLong> entry : group.columnFamilies.entrySet())
{
    +            if (entry.getValue().longValue() > 0) {
    +              if (groupByCf.containsKey(entry.getKey())) {
    +                throw new IllegalStateException("Found the same cf in multiple locality
groups");
    +              }
    +              groupByCf.put(entry.getKey(), group);
    +            }
    +          }
    +        }
    +      }
    +      defaultGroup = foundDefault;
    +    }
    +  }
    +
    +  private final LocalityGroupContext lgContext;
       private AtomicBoolean interruptFlag;
    +  private ImmutableSet<ByteSequence> lastColumnFamilies;
    +  private volatile boolean lastInclusive;
    +  private List<LocalityGroup> lastUsed;
     
    -  public LocalityGroupIterator(LocalityGroup groups[], Set<ByteSequence> nonDefaultColumnFamilies)
{
    +  public LocalityGroupIterator(LocalityGroup groups[]) {
         super(groups.length);
    -    this.groups = groups;
    -    this.nonDefaultColumnFamilies = nonDefaultColumnFamilies;
    +    this.lgContext = new LocalityGroupContext(groups);
       }
     
       @Override
       public void init(SortedKeyValueIterator<Key,Value> source, Map<String,String>
options, IteratorEnvironment env) throws IOException {
         throw new UnsupportedOperationException();
       }
     
    -  public static final int seek(HeapIterator hiter, LocalityGroup[] groups, Set<ByteSequence>
nonDefaultColumnFamilies, Range range,
    -      Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException
{
    +  public static final int seek(HeapIterator hiter, LocalityGroupContext groups, Range
range, Collection<ByteSequence> columnFamilies, boolean inclusive,
    +      List<LocalityGroup> used) throws IOException {
    --- End diff --
    
    ok


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