本文整理汇总了Java中org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField.exec方法的典型用法代码示例。如果您正苦于以下问题:Java ExtremalTupleByNthField.exec方法的具体用法?Java ExtremalTupleByNthField.exec怎么用?Java ExtremalTupleByNthField.exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField
的用法示例。
在下文中一共展示了ExtremalTupleByNthField.exec方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMin
import org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField; //导入方法依赖的package包/类
@Test
public void testMin() throws Exception {
ExtremalTupleByNthField o = new ExtremalTupleByNthField("3", "min");
DataBag input = BagFactory.getInstance().newDefaultBag();
for (int i = 100; i > 0; --i) {
Tuple t = TupleFactory.getInstance().newTuple();
t.append(i);
t.append(" " + i);
t.append(i);
input.add(t);
}
Tuple tupleInput = TupleFactory.getInstance().newTuple();
tupleInput.append(input);
Tuple out = o.exec(tupleInput);
Assert.assertEquals(" 1", (String) out.get(1));
}
示例2: testMax
import org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField; //导入方法依赖的package包/类
@Test
public void testMax() throws Exception {
ExtremalTupleByNthField o = new ExtremalTupleByNthField("4", "max");
DataBag input = BagFactory.getInstance().newDefaultBag();
for (int i = 0; i < 100; i++) {
Tuple t = TupleFactory.getInstance().newTuple();
t.append(i);
t.append(" " + i);
t.append(i);
t.append(i);
input.add(t);
}
Tuple tupleInput = TupleFactory.getInstance().newTuple();
tupleInput.append(input);
Tuple out = o.exec(tupleInput);
Assert.assertEquals(" 99", (String) out.get(1));
}
示例3: testMaxComplexKey
import org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField; //导入方法依赖的package包/类
@Test
public void testMaxComplexKey() throws Exception {
ExtremalTupleByNthField o = new ExtremalTupleByNthField("3", "max");
DataBag input = BagFactory.getInstance().newDefaultBag();
for (int j = 0; j < 3; ++j) {
for (int i = 0; i < 100; i++) {
Tuple t = TupleFactory.getInstance().newTuple();
t.append(-i);
t.append(" " + j + ", " + i);
Tuple key = TupleFactory.getInstance().newTuple();
key.append(j);
key.append(i);
t.append(key);
t.append(-i);
input.add(t);
}
}
Tuple tupleInput = TupleFactory.getInstance().newTuple();
tupleInput.append(input);
Tuple out = o.exec(tupleInput);
Assert.assertEquals(" 2, 99", (String) out.get(1));
}
示例4: testMinComplexKey
import org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField; //导入方法依赖的package包/类
@Test
public void testMinComplexKey() throws Exception {
ExtremalTupleByNthField o = new ExtremalTupleByNthField("3", "min");
DataBag input = BagFactory.getInstance().newDefaultBag();
for (int j = 0; j < 3; ++j) {
for (int i = 0; i < 100; i++) {
Tuple t = TupleFactory.getInstance().newTuple();
t.append(-i);
t.append(" " + j + ", " + i);
Tuple key = TupleFactory.getInstance().newTuple();
key.append(j);
key.append(i);
t.append(key);
t.append(-i);
input.add(t);
}
}
Tuple tupleInput = TupleFactory.getInstance().newTuple();
tupleInput.append(input);
Tuple out = o.exec(tupleInput);
Assert.assertEquals(" 0, 0", (String) out.get(1));
}
示例5: testMinStringey
import org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField; //导入方法依赖的package包/类
@Test
public void testMinStringey() throws Exception {
ExtremalTupleByNthField o = new ExtremalTupleByNthField("4", "min");
DataBag input = BagFactory.getInstance().newDefaultBag();
Tuple t = TupleFactory.getInstance().newTuple();
t.append("a");
t.append("a");
t.append("a");
t.append("min");
input.add(t);
t = TupleFactory.getInstance().newTuple();
t.append("b");
t.append("b");
t.append("b");
t.append("max");
input.add(t);
Tuple tupleInput = TupleFactory.getInstance().newTuple();
tupleInput.append(input);
Tuple out = o.exec(tupleInput);
// ironically "max" is smaller than "min"
Assert.assertEquals("b", (String) out.get(1));
}
示例6: testBiggerBag
import org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField; //导入方法依赖的package包/类
@Test
public void testBiggerBag() throws Exception {
ExtremalTupleByNthField o = new ExtremalTupleByNthField("1", "max");
DataBag input = BagFactory.getInstance().newDefaultBag();
DataBag dbSmaller = BagFactory.getInstance().newDefaultBag();
dbSmaller.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has three items")));
dbSmaller.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has three items")));
dbSmaller.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has three items")));
input.add(TupleFactory.getInstance().newTuple(
Arrays.asList(dbSmaller, "smaller")));
DataBag dbBigger = BagFactory.getInstance().newDefaultBag();
dbBigger.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has four items")));
dbBigger.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has four items")));
dbBigger.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has four items")));
dbBigger.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has four items")));
dbBigger.add(TupleFactory.getInstance().newTuple(
Arrays.asList("This bag has four items")));
input.add(TupleFactory.getInstance().newTuple(
Arrays.asList(dbBigger, "bigger")));
Tuple tupleInput = TupleFactory.getInstance().newTuple();
tupleInput.append(input);
Tuple out = o.exec(tupleInput);
// DataBags are ordered by size, so the bigger one will be the one
// containing 4 items
Assert.assertEquals("bigger", out.get(1));
}
示例7: testBiggerTuple
import org.apache.pig.piggybank.evaluation.ExtremalTupleByNthField; //导入方法依赖的package包/类
@Test
public void testBiggerTuple() throws Exception {
ExtremalTupleByNthField o = new ExtremalTupleByNthField("1", "min");
DataBag input = BagFactory.getInstance().newDefaultBag();
Tuple tpSmaller = TupleFactory.getInstance().newTuple();
tpSmaller.append("This is a smaller tuple.");
tpSmaller.append("This is a smaller tuple.");
tpSmaller.append("This is a smaller tuple.");
input.add(TupleFactory.getInstance().newTuple(
Arrays.asList(tpSmaller, "smaller")));
Tuple tpBigger = TupleFactory.getInstance().newTuple();
tpBigger.append("This is a bigger tuple.");
tpBigger.append("This is a bigger tuple.");
tpBigger.append("This is a bigger tuple.");
tpBigger.append("This is a bigger tuple.");
input.add(TupleFactory.getInstance().newTuple(
Arrays.asList(tpBigger, "bigger")));
Tuple tupleInput = TupleFactory.getInstance().newTuple();
tupleInput.append(input);
Tuple out = o.exec(tupleInput);
// DataBags are ordered by size, so the bigger one will be the one
// containing 4 items
Assert.assertEquals("smaller", out.get(1));
}