Skip to content
Permalink
Browse files
checkstyle fixes, add missing copyright blurbs
  • Loading branch information
jmalkin committed Jun 28, 2017
1 parent f425336 commit 55ec92ea5d8b437714561f1fa03cb3d642394369
Showing 16 changed files with 90 additions and 20 deletions.
@@ -1,3 +1,8 @@
/*
* Copyright 2017, 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.pig.sampling;

import java.io.ByteArrayInputStream;
@@ -1,5 +1,5 @@
/*
* Copyright 2016, Yahoo! Inc.
* Copyright 2017, Yahoo! Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*/

@@ -1,5 +1,5 @@
/*
* Copyright 2016, Yahoo! Inc.
* Copyright 2017, Yahoo! Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*/

@@ -1,3 +1,8 @@
/*
* Copyright 2017, 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.pig.sampling;

import java.io.IOException;
@@ -1,3 +1,8 @@
/*
* Copyright 2017, 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.pig.sampling;

import java.io.IOException;
@@ -1,5 +1,5 @@
/*
* Copyright 2016, Yahoo! Inc.
* Copyright 2017, Yahoo! Inc.
* Licensed under the terms of the Apache License 2.0. See LICENSE file at the project root for terms.
*/

@@ -1,3 +1,8 @@
/*
* Copyright 2017, 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.pig.sampling;

import static com.yahoo.sketches.pig.sampling.VarOptCommonImpl.DEFAULT_TARGET_K;
@@ -6,7 +11,6 @@

import org.apache.pig.AccumulatorEvalFunc;
import org.apache.pig.Algebraic;
import org.apache.pig.backend.executionengine.ExecException;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.DataByteArray;
import org.apache.pig.data.DataType;
@@ -13,7 +13,6 @@
import org.apache.pig.data.TupleFactory;

import com.yahoo.memory.Memory;
import com.yahoo.memory.WritableMemory;
import com.yahoo.sketches.ResizeFactor;
import com.yahoo.sketches.theta.CompactSketch;
import com.yahoo.sketches.theta.Sketch;
@@ -1,3 +1,8 @@
/*
* Copyright 2017, 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.pig.sampling;

import static org.testng.Assert.assertEquals;
@@ -1,3 +1,8 @@
/*
* Copyright 2017, 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.pig.sampling;

import static com.yahoo.sketches.pig.sampling.VarOptCommonImpl.RECORD_ALIAS;
@@ -1,3 +1,8 @@
/*
* Copyright 2017, 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.pig.sampling;

import static com.yahoo.sketches.pig.sampling.ReservoirSampling.K_ALIAS;
@@ -1,3 +1,8 @@
/*
* Copyright 2017, 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.pig.sampling;

import static com.yahoo.sketches.pig.sampling.ReservoirSampling.K_ALIAS;
@@ -1,3 +1,8 @@
/*
* Copyright 2017, 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.pig.sampling;

import static org.testng.Assert.assertEquals;
@@ -1,3 +1,8 @@
/*
* Copyright 2017, 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.pig.sampling;

import static com.yahoo.sketches.pig.sampling.VarOptCommonImpl.RECORD_ALIAS;
@@ -1,3 +1,8 @@
/*
* Copyright 2017, 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.pig.sampling;

import static org.testng.Assert.assertEquals;
@@ -7,9 +12,6 @@

import java.io.IOException;

import com.yahoo.memory.Memory;
import com.yahoo.sketches.sampling.VarOptItemsSketch;
import com.yahoo.sketches.sampling.VarOptItemsUnion;
import org.apache.pig.data.BagFactory;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.DataByteArray;
@@ -19,6 +21,10 @@
import org.apache.pig.impl.logicalLayer.schema.Schema;
import org.testng.annotations.Test;

import com.yahoo.memory.Memory;
import com.yahoo.sketches.sampling.VarOptItemsSketch;
import com.yahoo.sketches.sampling.VarOptItemsUnion;

public class VarOptUnionTest {
@Test
public void checkConstructors() {
@@ -2,33 +2,49 @@
* 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.pig.tuple;

import java.util.List;

import org.apache.pig.data.BagFactory;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.Tuple;
import org.apache.pig.data.TupleFactory;
import org.apache.pig.data.DataBag;
import org.apache.pig.data.BagFactory;

public class PigUtil {
public static Tuple objectsToTuple(Object ... objects) {
Tuple tuple = TupleFactory.getInstance().newTuple();
for (Object object: objects) tuple.append(object);
/**
* Wraps input Objects in a Tuple
* @param objects Objects intended to be wrapped
* @return a Pig Tuple containing the input Objects
*/
public static Tuple objectsToTuple(final Object ... objects) {
final Tuple tuple = TupleFactory.getInstance().newTuple();
for (Object object: objects) { tuple.append(object); }
return tuple;
}

public static DataBag tuplesToBag(Tuple ... tuples) {
DataBag bag = BagFactory.getInstance().newDefaultBag();
for (Tuple tuple: tuples) bag.add(tuple);
/**
* Wraps a set of Tuples in a DataBag
* @param tuples Tuples to wrap
* @return a Pig DataBag containing the input Tuples
*/
public static DataBag tuplesToBag(final Tuple ... tuples) {
final DataBag bag = BagFactory.getInstance().newDefaultBag();
for (Tuple tuple: tuples) { bag.add(tuple); }
return bag;
}

// wrap a List of Objects into a DataBag of a Tuples (one Object per Tuple)
public static <T> DataBag listToBagOfTuples(List<T> list) {
DataBag bag = BagFactory.getInstance().newDefaultBag();
/**
* Wraps a List of objects into a DataBag of Tuples (one object per Tuple)
* @param list List of items to wrap
* @param <T> Type of objects in the List
* @return a Pig DataBag containing Tuples populated with list items
*/
public static <T> DataBag listToBagOfTuples(final List<T> list) {
final DataBag bag = BagFactory.getInstance().newDefaultBag();
for (Object object: list) {
Tuple tuple = TupleFactory.getInstance().newTuple();
final Tuple tuple = TupleFactory.getInstance().newTuple();
tuple.append(object);
bag.add(tuple);
}

0 comments on commit 55ec92e

Please sign in to comment.