Skip to content
Permalink
Browse files
Got Checkstyle working. These are checkstyle fixes.
  • Loading branch information
leerho committed Mar 5, 2021
1 parent df5860b commit 11300f0ae9576dc8199ec49dc512899a9629189d
Showing 19 changed files with 52 additions and 37 deletions.
@@ -126,7 +126,8 @@ public DataByteArray exec(final Tuple inputTuple) throws IOException {
}
if (inputTuple == null || inputTuple.size() == 0) {
if (this.emptySketch_ == null) {
this.emptySketch_ = new DataByteArray(new HllSketch(this.lgK_, this.tgtHllType_).toCompactByteArray());
this.emptySketch_ =
new DataByteArray(new HllSketch(this.lgK_, this.tgtHllType_).toCompactByteArray());
}
return this.emptySketch_;
}
@@ -172,7 +173,8 @@ public void accumulate(final Tuple inputTuple) throws IOException {
public DataByteArray getValue() {
if (this.accumUnion_ == null) {
if (this.emptySketch_ == null) {
this.emptySketch_ = new DataByteArray(new HllSketch(this.lgK_, this.tgtHllType_).toCompactByteArray());
this.emptySketch_ =
new DataByteArray(new HllSketch(this.lgK_, this.tgtHllType_).toCompactByteArray());
}
return this.emptySketch_;
}
@@ -112,7 +112,8 @@ public DataByteArray exec(final Tuple inputTuple) throws IOException {
}
if (inputTuple == null || inputTuple.size() == 0) {
if (this.emptySketch_ == null) {
this.emptySketch_ = new DataByteArray(new HllSketch(this.lgK_, this.tgtHllType_).toCompactByteArray());
this.emptySketch_ =
new DataByteArray(new HllSketch(this.lgK_, this.tgtHllType_).toCompactByteArray());
}
return this.emptySketch_;
}
@@ -20,15 +20,15 @@
/**
* Pig UDFs for HLL sketches.
*
* These UDFs can be used as a replacement of corresponding Theta sketch UDFs.
* <p>These UDFs can be used as a replacement of corresponding Theta sketch UDFs.
* Notice that intersections and A-not-B operations are not supported by the HLL sketch.
* Also notice a small difference in the output type of DataToSketch and UnionSketch:
* HLL sketch UDFs return DataByteArray (BYTEARRAY in Pig), but corresponding Theta sketch
* UDFs return a Tuple with single DataByteArray inside. This was a historical accident,
* and we are reluctant to break the compatibility with existing scripts. HLL sketch UDFs
* don't have to keep this compatibility. As a result, HLL sketch UDFs don't need
* flatten() around them to remove the Tuple, and internally they don't have to spend extra
* resources to wrap every output DataByteArray into a Tuple.
* resources to wrap every output DataByteArray into a Tuple.</p>
*
* @author Alexander Saydakov
*/
@@ -273,7 +273,7 @@ private Intermediate(final int k) {
}

@SuppressWarnings("synthetic-access")
@Override
@Override
public Tuple exec(final Tuple inputTuple) throws IOException { //throws is in API
return TUPLE_FACTORY_.newTuple(process(inputTuple, this.k_));
}
@@ -320,7 +320,7 @@ private Final(final int k) {
}

@SuppressWarnings("synthetic-access")
@Override
@Override
public DataByteArray exec(final Tuple inputTuple) throws IOException {
return process(inputTuple, this.k_);
}
@@ -287,7 +287,7 @@ private Intermediate(final int k) {
}

@SuppressWarnings("synthetic-access")
@Override
@Override
public Tuple exec(final Tuple inputTuple) throws IOException {
return TUPLE_FACTORY_.newTuple(process(inputTuple, this.k_));
}
@@ -333,7 +333,7 @@ private Final(final int k) {
}

@SuppressWarnings("synthetic-access")
@Override
@Override
public DataByteArray exec(final Tuple inputTuple) throws IOException {
return process(inputTuple, this.k_);
}
@@ -152,7 +152,8 @@ public Tuple exec(final Tuple inputTuple) throws IOException {
}
}
// return empty sketch
return tupleFactory_.newTuple(new DataByteArray(this.unionBuilder_.build().getResult().toByteArray(true)));
return tupleFactory_.newTuple(
new DataByteArray(this.unionBuilder_.build().getResult().toByteArray(true)));
}

@Override
@@ -214,7 +215,8 @@ public Tuple getValue() {
}
}
// return empty sketch
return tupleFactory_.newTuple(new DataByteArray(this.unionBuilder_.build().getResult().toByteArray(true)));
return tupleFactory_.newTuple(
new DataByteArray(this.unionBuilder_.build().getResult().toByteArray(true)));
}

/**
@@ -321,7 +323,7 @@ public IntermediateFinal(final int k) {
}

@SuppressWarnings("synthetic-access")
@Override // IntermediateFinal exec
@Override // IntermediateFinal exec
public Tuple exec(final Tuple inputTuple) throws IOException { //throws is in API
if ((inputTuple != null) && (inputTuple.size() > 0)) {
final DoublesUnion union = this.unionBuilder_.build();
@@ -359,7 +361,8 @@ public Tuple exec(final Tuple inputTuple) throws IOException { //throws is in AP
}
}
// return empty sketch
return tupleFactory_.newTuple(new DataByteArray(this.unionBuilder_.build().getResult().toByteArray(true)));
return tupleFactory_.newTuple(
new DataByteArray(this.unionBuilder_.build().getResult().toByteArray(true)));
}
} // end IntermediateFinal

@@ -309,7 +309,7 @@ protected T extractValue(final Object object) {
}

@SuppressWarnings("synthetic-access")
@Override // IntermediateFinal exec
@Override // IntermediateFinal exec
public Tuple exec(final Tuple inputTuple) throws IOException { //throws is in API
if ((inputTuple != null) && (inputTuple.size() > 0)) {
final ItemsUnion<T> union = this.k_ > 0
@@ -63,11 +63,11 @@ public String getFinal() {
public static class DataToStringsSketchIntermediateFinal
extends DataToItemsSketchIntermediateFinal<String> {

public DataToStringsSketchIntermediateFinal() {
public DataToStringsSketchIntermediateFinal() {
super(0, COMPARATOR, SER_DE);
}

public DataToStringsSketchIntermediateFinal(final String kStr) {
public DataToStringsSketchIntermediateFinal(final String kStr) {
super(Integer.parseInt(kStr), COMPARATOR, SER_DE);
}

@@ -138,7 +138,8 @@ public Tuple exec(final Tuple inputTuple) throws IOException {
}
}
// return empty sketch
return tupleFactory_.newTuple(new DataByteArray(this.unionBuilder_.build().getResult().toByteArray(true)));
return tupleFactory_.newTuple(
new DataByteArray(this.unionBuilder_.build().getResult().toByteArray(true)));
}

@Override
@@ -193,7 +194,8 @@ public Tuple getValue() {
}
}
// return empty sketch
return tupleFactory_.newTuple(new DataByteArray(this.unionBuilder_.build().getResult().toByteArray(true)));
return tupleFactory_.newTuple(
new DataByteArray(this.unionBuilder_.build().getResult().toByteArray(true)));
}

/**
@@ -321,7 +323,7 @@ public IntermediateFinal(final int k) {
}

@SuppressWarnings("synthetic-access")
@Override // IntermediateFinal exec
@Override // IntermediateFinal exec
public Tuple exec(final Tuple inputTuple) throws IOException {
if (inputTuple != null && inputTuple.size() > 0) {
final DoublesUnion union = this.unionBuilder_.build();
@@ -354,7 +356,8 @@ public Tuple exec(final Tuple inputTuple) throws IOException {
}
}
// return empty sketch
return tupleFactory_.newTuple(new DataByteArray(this.unionBuilder_.build().getResult().toByteArray(true)));
return tupleFactory_.newTuple(
new DataByteArray(this.unionBuilder_.build().getResult().toByteArray(true)));
}
} // end IntermediateFinal

@@ -170,7 +170,9 @@ public void accumulate(final Tuple inputTuple) throws IOException {
final DataBag bag = (DataBag) inputTuple.get(0);
if (bag == null) { return; }
if (this.accumUnion_ == null) {
this.accumUnion_ = this.k_ > 0 ? ItemsUnion.getInstance(this.k_, this.comparator_) : ItemsUnion.getInstance(this.comparator_);
this.accumUnion_ = this.k_ > 0
? ItemsUnion.getInstance(this.k_, this.comparator_)
: ItemsUnion.getInstance(this.comparator_);
}
updateUnion(bag, this.accumUnion_, this.comparator_, this.serDe_);
}
@@ -292,7 +294,7 @@ public UnionItemsSketchIntermediateFinal(
}

@SuppressWarnings("synthetic-access")
@Override // IntermediateFinal exec
@Override // IntermediateFinal exec
public Tuple exec(final Tuple inputTuple) throws IOException {
if (inputTuple != null && inputTuple.size() > 0) {
final ItemsUnion<T> union = this.k_ > 0
@@ -62,7 +62,7 @@ public String getFinal() {
@SuppressWarnings("synthetic-access")
public static class UnionStringsSketchIntermediateFinal extends UnionItemsSketchIntermediateFinal<String> {

public UnionStringsSketchIntermediateFinal() {
public UnionStringsSketchIntermediateFinal() {
super(0, COMPARATOR, SER_DE);
}

@@ -272,7 +272,7 @@ public UnionSketchesAsByteArray(final String kStr, final String weightIdxStr) {
}

@SuppressWarnings("synthetic-access")
@Override
@Override
public DataByteArray exec(final Tuple inputTuple) throws IOException {
if (inputTuple == null || inputTuple.size() < 1 || inputTuple.isNull(0)) {
return null;
@@ -524,7 +524,7 @@ public IntermediateFinal(final int nomEntries, final float p, final long seed) {
}

@SuppressWarnings("synthetic-access")
@Override //IntermediateFinal exec
@Override //IntermediateFinal exec
public Tuple exec(final Tuple inputTuple) throws IOException { //throws is in API
final Union union = newUnion(this.myNomEntries_, this.myP_, this.mySeed_);
final DataBag outerBag = extractBag(inputTuple); //InputTuple.bag0
@@ -346,7 +346,7 @@ public IntermediateFinal(final long seed) {
}

@SuppressWarnings("synthetic-access")
@Override //IntermediateFinal exec
@Override //IntermediateFinal exec
public Tuple exec(final Tuple inputTuple) throws IOException { //throws is in API

final Intersection intersection = SetOperation.builder().setSeed(this.mySeed_).buildIntersection();
@@ -468,7 +468,7 @@ public IntermediateFinal(final int nomEntries, final float p, final long seed) {
}

@SuppressWarnings("synthetic-access")
@Override //IntermediateFinal exec
@Override //IntermediateFinal exec
public Tuple exec(final Tuple inputTuple) throws IOException { //throws is in API

final org.apache.datasketches.theta.Union union =
@@ -129,7 +129,8 @@ public Tuple exec(final Tuple inputTuple) throws IOException {
// This is a sketch from a prior call to the
// Intermediate function. merge it with the
// current sketch.
final Sketch<S> incomingSketch = Util.deserializeSketchFromTuple(dataTuple, this.summaryDeserializer_);
final Sketch<S> incomingSketch =
Util.deserializeSketchFromTuple(dataTuple, this.summaryDeserializer_);
union.union(incomingSketch);
} else {
// we should never get here.
@@ -93,13 +93,15 @@ public Tuple exec(final Tuple inputTuple) throws IOException {
if (item instanceof DataBag) {
// this is from a prior call to the initial function, so there is a nested bag.
for (Tuple innerTuple: (DataBag) item) {
final Sketch<S> incomingSketch = Util.deserializeSketchFromTuple(innerTuple, this.summaryDeserializer_);
final Sketch<S> incomingSketch =
Util.deserializeSketchFromTuple(innerTuple, this.summaryDeserializer_);
union.union(incomingSketch);
}
} else if (item instanceof DataByteArray) {
// This is a sketch from a call to the Intermediate function
// Add it to the current union.
final Sketch<S> incomingSketch = Util.deserializeSketchFromTuple(dataTuple, this.summaryDeserializer_);
final Sketch<S> incomingSketch =
Util.deserializeSketchFromTuple(dataTuple, this.summaryDeserializer_);
union.union(incomingSketch);
} else {
// we should never get here.
@@ -19,23 +19,24 @@

/**
* Pig UDFs for Tuple sketches.
* Tuple sketches are based on the idea of Theta sketches with the addition of
*
* <p>Tuple sketches are based on the idea of Theta sketches with the addition of
* values associated with unique keys.
* Two sets of tuple sketch classes are available at the moment:
* generic Tuple sketches with user-defined Summary, and a faster specialized
* implementation with an array of double values.
* implementation with an array of double values.</p>
*
* <p>There are two sets of Pig UDFs: one for generic Tuple sketch with an example
* implementation for DoubleSummay, and another one for a specialized ArrayOfDoublesSketch.
*
* <p> The generic implementation is in the form of abstract classes DataToSketch and
* <p>The generic implementation is in the form of abstract classes DataToSketch and
* UnionSketch to be specialized for particular types of Summary.
* An example implementation for DoubleSumamry is provided: DataToDoubleSummarySketch and
* UnionDoubleSummarySketch, as well as UDFs to obtain the results from sketches:
* DoubleSumamrySketchToEstimates and DoubleSummarySketchToPercentile.
* DoubleSumamrySketchToEstimates and DoubleSummarySketchToPercentile.</p>
*
* <p>UDFs for ArrayOfDoublesSketch: DataToArrayOfDoublesSketch, UnionArrayOfDoublesSketch,
* ArrayOfDoublesSketchToEstimates.
* ArrayOfDoublesSketchToEstimates.</p>
*
* @author Alexander Saydakov
*/
@@ -203,10 +203,10 @@ under the License.
<module name="JavadocMethod">
<property name="scope" value="public"/>
<property name="allowMissingParamTags" value="false"/>
<property name="allowMissingThrowsTags" value="true"/>
<!-- <property name="allowMissingThrowsTags" value="true"/> now not allowed ?!? -->
<property name="allowMissingReturnTag" value="false"/>
<property name="allowedAnnotations" value="Override, Test"/>
<property name="allowThrowsTagsForSubclasses" value="true"/>
<!-- <property name="allowThrowsTagsForSubclasses" value="true"/> now not allowed ?!? -->
</module>

<module name="JavadocParagraph"/>

0 comments on commit 11300f0

Please sign in to comment.