hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject [04/17] hive git commit: HIVE-17234 Remove HBase metastore from master (Alan Gates, reviewed by Daniel Dai and Sergey Shelukhin)
Date Fri, 04 Aug 2017 21:14:25 GMT
http://git-wip-us.apache.org/repos/asf/hive/blob/5e061557/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsCache.java
----------------------------------------------------------------------
diff --git a/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsCache.java b/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsCache.java
deleted file mode 100644
index c6a134c..0000000
--- a/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsCache.java
+++ /dev/null
@@ -1,316 +0,0 @@
-/**
- * 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.hadoop.hive.metastore.hbase;
-
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.metastore.api.AggrStats;
-import org.apache.hadoop.hive.metastore.api.BooleanColumnStatsData;
-import org.apache.hadoop.hive.metastore.api.ColumnStatistics;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsData;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsDesc;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj;
-import org.apache.hadoop.hive.metastore.api.DoubleColumnStatsData;
-import org.apache.hadoop.hive.metastore.api.FieldSchema;
-import org.apache.hadoop.hive.metastore.api.Partition;
-import org.apache.hadoop.hive.metastore.api.SerDeInfo;
-import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
-import org.apache.hadoop.hive.metastore.api.Table;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TestHBaseAggregateStatsCache {
-  private static final Logger LOG = LoggerFactory.getLogger(TestHBaseAggregateStatsCache.class.getName());
-
-  @Mock HTableInterface htable;
-  private HBaseStore store;
-  SortedMap<String, Cell> rows = new TreeMap<>();
-
-  @Before
-  public void before() throws IOException {
-    MockitoAnnotations.initMocks(this);
-    HiveConf conf = new HiveConf();
-    conf.setBoolean(HBaseReadWrite.NO_CACHE_CONF, true);
-    store = MockUtils.init(conf, htable, rows);
-    store.backdoor().getStatsCache().resetCounters();
-  }
-
-  private static interface Checker {
-    void checkStats(AggrStats aggrStats) throws Exception;
-  }
-
-  // Do to limitations in the Mock infrastructure we use for HBase testing we can only test
-  // this for a single column table and we can't really test hits in hbase, only in memory or
-  // build from scratch.  But it's still useful to cover many bugs.  More in depth testing with
-  // multiple columns and with HBase hits is done in TestHBaseAggrStatsCacheIntegration.
-
-  @Test
-  public void allWithStats() throws Exception {
-    String dbName = "default";
-    String tableName = "hit";
-    List<String> partVals1 = Arrays.asList("today");
-    List<String> partVals2 = Arrays.asList("yesterday");
-    long now = System.currentTimeMillis();
-
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col1", "boolean", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String>emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int)now, (int)now, 0, sd, partCols,
-        Collections.<String, String>emptyMap(), null, null, null);
-    store.createTable(table);
-
-    for (List<String> partVals : Arrays.asList(partVals1, partVals2)) {
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVals.get(0));
-      Partition part = new Partition(partVals, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String>emptyMap());
-      store.addPartition(part);
-
-      ColumnStatistics cs = new ColumnStatistics();
-      ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-      desc.setLastAnalyzed(now);
-      desc.setPartName("ds=" + partVals.get(0));
-      cs.setStatsDesc(desc);
-      ColumnStatisticsObj obj = new ColumnStatisticsObj();
-      obj.setColName("col1");
-      obj.setColType("boolean");
-      ColumnStatisticsData data = new ColumnStatisticsData();
-      BooleanColumnStatsData bcsd = new BooleanColumnStatsData();
-      bcsd.setNumFalses(10);
-      bcsd.setNumTrues(20);
-      bcsd.setNumNulls(30);
-      data.setBooleanStats(bcsd);
-      obj.setStatsData(data);
-      cs.addToStatsObj(obj);
-
-      store.updatePartitionColumnStatistics(cs, partVals);
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(2, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col1", cso.getColName());
-        Assert.assertEquals("boolean", cso.getColType());
-        BooleanColumnStatsData bcsd = cso.getStatsData().getBooleanStats();
-        Assert.assertEquals(20, bcsd.getNumFalses());
-        Assert.assertEquals(40, bcsd.getNumTrues());
-        Assert.assertEquals(60, bcsd.getNumNulls());
-      }
-    };
-
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName,
-        Arrays.asList("ds=today", "ds=yesterday"), Arrays.asList("col1"));
-    statChecker.checkStats(aggrStats);
-
-    // Check that we had to build it from the stats
-    Assert.assertEquals(0, store.backdoor().getStatsCache().hbaseHits.getCnt());
-    Assert.assertEquals(1, store.backdoor().getStatsCache().totalGets.getCnt());
-    Assert.assertEquals(1, store.backdoor().getStatsCache().misses.getCnt());
-
-    // Call again, this time it should come from memory.  Also, reverse the name order this time
-    // to assure that we still hit.
-    aggrStats = store.get_aggr_stats_for(dbName, tableName,
-        Arrays.asList("ds=yesterday", "ds=today"), Arrays.asList("col1"));
-    statChecker.checkStats(aggrStats);
-
-    Assert.assertEquals(0, store.backdoor().getStatsCache().hbaseHits.getCnt());
-    Assert.assertEquals(2, store.backdoor().getStatsCache().totalGets.getCnt());
-    Assert.assertEquals(1, store.backdoor().getStatsCache().misses.getCnt());
-  }
-
-
-  @Test
-  public void noneWithStats() throws Exception {
-    String dbName = "default";
-    String tableName = "nws";
-    List<String> partVals1 = Arrays.asList("today");
-    List<String> partVals2 = Arrays.asList("yesterday");
-    long now = System.currentTimeMillis();
-
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col1", "boolean", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String>emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int)now, (int)now, 0, sd, partCols,
-        Collections.<String, String>emptyMap(), null, null, null);
-    store.createTable(table);
-
-    for (List<String> partVals : Arrays.asList(partVals1, partVals2)) {
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/nws/ds=" + partVals.get(0));
-      Partition part = new Partition(partVals, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String>emptyMap());
-      store.addPartition(part);
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(0, aggrStats.getPartsFound());
-      }
-    };
-
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName,
-        Arrays.asList("ds=today", "ds=yesterday"), Arrays.asList("col1"));
-    statChecker.checkStats(aggrStats);
-  }
-
-  @Test
-  public void someNonexistentPartitions() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    List<String> partVals1 = Arrays.asList("today");
-    List<String> partVals2 = Arrays.asList("yesterday");
-    long now = System.currentTimeMillis();
-
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col1", "boolean", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String>emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int)now, (int)now, 0, sd, partCols,
-        Collections.<String, String>emptyMap(), null, null, null);
-    store.createTable(table);
-
-    StorageDescriptor psd = new StorageDescriptor(sd);
-    psd.setLocation("file:/tmp/default/hit/ds=" + partVals1.get(0));
-    Partition part = new Partition(partVals1, dbName, tableName, (int) now, (int) now, psd,
-        Collections.<String, String>emptyMap());
-    store.addPartition(part);
-
-    ColumnStatistics cs = new ColumnStatistics();
-    ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-    desc.setLastAnalyzed(now);
-    desc.setPartName("ds=" + partVals1.get(0));
-    cs.setStatsDesc(desc);
-    ColumnStatisticsObj obj = new ColumnStatisticsObj();
-    obj.setColName("col1");
-    obj.setColType("double");
-    ColumnStatisticsData data = new ColumnStatisticsData();
-    DoubleColumnStatsData dcsd = new DoubleColumnStatsData();
-    dcsd.setHighValue(1000.2342343);
-    dcsd.setLowValue(-20.1234213423);
-    dcsd.setNumNulls(30);
-    dcsd.setNumDVs(12342);
-    data.setDoubleStats(dcsd);
-    obj.setStatsData(data);
-    cs.addToStatsObj(obj);
-
-    store.updatePartitionColumnStatistics(cs, partVals1);
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(1, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col1", cso.getColName());
-        Assert.assertEquals("double", cso.getColType());
-        DoubleColumnStatsData dcsd = cso.getStatsData().getDoubleStats();
-        Assert.assertEquals(1000.23, dcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-20.12, dcsd.getLowValue(), 0.01);
-        Assert.assertEquals(30, dcsd.getNumNulls());
-        Assert.assertEquals(12342, dcsd.getNumDVs());
-      }
-    };
-
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName,
-        Arrays.asList("ds=today", "ds=yesterday"), Arrays.asList("col1"));
-    statChecker.checkStats(aggrStats);
-
-    // Check that we had to build it from the stats
-    Assert.assertEquals(0, store.backdoor().getStatsCache().hbaseHits.getCnt());
-    Assert.assertEquals(1, store.backdoor().getStatsCache().totalGets.getCnt());
-    Assert.assertEquals(1, store.backdoor().getStatsCache().misses.getCnt());
-
-    // Call again, this time it should come from memory.  Also, reverse the name order this time
-    // to assure that we still hit.
-    aggrStats = store.get_aggr_stats_for(dbName, tableName,
-        Arrays.asList("ds=yesterday", "ds=today"), Arrays.asList("col1"));
-    statChecker.checkStats(aggrStats);
-
-    Assert.assertEquals(0, store.backdoor().getStatsCache().hbaseHits.getCnt());
-    Assert.assertEquals(2, store.backdoor().getStatsCache().totalGets.getCnt());
-    Assert.assertEquals(1, store.backdoor().getStatsCache().misses.getCnt());
-  }
-
-  @Test
-  public void nonexistentPartitions() throws Exception {
-    String dbName = "default";
-    String tableName = "nep";
-    List<String> partVals1 = Arrays.asList("today");
-    List<String> partVals2 = Arrays.asList("yesterday");
-    long now = System.currentTimeMillis();
-
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col1", "boolean", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String>emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int)now, (int)now, 0, sd, partCols,
-        Collections.<String, String>emptyMap(), null, null, null);
-    store.createTable(table);
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(0, aggrStats.getPartsFound());
-      }
-    };
-
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName,
-        Arrays.asList("ds=today", "ds=yesterday"), Arrays.asList("col1"));
-    statChecker.checkStats(aggrStats);
-
-    // Check that we had to build it from the stats
-    Assert.assertEquals(0, store.backdoor().getStatsCache().hbaseHits.getCnt());
-    Assert.assertEquals(1, store.backdoor().getStatsCache().totalGets.getCnt());
-    Assert.assertEquals(1, store.backdoor().getStatsCache().misses.getCnt());
-  }
-  // TODO test invalidation
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/5e061557/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsCacheWithBitVector.java
----------------------------------------------------------------------
diff --git a/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsCacheWithBitVector.java b/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsCacheWithBitVector.java
deleted file mode 100644
index 9cf1fb8..0000000
--- a/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsCacheWithBitVector.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- * 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.hadoop.hive.metastore.hbase;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hive.common.ndv.hll.HyperLogLog;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.metastore.api.AggrStats;
-import org.apache.hadoop.hive.metastore.api.ColumnStatistics;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsData;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsDesc;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj;
-import org.apache.hadoop.hive.metastore.api.DoubleColumnStatsData;
-import org.apache.hadoop.hive.metastore.api.FieldSchema;
-import org.apache.hadoop.hive.metastore.api.Partition;
-import org.apache.hadoop.hive.metastore.api.SerDeInfo;
-import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
-import org.apache.hadoop.hive.metastore.api.Table;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TestHBaseAggregateStatsCacheWithBitVector {
-  private static final Logger LOG = LoggerFactory
-      .getLogger(TestHBaseAggregateStatsCacheWithBitVector.class.getName());
-
-  @Mock
-  HTableInterface htable;
-  private HBaseStore store;
-  SortedMap<String, Cell> rows = new TreeMap<>();
-
-  @Before
-  public void before() throws IOException {
-    MockitoAnnotations.initMocks(this);
-    HiveConf conf = new HiveConf();
-    conf.setBoolean(HBaseReadWrite.NO_CACHE_CONF, true);
-    store = MockUtils.init(conf, htable, rows);
-    store.backdoor().getStatsCache().resetCounters();
-  }
-
-  private static interface Checker {
-    void checkStats(AggrStats aggrStats) throws Exception;
-  }
-
-  @Test
-  public void allPartitions() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    List<String> partVals1 = Arrays.asList("today");
-    List<String> partVals2 = Arrays.asList("yesterday");
-    long now = System.currentTimeMillis();
-
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col1", "boolean", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    StorageDescriptor psd = new StorageDescriptor(sd);
-    psd.setLocation("file:/tmp/default/hit/ds=" + partVals1.get(0));
-    Partition part = new Partition(partVals1, dbName, tableName, (int) now, (int) now, psd,
-        Collections.<String, String> emptyMap());
-    store.addPartition(part);
-
-    psd = new StorageDescriptor(sd);
-    psd.setLocation("file:/tmp/default/hit/ds=" + partVals2.get(0));
-    part = new Partition(partVals2, dbName, tableName, (int) now, (int) now, psd,
-        Collections.<String, String> emptyMap());
-    store.addPartition(part);
-
-    ColumnStatistics cs = new ColumnStatistics();
-    ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-    desc.setLastAnalyzed(now);
-    desc.setPartName("ds=" + partVals1.get(0));
-    cs.setStatsDesc(desc);
-    ColumnStatisticsObj obj = new ColumnStatisticsObj();
-    obj.setColName("col1");
-    obj.setColType("double");
-    ColumnStatisticsData data = new ColumnStatisticsData();
-    DoubleColumnStatsData dcsd = new DoubleColumnStatsData();
-    dcsd.setHighValue(1000.2342343);
-    dcsd.setLowValue(-20.1234213423);
-    dcsd.setNumNulls(30);
-    dcsd.setNumDVs(12342);
-    HyperLogLog hll = HyperLogLog.builder().build();
-    hll.addDouble(1);
-    hll.addDouble(2);
-    hll.addDouble(3);
-    dcsd.setBitVectors(hll.serialize());
-    data.setDoubleStats(dcsd);
-    obj.setStatsData(data);
-    cs.addToStatsObj(obj);
-    store.updatePartitionColumnStatistics(cs, partVals1);
-
-    cs = new ColumnStatistics();
-    desc = new ColumnStatisticsDesc(false, dbName, tableName);
-    desc.setLastAnalyzed(now);
-    desc.setPartName("ds=" + partVals2.get(0));
-    cs.setStatsDesc(desc);
-    obj = new ColumnStatisticsObj();
-    obj.setColName("col1");
-    obj.setColType("double");
-    data = new ColumnStatisticsData();
-    dcsd = new DoubleColumnStatsData();
-    dcsd.setHighValue(1000.2342343);
-    dcsd.setLowValue(-20.1234213423);
-    dcsd.setNumNulls(30);
-    dcsd.setNumDVs(12342);
-    hll = HyperLogLog.builder().build();
-    hll.addDouble(3);
-    hll.addDouble(4);
-    hll.addDouble(5);
-    dcsd.setBitVectors(hll.serialize());
-    data.setDoubleStats(dcsd);
-    obj.setStatsData(data);
-    cs.addToStatsObj(obj);
-
-    store.updatePartitionColumnStatistics(cs, partVals2);
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(2, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col1", cso.getColName());
-        Assert.assertEquals("double", cso.getColType());
-        DoubleColumnStatsData dcsd = cso.getStatsData().getDoubleStats();
-        Assert.assertEquals(1000.23, dcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-20.12, dcsd.getLowValue(), 0.01);
-        Assert.assertEquals(60, dcsd.getNumNulls());
-        Assert.assertEquals(5, dcsd.getNumDVs());
-        // we do not store the bitvector for the aggrStats.
-        // we can store that if it is necessary in the future.
-      }
-    };
-
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName,
-        Arrays.asList("ds=today", "ds=yesterday"), Arrays.asList("col1"));
-    statChecker.checkStats(aggrStats);
-
-    // Check that we had to build it from the stats
-    Assert.assertEquals(0, store.backdoor().getStatsCache().hbaseHits.getCnt());
-    Assert.assertEquals(1, store.backdoor().getStatsCache().totalGets.getCnt());
-    Assert.assertEquals(1, store.backdoor().getStatsCache().misses.getCnt());
-
-    // Call again, this time it should come from memory. Also, reverse the name
-    // order this time
-    // to assure that we still hit.
-    aggrStats = store.get_aggr_stats_for(dbName, tableName,
-        Arrays.asList("ds=yesterday", "ds=today"), Arrays.asList("col1"));
-    statChecker.checkStats(aggrStats);
-
-    Assert.assertEquals(0, store.backdoor().getStatsCache().hbaseHits.getCnt());
-    Assert.assertEquals(2, store.backdoor().getStatsCache().totalGets.getCnt());
-    Assert.assertEquals(1, store.backdoor().getStatsCache().misses.getCnt());
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/5e061557/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsExtrapolation.java
----------------------------------------------------------------------
diff --git a/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsExtrapolation.java b/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsExtrapolation.java
deleted file mode 100644
index 4d868b0..0000000
--- a/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsExtrapolation.java
+++ /dev/null
@@ -1,721 +0,0 @@
-/**
- * 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.hadoop.hive.metastore.hbase;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hive.common.ndv.hll.HyperLogLog;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.metastore.StatObjectConverter;
-import org.apache.hadoop.hive.metastore.api.AggrStats;
-import org.apache.hadoop.hive.metastore.api.ColumnStatistics;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsData;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsDesc;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj;
-import org.apache.hadoop.hive.metastore.api.DecimalColumnStatsData;
-import org.apache.hadoop.hive.metastore.api.DoubleColumnStatsData;
-import org.apache.hadoop.hive.metastore.api.FieldSchema;
-import org.apache.hadoop.hive.metastore.api.LongColumnStatsData;
-import org.apache.hadoop.hive.metastore.api.Partition;
-import org.apache.hadoop.hive.metastore.api.SerDeInfo;
-import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
-import org.apache.hadoop.hive.metastore.api.StringColumnStatsData;
-import org.apache.hadoop.hive.metastore.api.Table;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TestHBaseAggregateStatsExtrapolation {
-  private static final Logger LOG = LoggerFactory
-      .getLogger(TestHBaseAggregateStatsExtrapolation.class.getName());
-
-  @Mock
-  HTableInterface htable;
-  private HBaseStore store;
-  SortedMap<String, Cell> rows = new TreeMap<>();
-
-  // NDV will be 3 for the bitVectors
-  String bitVectors = null;
-  @Before
-  public void before() throws IOException {
-    MockitoAnnotations.initMocks(this);
-    HiveConf conf = new HiveConf();
-    conf.setBoolean(HBaseReadWrite.NO_CACHE_CONF, true);
-    store = MockUtils.init(conf, htable, rows);
-    store.backdoor().getStatsCache().resetCounters();
-    HyperLogLog hll = HyperLogLog.builder().build();
-    hll.addLong(1);
-    hll.addLong(2);
-    hll.addLong(3);
-    bitVectors = hll.serialize();
-  }
-
-  private static interface Checker {
-    void checkStats(AggrStats aggrStats) throws Exception;
-  }
-
-  @Test
-  public void allPartitionsHaveBitVectorStatusLong() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col1", "long", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      ColumnStatistics cs = new ColumnStatistics();
-      ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-      desc.setLastAnalyzed(now);
-      desc.setPartName("ds=" + partVal);
-      cs.setStatsDesc(desc);
-      ColumnStatisticsObj obj = new ColumnStatisticsObj();
-      obj.setColName("col1");
-      obj.setColType("long");
-      ColumnStatisticsData data = new ColumnStatisticsData();
-      LongColumnStatsData dcsd = new LongColumnStatsData();
-      dcsd.setHighValue(1000 + i);
-      dcsd.setLowValue(-1000 - i);
-      dcsd.setNumNulls(i);
-      dcsd.setNumDVs(10 * i + 1);
-      dcsd.setBitVectors(bitVectors);
-      data.setLongStats(dcsd);
-      obj.setStatsData(data);
-      cs.addToStatsObj(obj);
-      store.updatePartitionColumnStatistics(cs, partVal);
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(10, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col1", cso.getColName());
-        Assert.assertEquals("long", cso.getColType());
-        LongColumnStatsData lcsd = cso.getStatsData().getLongStats();
-        Assert.assertEquals(1009, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1009, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(45, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col1"));
-    statChecker.checkStats(aggrStats);
-  }
-
-  @Test
-  public void allPartitionsHaveBitVectorStatusDecimal() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col1_decimal", "decimal", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      ColumnStatistics cs = new ColumnStatistics();
-      ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-      desc.setLastAnalyzed(now);
-      desc.setPartName("ds=" + partVal);
-      cs.setStatsDesc(desc);
-      ColumnStatisticsObj obj = new ColumnStatisticsObj();
-      obj.setColName("col1_decimal");
-      obj.setColType("decimal");
-      ColumnStatisticsData data = new ColumnStatisticsData();
-      DecimalColumnStatsData dcsd = new DecimalColumnStatsData();
-      dcsd.setHighValue(StatObjectConverter.createThriftDecimal("" + (1000 + i)));
-      dcsd.setLowValue(StatObjectConverter.createThriftDecimal("" + (-1000 - i)));
-      dcsd.setNumNulls(i);
-      dcsd.setNumDVs(10 * i + 1);
-      dcsd.setBitVectors(bitVectors);
-      data.setDecimalStats(dcsd);
-      obj.setStatsData(data);
-      cs.addToStatsObj(obj);
-      store.updatePartitionColumnStatistics(cs, partVal);
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(10, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col1_decimal", cso.getColName());
-        Assert.assertEquals("decimal", cso.getColType());
-        DecimalColumnStatsData lcsd = cso.getStatsData().getDecimalStats();
-        Assert.assertEquals(1009, HBaseUtils.getDoubleValue(lcsd.getHighValue()), 0.01);
-        Assert.assertEquals(-1009, HBaseUtils.getDoubleValue(lcsd.getLowValue()), 0.01);
-        Assert.assertEquals(45, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col1_decimal"));
-    statChecker.checkStats(aggrStats);
-  }
-
-  @Test
-  public void allPartitionsHaveBitVectorStatusDouble() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col1_double", "double", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      ColumnStatistics cs = new ColumnStatistics();
-      ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-      desc.setLastAnalyzed(now);
-      desc.setPartName("ds=" + partVal);
-      cs.setStatsDesc(desc);
-      ColumnStatisticsObj obj = new ColumnStatisticsObj();
-      obj.setColName("col1_double");
-      obj.setColType("double");
-      ColumnStatisticsData data = new ColumnStatisticsData();
-      DoubleColumnStatsData dcsd = new DoubleColumnStatsData();
-      dcsd.setHighValue(1000 + i);
-      dcsd.setLowValue(-1000 - i);
-      dcsd.setNumNulls(i);
-      dcsd.setNumDVs(10 * i + 1);
-      dcsd.setBitVectors(bitVectors);
-      data.setDoubleStats(dcsd);
-      obj.setStatsData(data);
-      cs.addToStatsObj(obj);
-      store.updatePartitionColumnStatistics(cs, partVal);
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(10, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col1_double", cso.getColName());
-        Assert.assertEquals("double", cso.getColType());
-        DoubleColumnStatsData lcsd = cso.getStatsData().getDoubleStats();
-        Assert.assertEquals(1009, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1009, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(45, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col1_double"));
-    statChecker.checkStats(aggrStats);
-  }
-  
-  @Test
-  public void allPartitionsHaveBitVectorStatusString() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col1_string", "string", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      ColumnStatistics cs = new ColumnStatistics();
-      ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-      desc.setLastAnalyzed(now);
-      desc.setPartName("ds=" + partVal);
-      cs.setStatsDesc(desc);
-      ColumnStatisticsObj obj = new ColumnStatisticsObj();
-      obj.setColName("col1_string");
-      obj.setColType("string");
-      ColumnStatisticsData data = new ColumnStatisticsData();
-      StringColumnStatsData dcsd = new StringColumnStatsData();
-      dcsd.setAvgColLen(i + 1);
-      dcsd.setMaxColLen(i + 10);
-      dcsd.setNumNulls(i);
-      dcsd.setNumDVs(10 * i + 1);
-      dcsd.setBitVectors(bitVectors);
-      data.setStringStats(dcsd);
-      obj.setStatsData(data);
-      cs.addToStatsObj(obj);
-      store.updatePartitionColumnStatistics(cs, partVal);
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(10, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col1_string", cso.getColName());
-        Assert.assertEquals("string", cso.getColType());
-        StringColumnStatsData lcsd = cso.getStatsData().getStringStats();
-        Assert.assertEquals(10, lcsd.getAvgColLen(), 0.01);
-        Assert.assertEquals(19, lcsd.getMaxColLen(), 0.01);
-        Assert.assertEquals(45, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col1_string"));
-    statChecker.checkStats(aggrStats);
-  }
-
-  @Test
-  public void noPartitionsHaveBitVectorStatus() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col2", "long", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      ColumnStatistics cs = new ColumnStatistics();
-      ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-      desc.setLastAnalyzed(now);
-      desc.setPartName("ds=" + partVal);
-      cs.setStatsDesc(desc);
-      ColumnStatisticsObj obj = new ColumnStatisticsObj();
-      obj.setColName("col2");
-      obj.setColType("long");
-      ColumnStatisticsData data = new ColumnStatisticsData();
-      LongColumnStatsData dcsd = new LongColumnStatsData();
-      dcsd.setHighValue(1000 + i);
-      dcsd.setLowValue(-1000 - i);
-      dcsd.setNumNulls(i);
-      dcsd.setNumDVs(i == 0 ? 1 : 10 * i);
-      data.setLongStats(dcsd);
-      obj.setStatsData(data);
-      cs.addToStatsObj(obj);
-      store.updatePartitionColumnStatistics(cs, partVal);
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(10, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col2", cso.getColName());
-        Assert.assertEquals("long", cso.getColType());
-        LongColumnStatsData lcsd = cso.getStatsData().getLongStats();
-        Assert.assertEquals(1009, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1009, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(45, lcsd.getNumNulls());
-        Assert.assertEquals(90, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col2"));
-    statChecker.checkStats(aggrStats);
-  }
-
-  @Test
-  public void TwoEndsOfPartitionsHaveBitVectorStatus() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col3", "long", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      if (i < 2 || i > 7) {
-        ColumnStatistics cs = new ColumnStatistics();
-        ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-        desc.setLastAnalyzed(now);
-        desc.setPartName("ds=" + partVal);
-        cs.setStatsDesc(desc);
-        ColumnStatisticsObj obj = new ColumnStatisticsObj();
-        obj.setColName("col3");
-        obj.setColType("long");
-        ColumnStatisticsData data = new ColumnStatisticsData();
-        LongColumnStatsData dcsd = new LongColumnStatsData();
-        dcsd.setHighValue(1000 + i);
-        dcsd.setLowValue(-1000 - i);
-        dcsd.setNumNulls(i);
-        dcsd.setNumDVs(10 * i);
-        dcsd.setBitVectors(bitVectors);
-        data.setLongStats(dcsd);
-        obj.setStatsData(data);
-        cs.addToStatsObj(obj);
-        store.updatePartitionColumnStatistics(cs, partVal);
-      }
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(4, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col3", cso.getColName());
-        Assert.assertEquals("long", cso.getColType());
-        LongColumnStatsData lcsd = cso.getStatsData().getLongStats();
-        Assert.assertEquals(1010, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1010, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(45, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col3"));
-    statChecker.checkStats(aggrStats);
-  }
-
-  @Test
-  public void MiddleOfPartitionsHaveBitVectorStatus() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col4", "long", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      if (i > 2 && i < 7) {
-        ColumnStatistics cs = new ColumnStatistics();
-        ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-        desc.setLastAnalyzed(now);
-        desc.setPartName("ds=" + partVal);
-        cs.setStatsDesc(desc);
-        ColumnStatisticsObj obj = new ColumnStatisticsObj();
-        obj.setColName("col4");
-        obj.setColType("long");
-        ColumnStatisticsData data = new ColumnStatisticsData();
-        LongColumnStatsData dcsd = new LongColumnStatsData();
-        dcsd.setHighValue(1000 + i);
-        dcsd.setLowValue(-1000 - i);
-        dcsd.setNumNulls(i);
-        dcsd.setNumDVs(10 * i);
-        dcsd.setBitVectors(bitVectors);
-        data.setLongStats(dcsd);
-        obj.setStatsData(data);
-        cs.addToStatsObj(obj);
-        store.updatePartitionColumnStatistics(cs, partVal);
-      }
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(4, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col4", cso.getColName());
-        Assert.assertEquals("long", cso.getColType());
-        LongColumnStatsData lcsd = cso.getStatsData().getLongStats();
-        Assert.assertEquals(1006, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1006, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(45, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col4"));
-    statChecker.checkStats(aggrStats);
-  }
-
-  @Test
-  public void TwoEndsAndMiddleOfPartitionsHaveBitVectorStatusLong() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col5", "long", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      if (i == 0 || i == 2 || i == 3 || i == 5 || i == 6 || i == 8) {
-        ColumnStatistics cs = new ColumnStatistics();
-        ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-        desc.setLastAnalyzed(now);
-        desc.setPartName("ds=" + partVal);
-        cs.setStatsDesc(desc);
-        ColumnStatisticsObj obj = new ColumnStatisticsObj();
-        obj.setColName("col5");
-        obj.setColType("long");
-        ColumnStatisticsData data = new ColumnStatisticsData();
-        LongColumnStatsData dcsd = new LongColumnStatsData();
-        dcsd.setHighValue(1000 + i);
-        dcsd.setLowValue(-1000 - i);
-        dcsd.setNumNulls(i);
-        dcsd.setNumDVs(10 * i);
-        dcsd.setBitVectors(bitVectors);
-        data.setLongStats(dcsd);
-        obj.setStatsData(data);
-        cs.addToStatsObj(obj);
-        store.updatePartitionColumnStatistics(cs, partVal);
-      }
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(6, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col5", cso.getColName());
-        Assert.assertEquals("long", cso.getColType());
-        LongColumnStatsData lcsd = cso.getStatsData().getLongStats();
-        Assert.assertEquals(1010, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1010, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(40, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col5"));
-    statChecker.checkStats(aggrStats);
-  }
-  
-  @Test
-  public void TwoEndsAndMiddleOfPartitionsHaveBitVectorStatusDouble() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col5_double", "double", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      if (i == 0 || i == 2 || i == 3 || i == 5 || i == 6 || i == 8) {
-        ColumnStatistics cs = new ColumnStatistics();
-        ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-        desc.setLastAnalyzed(now);
-        desc.setPartName("ds=" + partVal);
-        cs.setStatsDesc(desc);
-        ColumnStatisticsObj obj = new ColumnStatisticsObj();
-        obj.setColName("col5_double");
-        obj.setColType("double");
-        ColumnStatisticsData data = new ColumnStatisticsData();
-        DoubleColumnStatsData dcsd = new DoubleColumnStatsData();
-        dcsd.setHighValue(1000 + i);
-        dcsd.setLowValue(-1000 - i);
-        dcsd.setNumNulls(i);
-        dcsd.setNumDVs(10 * i);
-        dcsd.setBitVectors(bitVectors);
-        data.setDoubleStats(dcsd);
-        obj.setStatsData(data);
-        cs.addToStatsObj(obj);
-        store.updatePartitionColumnStatistics(cs, partVal);
-      }
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(6, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col5_double", cso.getColName());
-        Assert.assertEquals("double", cso.getColType());
-        DoubleColumnStatsData lcsd = cso.getStatsData().getDoubleStats();
-        Assert.assertEquals(1010, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1010, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(40, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col5_double"));
-    statChecker.checkStats(aggrStats);
-  }
-}

http://git-wip-us.apache.org/repos/asf/hive/blob/5e061557/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsNDVUniformDist.java
----------------------------------------------------------------------
diff --git a/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsNDVUniformDist.java b/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsNDVUniformDist.java
deleted file mode 100644
index 0ad2780..0000000
--- a/metastore/src/test/org/apache/hadoop/hive/metastore/hbase/TestHBaseAggregateStatsNDVUniformDist.java
+++ /dev/null
@@ -1,589 +0,0 @@
-/**
- * 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.hadoop.hive.metastore.hbase;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hive.common.ndv.hll.HyperLogLog;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.metastore.StatObjectConverter;
-import org.apache.hadoop.hive.metastore.api.AggrStats;
-import org.apache.hadoop.hive.metastore.api.ColumnStatistics;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsData;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsDesc;
-import org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj;
-import org.apache.hadoop.hive.metastore.api.DecimalColumnStatsData;
-import org.apache.hadoop.hive.metastore.api.DoubleColumnStatsData;
-import org.apache.hadoop.hive.metastore.api.FieldSchema;
-import org.apache.hadoop.hive.metastore.api.LongColumnStatsData;
-import org.apache.hadoop.hive.metastore.api.Partition;
-import org.apache.hadoop.hive.metastore.api.SerDeInfo;
-import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
-import org.apache.hadoop.hive.metastore.api.Table;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TestHBaseAggregateStatsNDVUniformDist {
-  private static final Logger LOG = LoggerFactory
-      .getLogger(TestHBaseAggregateStatsNDVUniformDist.class.getName());
-
-  @Mock
-  HTableInterface htable;
-  private HBaseStore store;
-  SortedMap<String, Cell> rows = new TreeMap<>();
-
-  // NDV will be 3 for bitVectors[0] and 1 for bitVectors[1]
-  String bitVectors[] = new String[2];
-    
-
-  @Before
-  public void before() throws IOException {
-    MockitoAnnotations.initMocks(this);
-    HiveConf conf = new HiveConf();
-    conf.setBoolean(HBaseReadWrite.NO_CACHE_CONF, true);
-    conf.setBoolean(HiveConf.ConfVars.HIVE_METASTORE_STATS_NDV_DENSITY_FUNCTION.varname, true);
-    store = MockUtils.init(conf, htable, rows);
-    store.backdoor().getStatsCache().resetCounters();
-    HyperLogLog hll = HyperLogLog.builder().build();
-    hll.addLong(1);
-    bitVectors[1] = hll.serialize();
-    hll = HyperLogLog.builder().build();
-    hll.addLong(2);
-    hll.addLong(3);
-    hll.addLong(3);
-    hll.addLong(4);
-    bitVectors[0] = hll.serialize();
-  }
-
-  private static interface Checker {
-    void checkStats(AggrStats aggrStats) throws Exception;
-  }
-
-  @Test
-  public void allPartitionsHaveBitVectorStatus() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col1", "long", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      ColumnStatistics cs = new ColumnStatistics();
-      ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-      desc.setLastAnalyzed(now);
-      desc.setPartName("ds=" + partVal);
-      cs.setStatsDesc(desc);
-      ColumnStatisticsObj obj = new ColumnStatisticsObj();
-      obj.setColName("col1");
-      obj.setColType("long");
-      ColumnStatisticsData data = new ColumnStatisticsData();
-      LongColumnStatsData dcsd = new LongColumnStatsData();
-      dcsd.setHighValue(1000 + i);
-      dcsd.setLowValue(-1000 - i);
-      dcsd.setNumNulls(i);
-      dcsd.setNumDVs(10 * i + 1);
-      dcsd.setBitVectors(bitVectors[0]);
-      data.setLongStats(dcsd);
-      obj.setStatsData(data);
-      cs.addToStatsObj(obj);
-      store.updatePartitionColumnStatistics(cs, partVal);
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(10, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col1", cso.getColName());
-        Assert.assertEquals("long", cso.getColType());
-        LongColumnStatsData lcsd = cso.getStatsData().getLongStats();
-        Assert.assertEquals(1009, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1009, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(45, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col1"));
-    statChecker.checkStats(aggrStats);
-  }
-
-  @Test
-  public void noPartitionsHaveBitVectorStatus() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col2", "long", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      ColumnStatistics cs = new ColumnStatistics();
-      ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-      desc.setLastAnalyzed(now);
-      desc.setPartName("ds=" + partVal);
-      cs.setStatsDesc(desc);
-      ColumnStatisticsObj obj = new ColumnStatisticsObj();
-      obj.setColName("col2");
-      obj.setColType("long");
-      ColumnStatisticsData data = new ColumnStatisticsData();
-      LongColumnStatsData dcsd = new LongColumnStatsData();
-      dcsd.setHighValue(1000 + i);
-      dcsd.setLowValue(-1000 - i);
-      dcsd.setNumNulls(i);
-      dcsd.setNumDVs(10 * i + 1);
-      data.setLongStats(dcsd);
-      obj.setStatsData(data);
-      cs.addToStatsObj(obj);
-      store.updatePartitionColumnStatistics(cs, partVal);
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(10, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col2", cso.getColName());
-        Assert.assertEquals("long", cso.getColType());
-        LongColumnStatsData lcsd = cso.getStatsData().getLongStats();
-        Assert.assertEquals(1009, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1009, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(45, lcsd.getNumNulls());
-        Assert.assertEquals(91, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col2"));
-    statChecker.checkStats(aggrStats);
-  }
-
-  @Test
-  public void TwoEndsOfPartitionsHaveBitVectorStatus() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col3", "long", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      if (i < 2 || i > 7) {
-        ColumnStatistics cs = new ColumnStatistics();
-        ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-        desc.setLastAnalyzed(now);
-        desc.setPartName("ds=" + partVal);
-        cs.setStatsDesc(desc);
-        ColumnStatisticsObj obj = new ColumnStatisticsObj();
-        obj.setColName("col3");
-        obj.setColType("long");
-        ColumnStatisticsData data = new ColumnStatisticsData();
-        LongColumnStatsData dcsd = new LongColumnStatsData();
-        dcsd.setHighValue(1000 + i);
-        dcsd.setLowValue(-1000 - i);
-        dcsd.setNumNulls(i);
-        dcsd.setNumDVs(10 * i + 1);
-        dcsd.setBitVectors(bitVectors[i / 5]);
-        data.setLongStats(dcsd);
-        obj.setStatsData(data);
-        cs.addToStatsObj(obj);
-        store.updatePartitionColumnStatistics(cs, partVal);
-      }
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(4, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col3", cso.getColName());
-        Assert.assertEquals("long", cso.getColType());
-        LongColumnStatsData lcsd = cso.getStatsData().getLongStats();
-        Assert.assertEquals(1010, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1010, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(45, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col3"));
-    statChecker.checkStats(aggrStats);
-  }
-
-  @Test
-  public void MiddleOfPartitionsHaveBitVectorStatus() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col4", "long", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      if (i > 2 && i < 7) {
-        ColumnStatistics cs = new ColumnStatistics();
-        ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-        desc.setLastAnalyzed(now);
-        desc.setPartName("ds=" + partVal);
-        cs.setStatsDesc(desc);
-        ColumnStatisticsObj obj = new ColumnStatisticsObj();
-        obj.setColName("col4");
-        obj.setColType("long");
-        ColumnStatisticsData data = new ColumnStatisticsData();
-        LongColumnStatsData dcsd = new LongColumnStatsData();
-        dcsd.setHighValue(1000 + i);
-        dcsd.setLowValue(-1000 - i);
-        dcsd.setNumNulls(i);
-        dcsd.setNumDVs(10 * i + 1);
-        dcsd.setBitVectors(bitVectors[0]);
-        data.setLongStats(dcsd);
-        obj.setStatsData(data);
-        cs.addToStatsObj(obj);
-        store.updatePartitionColumnStatistics(cs, partVal);
-      }
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(4, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col4", cso.getColName());
-        Assert.assertEquals("long", cso.getColType());
-        LongColumnStatsData lcsd = cso.getStatsData().getLongStats();
-        Assert.assertEquals(1006, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1006, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(45, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col4"));
-    statChecker.checkStats(aggrStats);
-  }
-
-  @Test
-  public void TwoEndsAndMiddleOfPartitionsHaveBitVectorStatusLong() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col5_long", "long", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      if (i == 0 || i == 2 || i == 3 || i == 5 || i == 6 || i == 8) {
-        ColumnStatistics cs = new ColumnStatistics();
-        ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-        desc.setLastAnalyzed(now);
-        desc.setPartName("ds=" + partVal);
-        cs.setStatsDesc(desc);
-        ColumnStatisticsObj obj = new ColumnStatisticsObj();
-        obj.setColName("col5_long");
-        obj.setColType("long");
-        ColumnStatisticsData data = new ColumnStatisticsData();
-        LongColumnStatsData dcsd = new LongColumnStatsData();
-        dcsd.setHighValue(1000 + i);
-        dcsd.setLowValue(-1000 - i);
-        dcsd.setNumNulls(i);
-        dcsd.setNumDVs(10 * i + 1);
-        dcsd.setBitVectors(bitVectors[i / 5]);
-        data.setLongStats(dcsd);
-        obj.setStatsData(data);
-        cs.addToStatsObj(obj);
-        store.updatePartitionColumnStatistics(cs, partVal);
-      }
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(6, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col5_long", cso.getColName());
-        Assert.assertEquals("long", cso.getColType());
-        LongColumnStatsData lcsd = cso.getStatsData().getLongStats();
-        Assert.assertEquals(1010, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1010, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(40, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col5_long"));
-    statChecker.checkStats(aggrStats);
-  }
-  
-  @Test
-  public void TwoEndsAndMiddleOfPartitionsHaveBitVectorStatusDecimal() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col5_decimal", "decimal", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      if (i == 0 || i == 2 || i == 3 || i == 5 || i == 6 || i == 8) {
-        ColumnStatistics cs = new ColumnStatistics();
-        ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-        desc.setLastAnalyzed(now);
-        desc.setPartName("ds=" + partVal);
-        cs.setStatsDesc(desc);
-        ColumnStatisticsObj obj = new ColumnStatisticsObj();
-        obj.setColName("col5_decimal");
-        obj.setColType("decimal");
-        ColumnStatisticsData data = new ColumnStatisticsData();
-        DecimalColumnStatsData dcsd = new DecimalColumnStatsData();
-        dcsd.setHighValue(StatObjectConverter.createThriftDecimal("" + (1000 + i)));
-        dcsd.setLowValue(StatObjectConverter.createThriftDecimal("" + (-1000 - i)));
-        dcsd.setNumNulls(i);
-        dcsd.setNumDVs(10 * i + 1);
-        dcsd.setBitVectors(bitVectors[i / 5]);
-        data.setDecimalStats(dcsd);
-        obj.setStatsData(data);
-        cs.addToStatsObj(obj);
-        store.updatePartitionColumnStatistics(cs, partVal);
-      }
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(6, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col5_decimal", cso.getColName());
-        Assert.assertEquals("decimal", cso.getColType());
-        DecimalColumnStatsData lcsd = cso.getStatsData().getDecimalStats();
-        Assert.assertEquals(1010, HBaseUtils.getDoubleValue(lcsd.getHighValue()), 0.01);
-        Assert.assertEquals(-1010, HBaseUtils.getDoubleValue(lcsd.getLowValue()), 0.01);
-        Assert.assertEquals(40, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col5_decimal"));
-    statChecker.checkStats(aggrStats);
-  }
-
-  @Test
-  public void TwoEndsAndMiddleOfPartitionsHaveBitVectorStatusDouble() throws Exception {
-    String dbName = "default";
-    String tableName = "snp";
-    long now = System.currentTimeMillis();
-    List<FieldSchema> cols = new ArrayList<>();
-    cols.add(new FieldSchema("col5_double", "double", "nocomment"));
-    SerDeInfo serde = new SerDeInfo("serde", "seriallib", null);
-    StorageDescriptor sd = new StorageDescriptor(cols, "file:/tmp", "input", "output", false, 0,
-        serde, null, null, Collections.<String, String> emptyMap());
-    List<FieldSchema> partCols = new ArrayList<>();
-    partCols.add(new FieldSchema("ds", "string", ""));
-    Table table = new Table(tableName, dbName, "me", (int) now, (int) now, 0, sd, partCols,
-        Collections.<String, String> emptyMap(), null, null, null);
-    store.createTable(table);
-
-    List<List<String>> partVals = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      List<String> partVal = Arrays.asList("" + i);
-      partVals.add(partVal);
-      StorageDescriptor psd = new StorageDescriptor(sd);
-      psd.setLocation("file:/tmp/default/hit/ds=" + partVal);
-      Partition part = new Partition(partVal, dbName, tableName, (int) now, (int) now, psd,
-          Collections.<String, String> emptyMap());
-      store.addPartition(part);
-      if (i == 0 || i == 2 || i == 3 || i == 5 || i == 6 || i == 8) {
-        ColumnStatistics cs = new ColumnStatistics();
-        ColumnStatisticsDesc desc = new ColumnStatisticsDesc(false, dbName, tableName);
-        desc.setLastAnalyzed(now);
-        desc.setPartName("ds=" + partVal);
-        cs.setStatsDesc(desc);
-        ColumnStatisticsObj obj = new ColumnStatisticsObj();
-        obj.setColName("col5_double");
-        obj.setColType("double");
-        ColumnStatisticsData data = new ColumnStatisticsData();
-        DoubleColumnStatsData dcsd = new DoubleColumnStatsData();
-        dcsd.setHighValue(1000 + i);
-        dcsd.setLowValue(-1000 - i);
-        dcsd.setNumNulls(i);
-        dcsd.setNumDVs(10 * i + 1);
-        dcsd.setBitVectors(bitVectors[i / 5]);
-        data.setDoubleStats(dcsd);
-        obj.setStatsData(data);
-        cs.addToStatsObj(obj);
-        store.updatePartitionColumnStatistics(cs, partVal);
-      }
-    }
-
-    Checker statChecker = new Checker() {
-      @Override
-      public void checkStats(AggrStats aggrStats) throws Exception {
-        Assert.assertEquals(6, aggrStats.getPartsFound());
-        Assert.assertEquals(1, aggrStats.getColStatsSize());
-        ColumnStatisticsObj cso = aggrStats.getColStats().get(0);
-        Assert.assertEquals("col5_double", cso.getColName());
-        Assert.assertEquals("double", cso.getColType());
-        DoubleColumnStatsData lcsd = cso.getStatsData().getDoubleStats();
-        Assert.assertEquals(1010, lcsd.getHighValue(), 0.01);
-        Assert.assertEquals(-1010, lcsd.getLowValue(), 0.01);
-        Assert.assertEquals(40, lcsd.getNumNulls());
-        Assert.assertEquals(3, lcsd.getNumDVs());
-      }
-    };
-    List<String> partNames = new ArrayList<>();
-    for (int i = 0; i < 10; i++) {
-      partNames.add("ds=" + i);
-    }
-    AggrStats aggrStats = store.get_aggr_stats_for(dbName, tableName, partNames,
-        Arrays.asList("col5_double"));
-    statChecker.checkStats(aggrStats);
-  }
-}


Mime
View raw message