MCPcopy Create free account
hub / github.com/apache/pig / splitCreateBagOfTuples

Method splitCreateBagOfTuples

test/org/apache/pig/test/Util.java:191–202  ·  view source on GitHub ↗

Create an array of tuple bags with specified size created by splitting the input array of primitive types @param input Array of primitive types @param bagSize The number of tuples to be split and copied into each bag @return an array of tuple bags with each bag containing bagSize tuples split from

(T[] input, int bagSize)

Source from the content-addressed store, hash-verified

189 * @return an array of tuple bags with each bag containing bagSize tuples split from the input
190 */
191 static public <T> Tuple[] splitCreateBagOfTuples(T[] input, int bagSize)
192 throws ExecException {
193 List<Tuple> result = new ArrayList<Tuple>();
194 for (int from = 0; from < input.length; from += bagSize) {
195 Tuple t = TupleFactory.getInstance().newTuple(1);
196 int to = from + bagSize < input.length ? from + bagSize
197 : input.length;
198 T[] array = Arrays.copyOfRange(input, from, to);
199 result.add(loadNestTuple(t, array));
200 }
201 return result.toArray(new Tuple[0]);
202 }
203
204 static public <T>void addToTuple(Tuple t, T[] b)
205 {

Callers 1

setUpMethod · 0.95

Calls 5

getInstanceMethod · 0.95
loadNestTupleMethod · 0.95
toArrayMethod · 0.80
newTupleMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected