accumulo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ACCUMULO-3913) Add per table sampling
Date Wed, 09 Sep 2015 20:49:45 GMT

    [ https://issues.apache.org/jira/browse/ACCUMULO-3913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14737561#comment-14737561
] 

ASF GitHub Bot commented on ACCUMULO-3913:
------------------------------------------

Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/46#discussion_r39094345
  
    --- Diff: core/src/main/java/org/apache/accumulo/core/sample/impl/SamplerConfigurationImpl.java
---
    @@ -0,0 +1,181 @@
    +/*
    + * 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.sample.impl;
    +
    +import java.io.DataInput;
    +import java.io.DataOutput;
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.Collections;
    +import java.util.HashMap;
    +import java.util.LinkedHashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Map.Entry;
    +
    +import org.apache.accumulo.core.client.admin.SamplerConfiguration;
    +import org.apache.accumulo.core.conf.AccumuloConfiguration;
    +import org.apache.accumulo.core.conf.Property;
    +import org.apache.accumulo.core.tabletserver.thrift.TSamplerConfiguration;
    +import org.apache.accumulo.core.util.Pair;
    +import org.apache.hadoop.io.Writable;
    +
    +public class SamplerConfigurationImpl implements Writable {
    +  private String className;
    +  private Map<String,String> options;
    +
    +  public SamplerConfigurationImpl(DataInput in) throws IOException {
    +    readFields(in);
    +  }
    +
    +  public SamplerConfigurationImpl(SamplerConfiguration sc) {
    +    this.className = sc.getSamplerClassName();
    +    this.options = new HashMap<>(sc.getOptions());
    +  }
    +
    +  public SamplerConfigurationImpl(String className, Map<String,String> options)
{
    +    this.className = className;
    +    this.options = options;
    +  }
    +
    +  public SamplerConfigurationImpl() {}
    +
    +  public String getClassName() {
    +    return className;
    +  }
    +
    +  public Map<String,String> getOptions() {
    +    return Collections.unmodifiableMap(options);
    +  }
    +
    +  @Override
    +  public int hashCode() {
    +    return 31 * className.hashCode() + options.hashCode();
    +  }
    +
    +  @Override
    +  public boolean equals(Object o) {
    +    if (o instanceof SamplerConfigurationImpl) {
    +      SamplerConfigurationImpl osc = (SamplerConfigurationImpl) o;
    +
    +      return className.equals(osc.className) && options.equals(osc.options);
    +    }
    +
    +    return false;
    +  }
    +
    +  @Override
    +  public void write(DataOutput out) throws IOException {
    --- End diff --
    
    > it just gives me pause (some of the RPC incompatibilities introduced between Thrift
0.9.0 and 0.9.1 are what make me hesitate)
    
    I don't think we ever had problems with Thrift messages being incompatible, did we? RFile
having a "thrift" dependency is a valid point, just not for worry about backwards compatibility
IMO.
    
    Either way, the root of the reason I brought it up is that we have 2 different serializations
for this class. That's a smell to me. I have no stake besides the opinion that we should have
one and not many serializations. :)


> Add per table sampling
> ----------------------
>
>                 Key: ACCUMULO-3913
>                 URL: https://issues.apache.org/jira/browse/ACCUMULO-3913
>             Project: Accumulo
>          Issue Type: Improvement
>            Reporter: Keith Turner
>             Fix For: 1.8.0
>
>
> I am working on prototyping adding hash based sampling to Accumulo.  I am trying to accomplish
the following goals in the prototype.
>   # Have each RFile store a sample per locality group.  Also store the configuration
used to generate the sample.
>   # Use sampling functions that ensure the same row columns exist across the samples
in all RFiles. Hash mod is a good candidate that gives a random sample that's consistent across
files.
>   # Have scanners support scanning RFile's samples sets.  Scan should fail if RFiles
have different sample configuration.  Different sampling config implies the RFile's sample
sets contain a possibly disjoint set of row columns.
>   # Support generating sample data for RFiles generated for bulk import
>   # Support sample data in the memory map
>   # Support enabling and disabling sampling per table AND configuring a sample function.
> I am currently using the following function in my prototype to determine what data an
RFile stores in its sample set.  This code will always select same subset of rows for each
RFile's sample set.  I have not yet made the function configurable.
> {code:java}
> public class RowSampler implements Sampler {
>   private HashFunction hasher = Hashing.murmur3_32();
>   @Override
>   public boolean accept(Key k) {
>     ByteSequence row = k.getRowData();
>     HashCode hc = hasher.hashBytes(row.getBackingArray(), row.offset(), row.length());
>     return hc.asInt() % 1009 == 0;
>   }
> }
> {code}
> Although not yet implemented, the divisor in this RowSample could be configurable. RFiles
with sample data would store the fact that a RowSample with a divisor of 1009 was used to
generate sample data.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message