accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshelser <...@git.apache.org>
Subject [GitHub] accumulo pull request #224: ACCUMULO-4500 ACCUMULO-96 Added summarization
Date Thu, 09 Mar 2017 19:43:08 GMT
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/224#discussion_r105248600
  
    --- Diff: core/src/main/java/org/apache/accumulo/core/summary/Gatherer.java ---
    @@ -0,0 +1,513 @@
    +/*
    + * 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.io.IOException;
    +import java.io.UncheckedIOException;
    +import java.util.ArrayList;
    +import java.util.Collections;
    +import java.util.HashMap;
    +import java.util.HashSet;
    +import java.util.Iterator;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Map.Entry;
    +import java.util.Set;
    +import java.util.TreeMap;
    +import java.util.concurrent.Callable;
    +import java.util.concurrent.ExecutionException;
    +import java.util.concurrent.ExecutorService;
    +import java.util.concurrent.Executors;
    +import java.util.concurrent.Future;
    +import java.util.function.Predicate;
    +import java.util.regex.Pattern;
    +import java.util.stream.Collectors;
    +import java.util.stream.StreamSupport;
    +
    +import org.apache.accumulo.core.client.AccumuloException;
    +import org.apache.accumulo.core.client.AccumuloSecurityException;
    +import org.apache.accumulo.core.client.TableNotFoundException;
    +import org.apache.accumulo.core.client.impl.ClientContext;
    +import org.apache.accumulo.core.client.impl.ServerClient;
    +import org.apache.accumulo.core.client.impl.thrift.TRowRange;
    +import org.apache.accumulo.core.client.impl.thrift.TSummaries;
    +import org.apache.accumulo.core.client.impl.thrift.TSummaryRequest;
    +import org.apache.accumulo.core.client.summary.SummarizerConfiguration;
    +import org.apache.accumulo.core.conf.AccumuloConfiguration;
    +import org.apache.accumulo.core.data.ByteSequence;
    +import org.apache.accumulo.core.data.Key;
    +import org.apache.accumulo.core.data.Range;
    +import org.apache.accumulo.core.data.impl.KeyExtent;
    +import org.apache.accumulo.core.file.blockfile.cache.BlockCache;
    +import org.apache.accumulo.core.metadata.schema.MetadataScanner;
    +import org.apache.accumulo.core.metadata.schema.TabletMetadata;
    +import org.apache.accumulo.core.rpc.ThriftUtil;
    +import org.apache.accumulo.core.tabletserver.thrift.TabletClientService.Client;
    +import org.apache.accumulo.core.trace.Tracer;
    +import org.apache.accumulo.core.trace.thrift.TInfo;
    +import org.apache.accumulo.core.util.ByteBufferUtil;
    +import org.apache.accumulo.core.util.CachedConfiguration;
    +import org.apache.accumulo.core.util.TextUtil;
    +import org.apache.accumulo.fate.util.UtilWaitThread;
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.fs.FileSystem;
    +import org.apache.hadoop.fs.Path;
    +import org.apache.hadoop.io.Text;
    +import org.apache.thrift.TApplicationException;
    +import org.apache.thrift.transport.TTransportException;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import com.google.common.base.Preconditions;
    +import com.google.common.collect.Lists;
    +import com.google.common.hash.Hashing;
    +import com.google.common.net.HostAndPort;
    +
    +/**
    + * This class implements using multiple tservers to gather summaries.
    + *
    + * Below is a rough outline of the RPC process.
    + *
    + * <ol>
    + * <li>Clients pick a random tserver and make an RPC to remotely execute {@link
#gather()}.
    + * <li> {@link #gather()} will call make RPC calls to multiple tservers to remotely
execute {@link #processPartition(int, int)}
    + * <li> {@link #processPartition(int, int)} will make RPC calls to multiple tserver
to remotely execute
    + * {@link #processFiles(FileSystemResolver, Map, BlockCache, BlockCache, ExecutorService)}
    + * </ol>
    + */
    +public class Gatherer {
    +
    +  private static final Logger log = LoggerFactory.getLogger(Gatherer.class);
    +
    +  private ClientContext ctx;
    +  private String tableId;
    +  private SummarizerFactory factory;
    +  private Text startRow = null;
    +  private Text endRow = null;
    +  private Range clipRange;
    +  private Predicate<SummarizerConfiguration> summarySelector;
    +
    +  private TSummaryRequest request;
    +
    +  private String summarizerPattern;
    +
    +  private Set<SummarizerConfiguration> summaries;
    +
    +  public Gatherer(ClientContext context, TSummaryRequest request, AccumuloConfiguration
tableConfig) {
    +    this.ctx = context;
    +    this.tableId = request.tableId;
    +    this.startRow = ByteBufferUtil.toText(request.bounds.startRow);
    +    this.endRow = ByteBufferUtil.toText(request.bounds.endRow);
    +    this.clipRange = new Range(startRow, false, endRow, true);
    +    this.summaries = request.getSummarizers().stream().map(SummarizerConfigurationUtil::fromThrift).collect(Collectors.toSet());
    +    this.request = request;
    +
    +    this.summarizerPattern = request.getSummarizerPattern();
    +
    +    if (summarizerPattern != null) {
    +      Pattern pattern = Pattern.compile(summarizerPattern);
    +      // The way conf is converted to string below is documented in the API, so consider
this when making changes!
    +      summarySelector = conf -> pattern.matcher(conf.getClassName() + " " + new TreeMap<>(conf.getOptions())).matches();
    --- End diff --
    
    Oh my...


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