Merge pull request #29 from DataSketches/code-and-docs-cleanup

cleanup
diff --git a/src/main/java/com/yahoo/sketches/hive/frequencies/package-info.java b/src/main/java/com/yahoo/sketches/hive/frequencies/package-info.java
index 3369bc8..32bb574 100644
--- a/src/main/java/com/yahoo/sketches/hive/frequencies/package-info.java
+++ b/src/main/java/com/yahoo/sketches/hive/frequencies/package-info.java
@@ -4,16 +4,12 @@
  */
 
 /**
- * <p>This package is dedicated to streaming algorithms that enable estimation of the
- * frequency of occurence of items in a weighted multiset stream of items.
- * If the frequency distribution of items is sufficiently skewed, these algorithms are very
- * useful in identifying the "Heavy Hitters" that occured most frequently in the stream.
- * The accuracy of the estimation of the frequency of an item has well understood error
- * bounds that can be returned by the sketch.</p>
+ * Hive UDFs for Frequent Items sketch.
+ * This includes generic implementation in the form of abstract classed DataToItemsSketchUDAF
+ * and UnionItemsSketchUDAF to be specialized for particular types of items.
+ * An implementation for strings is provided: DataToStringsSketchUDAF and UnionStringsSketchUDAF.
+ * GetFrequentItemsFromStringsSketchUDTF is to obtain results from sketches.
  *
- * <p>These sketches are mergable and can be serialized and deserialized to/from a compact
- * form.</p>
- *
- * @author Lee Rhodes
+ * @author Alexander Saydakov
  */
 package com.yahoo.sketches.hive.frequencies;
diff --git a/src/main/java/com/yahoo/sketches/hive/quantiles/package-info.java b/src/main/java/com/yahoo/sketches/hive/quantiles/package-info.java
index f1f0ab3..7fe33a8 100644
--- a/src/main/java/com/yahoo/sketches/hive/quantiles/package-info.java
+++ b/src/main/java/com/yahoo/sketches/hive/quantiles/package-info.java
@@ -4,10 +4,18 @@
  */
 
 /**
- * <p>The quantiles package contains stochastic streaming algorithms that enable single-pass
- * analysis of the distribution of a stream of real (double) values or generic items.
- * </p>
+ * Hive UDFs for Quantiles sketches.
+ * This includes UDFs for generic ItemsSketch and specialized DoublesSketch.
+ * 
+ * <p>The generic implementation is in the form of abstract classes DataToItemsSketchUDAF and
+ * UnionItemsSketchUDAF to be specialized for particular types of items.
+ * An implementation for strings is provided: DataToStringsSketchUDAF, UnionStringsSketchUDAF,
+ * plus UDFs to obtain the results from sketches:
+ * GetQuantileFromStringsSketchUDF, GetQuantilesFromStringsSketchUDF and GetPmfFromStringsSketchUDF.
+ * 
+ * <p>Support for DoublesSketch: DataToDoublesSketchUDAF, UnionDoublesSketchUDAF,
+ * GetQuantileFromDoublesSketchUDF, GetQuantilesFromDoublesSketchUDF, GetPmfFromDoublesSketchUDF
  *
- * @author Lee Rhodes
+ * @author Alexander Saydakov
  */
 package com.yahoo.sketches.hive.quantiles;
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/DataToSketchUDAF.java b/src/main/java/com/yahoo/sketches/hive/theta/DataToSketchUDAF.java
index 91465bd..aabcb96 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/DataToSketchUDAF.java
+++ b/src/main/java/com/yahoo/sketches/hive/theta/DataToSketchUDAF.java
@@ -153,10 +153,9 @@
             PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY)
           )
         );
-      } else {
-        // final results include just the sketch
-        return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
       }
+      // final results include just the sketch
+      return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
     }
 
     /*
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAF.java b/src/main/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAF.java
index 9efbcee..177e7fa 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAF.java
+++ b/src/main/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAF.java
@@ -98,11 +98,9 @@
               .getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY)
           )
         );
-      } else {
-        // final results include just the sketch
-        return PrimitiveObjectInspectorFactory
-            .getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
       }
+      // final results include just the sketch
+      return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
     }
 
     @Override
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/UnionSketchUDAF.java b/src/main/java/com/yahoo/sketches/hive/theta/UnionSketchUDAF.java
index 7c3e244..55f943e 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/UnionSketchUDAF.java
+++ b/src/main/java/com/yahoo/sketches/hive/theta/UnionSketchUDAF.java
@@ -29,8 +29,7 @@
 import com.yahoo.memory.Memory;
 
 /**
- * Hive Generic UDAF Resolver Class for MergeSketchUDAF.
- *
+ * Hive UDAF to compute union of theta Sketch objects
  */
 @Description(
     name = "unionSketch",
@@ -127,10 +126,9 @@
             PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY)
           )
         );
