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 #168: ACCUMULO-4501 (work in progress) Very simple imp...
Date Mon, 17 Oct 2016 14:22:55 GMT
Github user joshelser commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/168#discussion_r83653920
  
    --- Diff: core/src/main/java/org/apache/accumulo/core/file/rfile/histogram/HashMapVisibilityHistogram.java
---
    @@ -0,0 +1,141 @@
    +/*
    + * 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.file.rfile.histogram;
    +
    +import java.io.DataInput;
    +import java.io.DataOutput;
    +import java.io.IOException;
    +import java.util.AbstractMap;
    +import java.util.HashMap;
    +import java.util.Iterator;
    +import java.util.Map.Entry;
    +import java.util.Objects;
    +import java.util.concurrent.atomic.AtomicLong;
    +
    +import org.apache.accumulo.core.data.Key;
    +import org.apache.hadoop.io.Text;
    +
    +import com.google.common.base.Function;
    +import com.google.common.collect.Iterators;
    +
    +/**
    + * A basic unbounded hash map implementation.
    + */
    +public class HashMapVisibilityHistogram implements VisibilityHistogram {
    +
    +  private HashMap<Text,AtomicLong> histogram;
    +  private ThreadLocal<Text> buffer = new ThreadLocal<Text>() {
    +    @Override public Text initialValue() {
    +      return new Text();
    +    }
    +  };
    +
    +  public HashMapVisibilityHistogram() {
    +    this.histogram = new HashMap<>();
    +  }
    +
    +  @Override
    +  public long increment(Key k) {
    +    final Text t = buffer.get();
    +    Objects.requireNonNull(k.getColumnVisibility(t));
    +    AtomicLong count = histogram.get(t);
    --- End diff --
    
    I don't think it would be needed. Using something faster would probably be better.
    
    Sam applies to using an unbounded HashMap for storage (e.g. handling tables with 100's
to 1000's of visibilities per file).


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