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 #224: ACCUMULO-4500 ACCUMULO-96 Added summarization
Date Tue, 07 Mar 2017 15:52:28 GMT
Github user keith-turner commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/224#discussion_r104701438
  
    --- Diff: core/src/main/java/org/apache/accumulo/core/summary/SummaryCollection.java ---
    @@ -0,0 +1,167 @@
    +/*
    + * 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.summary;
    +
    +import java.util.ArrayList;
    +import java.util.Collection;
    +import java.util.HashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Map.Entry;
    +
    +import org.apache.accumulo.core.client.impl.thrift.TSummaries;
    +import org.apache.accumulo.core.client.impl.thrift.TSummarizerConfiguration;
    +import org.apache.accumulo.core.client.impl.thrift.TSummary;
    +import org.apache.accumulo.core.client.summary.Summarizer;
    +import org.apache.accumulo.core.client.summary.SummarizerConfiguration;
    +import org.apache.accumulo.core.client.summary.Summary;
    +
    +/**
    + * This class facilitates merging, storing, and serializing (to/from thrift) intermediate
summary information.
    + */
    +public class SummaryCollection {
    +
    +  private static class MergedSummary {
    +    Map<String,Long> summary;
    +    long filesContaining;
    +    long filesExceedingBoundry;
    +    long filesLarge;
    +
    +    public MergedSummary(FileSummary entry) {
    +      this.summary = entry.summary;
    +      this.filesContaining = 1;
    +      this.filesExceedingBoundry = entry.exceededBoundry ? 1 : 0;
    +      this.filesLarge = entry.exceededMaxSize ? 1 : 0;
    +    }
    +
    +    public MergedSummary(TSummary tSummary) {
    +      this.summary = new HashMap<>(tSummary.getSummary());
    +      this.filesContaining = tSummary.getFilesContaining();
    +      this.filesExceedingBoundry = tSummary.getFilesExceeding();
    +      this.filesLarge = tSummary.getFilesLarge();
    +    }
    +
    +    public void merge(MergedSummary other, SummarizerConfiguration config, SummarizerFactory
factory) {
    +
    +      if (summary == null && other.summary != null) {
    +        summary = new HashMap<>(other.summary);
    +      } else if (summary != null && other.summary != null) {
    +        Summarizer summarizer = factory.getSummarizer(config);
    +        summarizer.combiner(config).merge(summary, other.summary);
    +      }
    +
    +      filesContaining += other.filesContaining;
    +      filesExceedingBoundry += other.filesExceedingBoundry;
    +      filesLarge += other.filesLarge;
    +    }
    +
    +    public TSummary toThrift(SummarizerConfiguration key) {
    +      TSummarizerConfiguration tsumConf = SummarizerConfigurationUtil.toThrift(key);
    +      return new TSummary(summary, tsumConf, filesContaining, filesExceedingBoundry,
filesLarge);
    +    }
    +
    +  }
    +
    +  private Map<SummarizerConfiguration,MergedSummary> mergedSummaries;
    +  private long totalFiles;
    +
    +  public SummaryCollection() {
    +    mergedSummaries = new HashMap<>();
    +    totalFiles = 0;
    +  }
    +
    +  public SummaryCollection(TSummaries tsums) {
    +    mergedSummaries = new HashMap<>();
    +    for (TSummary tSummary : tsums.getSummaries()) {
    +      SummarizerConfiguration sconf = SummarizerConfigurationUtil.fromThrift(tSummary.getConfig());
    +      mergedSummaries.put(sconf, new MergedSummary(tSummary));
    +    }
    +
    +    totalFiles = tsums.getTotalFiles();
    +  }
    +
    +  SummaryCollection(Collection<FileSummary> initialEntries) {
    +    mergedSummaries = new HashMap<>();
    +    for (FileSummary entry : initialEntries) {
    +      mergedSummaries.put(entry.conf, new MergedSummary(entry));
    +    }
    +    totalFiles = 1;
    +  }
    +
    +  static class FileSummary {
    +
    +    private SummarizerConfiguration conf;
    +    private Map<String,Long> summary;
    +    private boolean exceededBoundry;
    +    private boolean exceededMaxSize;
    +
    +    FileSummary(SummarizerConfiguration conf, Map<String,Long> summary, boolean
exceededBoundry) {
    +      this.conf = conf;
    +      this.summary = summary;
    +      this.exceededBoundry = exceededBoundry;
    +      this.exceededMaxSize = false;
    +    }
    +
    +    FileSummary(SummarizerConfiguration conf) {
    +      this.conf = conf;
    +      this.summary = new HashMap<>();
    +      ;
    +      this.exceededBoundry = false;
    +      this.exceededMaxSize = true;
    +    }
    +  }
    +
    +  public void merge(SummaryCollection other, SummarizerFactory factory) {
    --- End diff --
    
    I don't think so.  Alot of code is assumed to be single threaded.  Also, its internal
as you mentioned.


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