-      } else {
-        // final results include just the sketch
-        return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
       }
+      // final results include just the sketch
+      return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
     }
 
     /**
diff --git a/src/main/java/com/yahoo/sketches/hive/theta/package-info.java b/src/main/java/com/yahoo/sketches/hive/theta/package-info.java
index b7d1af8..d66c7fd 100644
--- a/src/main/java/com/yahoo/sketches/hive/theta/package-info.java
+++ b/src/main/java/com/yahoo/sketches/hive/theta/package-info.java
@@ -4,13 +4,9 @@
  */
 
 /**
- * <p>The theta package contains all the sketch classes that are members of the
- * <a href="https://github.com/DataSketches/DataSketches.github.io/blob/master/docs/pdf/ThetaSketchFramework.pdf">Theta Sketch Framework</a>.
- * The basic sketching functionality in this package is also
- * accessible from Hadoop Pig UDFs found in the <i>sketches-pig</i> repository,
- * and from Hadoop Hive UADFs and UDFs found in the <i>sketches-hive</i> repository.
- * </p>
+ * Hive UDFs and UDAFs for Theta sketch.
  *
- * @author Lee Rhodes
+ * @author Will Lauer
+ * @author Alexander Saydakov
  */
 package com.yahoo.sketches.hive.theta;
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTF.java b/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTF.java
index 05b0608..f182058 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTF.java
+++ b/src/main/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTF.java
@@ -1,3 +1,7 @@
+/*
+ * Copyright 2016, Yahoo! Inc.
+ * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ */
 package com.yahoo.sketches.hive.tuple;
 
 import java.util.ArrayList;
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/DataToArrayOfDoublesSketchUDAF.java b/src/main/java/com/yahoo/sketches/hive/tuple/DataToArrayOfDoublesSketchUDAF.java
index a5a9950..d98e35c 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/DataToArrayOfDoublesSketchUDAF.java
+++ b/src/main/java/com/yahoo/sketches/hive/tuple/DataToArrayOfDoublesSketchUDAF.java
@@ -128,10 +128,9 @@
             PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY)
           )
         );
-      } else {
-        // final results include just the sketch
-        return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
       }
+      // final results include just the sketch
+      return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
     }
 
     @Override
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/DataToDoubleSummaryWithModeSketchUDAF.java b/src/main/java/com/yahoo/sketches/hive/tuple/DataToDoubleSummaryWithModeSketchUDAF.java
index d5e0eb4..1d6670f 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/DataToDoubleSummaryWithModeSketchUDAF.java
+++ b/src/main/java/com/yahoo/sketches/hive/tuple/DataToDoubleSummaryWithModeSketchUDAF.java
@@ -103,9 +103,8 @@
             PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY)
           )
         );
-      } else {
-        return resultInspector;
       }
+      return resultInspector;
     }
 
     @Override
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/DataToSketchUDAF.java b/src/main/java/com/yahoo/sketches/hive/tuple/DataToSketchUDAF.java
index dedc482..74f511e 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/DataToSketchUDAF.java
+++ b/src/main/java/com/yahoo/sketches/hive/tuple/DataToSketchUDAF.java
@@ -109,7 +109,7 @@
       }
 
       if (mode == Mode.PARTIAL1 || mode == Mode.PARTIAL2) {
-        // intermediate results need to include the the nominal number of entries
+        // intermediate results need to include the nominal number of entries
         return ObjectInspectorFactory.getStandardStructObjectInspector(
           Arrays.asList(NOMINAL_NUM_ENTRIES_FIELD, SKETCH_FIELD),
           Arrays.asList(
@@ -117,10 +117,9 @@
             PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY)
           )
         );
-      } else {
-        // final results include just the sketch
-        return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
       }
