Skip to content
Permalink
Browse files
minor style issues, update POM
  • Loading branch information
leerho committed Apr 25, 2019
1 parent ab5d9dd commit 82eecfb51c42c2068d904593248a9bc4a24b6f3d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
@@ -145,7 +145,7 @@
<dependency>
<groupId>com.yahoo.datasketches</groupId>
<artifactId>sketches-core</artifactId>
<version>0.13.0</version>
<version>0.13.1</version>
</dependency>

<!-- Pig -->
@@ -21,7 +21,7 @@
* operation. It will receive a bag of values returned by either the <i>Intermediate</i>
* stage or the <i>Initial</i> stages, so it needs to be able to differentiate between and
* interpret both types.
*
*
* @author Alexander Saydakov
*/
abstract class AlgebraicFinal extends EvalFunc<DataByteArray> {
@@ -55,8 +55,9 @@ public DataByteArray exec(final Tuple inputTuple) throws IOException {
return dba;
}

static DataByteArray process(final Tuple inputTuple, final int lgK, final long seed, boolean isInputRaw) throws IOException {
if (inputTuple == null || inputTuple.size() == 0) {
static DataByteArray process(final Tuple inputTuple, final int lgK, final long seed,
final boolean isInputRaw) throws IOException {
if ((inputTuple == null) || (inputTuple.size() == 0)) {
return null;
}
CpcSketch sketch = null;
@@ -102,7 +103,7 @@ static DataByteArray process(final Tuple inputTuple, final int lgK, final long s
+ f0.getClass().getName());
}
}
if (sketch != null && union != null) {
if ((sketch != null) && (union != null)) {
union.update(sketch);
sketch = null;
}
@@ -21,7 +21,7 @@
* and from a reducer). It will receive a bag of values returned by either <i>Intermediate</i>
* or <i>Initial</i> stages, so it needs to be able to differentiate between and
* interpret both types.
*
*
* @author Alexander Saydakov
*/
abstract class AlgebraicIntermediate extends EvalFunc<Tuple> {
@@ -37,7 +37,7 @@ abstract class AlgebraicIntermediate extends EvalFunc<Tuple> {
* Constructor with primitives for the intermediate pass of an Algebraic function.
*
* @param lgK parameter controlling the sketch size and accuracy
* @param seed
* @param seed the given seed
*/
public AlgebraicIntermediate(final int lgK, final long seed) {
lgK_ = lgK;
@@ -20,7 +20,8 @@

/**
* This UDF is to build sketches from data.
* This class implements both the <i>Accumulator</i> and <i>Algebraic</i> interfaces for performance optimization.
* This class implements both the <i>Accumulator</i> and <i>Algebraic</i> interfaces for
* performance optimization.
*/
public class DataToSketch extends EvalFunc<DataByteArray> implements Accumulator<DataByteArray>, Algebraic {

@@ -111,7 +112,7 @@ private DataToSketch(final int k) {
public DataByteArray exec(final Tuple inputTuple) throws IOException {
//The exec is a stateless function. It operates on the input and returns a result.
final KllFloatsSketch sketch = new KllFloatsSketch(k_);
if (inputTuple != null && inputTuple.size() > 0) {
if ((inputTuple != null) && (inputTuple.size() > 0)) {
final DataBag bag = (DataBag) inputTuple.get(0);
for (final Tuple innerTuple: bag) {
sketch.update((Float) innerTuple.get(0));
@@ -134,7 +135,7 @@ public DataByteArray exec(final Tuple inputTuple) throws IOException {
*/
@Override
public void accumulate(final Tuple inputTuple) throws IOException {
if (inputTuple == null || inputTuple.size() == 0) { return; }
if ((inputTuple == null) || (inputTuple.size() == 0)) { return; }
final DataBag bag = (DataBag) inputTuple.get(0);
if (bag == null) { return; }
if (accumSketch_ == null) {
@@ -312,7 +313,7 @@ public DataByteArray exec(final Tuple inputTuple) throws IOException {

private static DataByteArray process(final Tuple inputTuple, final int k) throws IOException {
final KllFloatsSketch sketch = new KllFloatsSketch(k);
if (inputTuple != null && inputTuple.size() > 0) {
if ((inputTuple != null) && (inputTuple.size() > 0)) {
final DataBag outerBag = (DataBag) inputTuple.get(0);
for (final Tuple dataTuple: outerBag) {
final Object f0 = dataTuple.get(0);
@@ -21,9 +21,11 @@

/**
* This UDF is to merge sketches.
* This class implements both the <i>Accumulator</i> and <i>Algebraic</i> interfaces for performance optimization.
* This class implements both the <i>Accumulator</i> and <i>Algebraic</i> interfaces for
* performance optimization.
*/
public class UnionSketch extends EvalFunc<DataByteArray> implements Accumulator<DataByteArray>, Algebraic {
public class UnionSketch extends EvalFunc<DataByteArray>
implements Accumulator<DataByteArray>, Algebraic {

private static final TupleFactory TUPLE_FACTORY_ = TupleFactory.getInstance();

@@ -102,7 +104,7 @@ private UnionSketch(final int k) {
public DataByteArray exec(final Tuple inputTuple) throws IOException {
//The exec is a stateless function. It operates on the input and returns a result.
final KllFloatsSketch sketch = new KllFloatsSketch(k_);
if (inputTuple != null && inputTuple.size() > 0) {
if ((inputTuple != null) && (inputTuple.size() > 0)) {
final DataBag bag = (DataBag) inputTuple.get(0);
updateUnion(bag, sketch);
}
@@ -113,8 +115,8 @@ public DataByteArray exec(final Tuple inputTuple) throws IOException {

/**
* An <i>Accumulator</i> version of the standard <i>exec()</i> method. Like <i>exec()</i>,
* accumulator is called with a bag of Sketch Tuples. Unlike <i>exec()</i>, it doesn't serialize the
* sketch at the end. Instead, it can be called multiple times, each time with another bag of
* accumulator is called with a bag of Sketch Tuples. Unlike <i>exec()</i>, it doesn't serialize
* the sketch at the end. Instead, it can be called multiple times, each time with another bag of
* Sketch Tuples to be input to the Union.
*
* @param inputTuple A tuple containing a single bag, containing Sketch Tuples.
@@ -124,7 +126,7 @@ public DataByteArray exec(final Tuple inputTuple) throws IOException {
*/
@Override
public void accumulate(final Tuple inputTuple) throws IOException {
if (inputTuple == null || inputTuple.size() == 0) { return; }
if ((inputTuple == null) || (inputTuple.size() == 0)) { return; }
final DataBag bag = (DataBag) inputTuple.get(0);
if (bag == null) { return; }
if (accumSketch_ == null) {
@@ -183,7 +185,8 @@ public String getFinal() {
* @param bag A bag of sketchTuples.
* @param union The union to update
*/
private static void updateUnion(final DataBag bag, final KllFloatsSketch union) throws ExecException {
private static void updateUnion(final DataBag bag, final KllFloatsSketch union)
throws ExecException {
for (Tuple innerTuple: bag) {
final Object f0 = innerTuple.get(0);
if (f0 == null) { continue; }
@@ -193,7 +196,8 @@ private static void updateUnion(final DataBag bag, final KllFloatsSketch union)
union.merge(KllFloatsSketch.heapify(Memory.wrap(dba.get())));
}
} else {
throw new IllegalArgumentException("Field type was not DataType.BYTEARRAY: " + innerTuple.getType(0));
throw new IllegalArgumentException("Field type was not DataType.BYTEARRAY: "
+ innerTuple.getType(0));
}
}
}
@@ -322,7 +326,7 @@ public DataByteArray exec(final Tuple inputTuple) throws IOException {

private static DataByteArray process(final Tuple inputTuple, final int k) throws IOException {
final KllFloatsSketch union = new KllFloatsSketch(k);
if (inputTuple != null && inputTuple.size() > 0) {
if ((inputTuple != null) && (inputTuple.size() > 0)) {
final DataBag outerBag = (DataBag) inputTuple.get(0);
for (final Tuple dataTuple: outerBag) {
final Object f0 = dataTuple.get(0);

0 comments on commit 82eecfb

Please sign in to comment.