+      // final results include just the sketch
+      return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
     }
 
     @Override
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/DoubleSummarySketchToEstimatesUDF.java b/src/main/java/com/yahoo/sketches/hive/tuple/DoubleSummarySketchToEstimatesUDF.java
index de774bb..47c1b3a 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/DoubleSummarySketchToEstimatesUDF.java
+++ b/src/main/java/com/yahoo/sketches/hive/tuple/DoubleSummarySketchToEstimatesUDF.java
@@ -31,7 +31,7 @@
 
   /**
    * Get estimates from a given Sketch&lt;DoubleSummary&gt;
-   * @param serializedSketch DoubleSummarySketch in as serialized binary
+   * @param serializedSketch DoubleSummarySketch in a serialized binary form
    * @return list of estimates
    */
   public List<Double> evaluate(final BytesWritable serializedSketch) {
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/UnionArrayOfDoublesSketchUDAF.java b/src/main/java/com/yahoo/sketches/hive/tuple/UnionArrayOfDoublesSketchUDAF.java
index 0f08333..d42e3f3 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/UnionArrayOfDoublesSketchUDAF.java
+++ b/src/main/java/com/yahoo/sketches/hive/tuple/UnionArrayOfDoublesSketchUDAF.java
@@ -101,10 +101,9 @@
             PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY)
           )
         );
-      } else {
-        // final results include just the sketch
-        return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
       }
+      // final results include just the sketch
+      return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
     }
 
     @Override
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/UnionDoubleSummaryWithModeSketchUDAF.java b/src/main/java/com/yahoo/sketches/hive/tuple/UnionDoubleSummaryWithModeSketchUDAF.java
index 5d1020b..10efccc 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/UnionDoubleSummaryWithModeSketchUDAF.java
+++ b/src/main/java/com/yahoo/sketches/hive/tuple/UnionDoubleSummaryWithModeSketchUDAF.java
@@ -92,9 +92,8 @@
             PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY)
           )
         );
-      } else {
-        return resultInspector;
       }
+      return resultInspector;
     }
 
     @Override
diff --git a/src/main/java/com/yahoo/sketches/hive/tuple/UnionSketchUDAF.java b/src/main/java/com/yahoo/sketches/hive/tuple/UnionSketchUDAF.java
index fd687dc..3936e08 100644
--- a/src/main/java/com/yahoo/sketches/hive/tuple/UnionSketchUDAF.java
+++ b/src/main/java/com/yahoo/sketches/hive/tuple/UnionSketchUDAF.java
@@ -95,10 +95,9 @@
             PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY)
           )
         );
-      } else {
-        // final results include just the sketch
-        return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
       }
+      // final results include just the sketch
+      return PrimitiveObjectInspectorFactory.getPrimitiveWritableObjectInspector(PrimitiveCategory.BINARY);
     }
 
     @Override
diff --git a/src/test/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAFTest.java b/src/test/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAFTest.java
index 6669adb..1061113 100644
--- a/src/test/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAFTest.java
+++ b/src/test/java/com/yahoo/sketches/hive/theta/IntersectSketchUDAFTest.java
@@ -1,3 +1,7 @@
+/*******************************************************************************
+ * Copyright 2015, Yahoo Inc.
+ * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ *******************************************************************************/
 package com.yahoo.sketches.hive.theta;
 
 import static com.yahoo.sketches.Util.DEFAULT_UPDATE_SEED;
diff --git a/src/test/java/com/yahoo/sketches/hive/theta/UnionSketchUDFTest.java b/src/test/java/com/yahoo/sketches/hive/theta/UnionSketchUDFTest.java
index dbe7682..054d0c0 100644
--- a/src/test/java/com/yahoo/sketches/hive/theta/UnionSketchUDFTest.java
+++ b/src/test/java/com/yahoo/sketches/hive/theta/UnionSketchUDFTest.java
@@ -54,7 +54,7 @@
 
     Sketch result = Sketches.wrapSketch(Memory.wrap(output.getBytes()));
 
-    Assert.assertEquals(256.0, result.getEstimate());
+    Assert.assertEquals(result.getEstimate(), 256.0);
   }
 
   @Test
@@ -79,7 +79,7 @@
 
     Sketch result = Sketches.wrapSketch(Memory.wrap(output.getBytes()), seed);
 
-    Assert.assertEquals(256.0, result.getEstimate(), 256 * 0.02);
+    Assert.assertEquals(result.getEstimate(), 256.0, 256 * 0.02);
     Assert.assertTrue(result.getRetainedEntries(true) <= 128.0);
   }
 
diff --git a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTFTest.java b/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTFTest.java
index c2ffde3..3ba2709 100644
--- a/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTFTest.java
+++ b/src/test/java/com/yahoo/sketches/hive/tuple/ArrayOfDoublesSketchToValuesUDTFTest.java
@@ -1,3 +1,7 @@
+/*
+ * Copyright 2016, Yahoo! Inc.
+ * Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
+ */
 package com.yahoo.sketches.hive.tuple;
 
 import java.util.ArrayList;