本文整理汇总了Java中org.apache.pig.data.DataByteArray.size方法的典型用法代码示例。如果您正苦于以下问题:Java DataByteArray.size方法的具体用法?Java DataByteArray.size怎么用?Java DataByteArray.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pig.data.DataByteArray
的用法示例。
在下文中一共展示了DataByteArray.size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateUnion
import org.apache.pig.data.DataByteArray; //导入方法依赖的package包/类
/**
* Updates a union given a bag of sketches
*
* @param bag A bag of sketchTuples.
* @param union The union to update
*/
private static <T> void updateUnion(final DataBag bag, final ItemsUnion<T> union,
final Comparator<T> comparator, final ArrayOfItemsSerDe<T> serDe) throws ExecException {
for (Tuple innerTuple: bag) {
final Object f0 = innerTuple.get(0);
if (f0 == null) { continue; }
if (f0 instanceof DataByteArray) {
final DataByteArray dba = (DataByteArray) f0;
if (dba.size() > 0) {
union.update(ItemsSketch.getInstance(Memory.wrap(dba.get()), comparator, serDe));
}
} else {
throw new IllegalArgumentException("Field type was not DataType.BYTEARRAY: " + innerTuple.getType(0));
}
}
}
示例2: updateUnion
import org.apache.pig.data.DataByteArray; //导入方法依赖的package包/类
/*************************************************************************************************
* Updates a union from a bag of sketches
*
* @param bag A bag of sketchTuples.
* @param union The union to update
*/
private static void updateUnion(final DataBag bag, final com.yahoo.sketches.theta.Union union) {
// Bag is not empty. process each innerTuple in the bag
for (Tuple innerTuple : bag) {
// validate the inner Tuples
final Object f0 = extractFieldAtIndex(innerTuple, 0);
if (f0 == null) {
continue;
}
final Byte type = extractTypeAtIndex(innerTuple, 0);
if (type == null) {
continue;
}
// add only the first field of the innerTuple to the union
if (type == DataType.BYTEARRAY) {
final DataByteArray dba = (DataByteArray) f0;
if (dba.size() > 0) {
union.update(Memory.wrap(dba.get()));
}
} else {
throw new IllegalArgumentException("Field type was not DataType.BYTEARRAY: " + type);
}
}
}
示例3: updateUnion
import org.apache.pig.data.DataByteArray; //导入方法依赖的package包/类
/**
* Updates a union from a bag of sketches
*
* @param bag A bag of sketchTuples.
* @param union The union to update
*/
private static void updateUnion(final DataBag bag, final DoublesUnion union) throws ExecException {
for (Tuple innerTuple: bag) {
final Object f0 = innerTuple.get(0);
if (f0 == null) { continue; }
if (f0 instanceof DataByteArray) {
final DataByteArray dba = (DataByteArray) f0;
if (dba.size() > 0) {
union.update(Memory.wrap(dba.get()));
}
} else {
throw new IllegalArgumentException("Field type was not DataType.BYTEARRAY: " + innerTuple.getType(0));
}
}
}
示例4: updateSketch
import org.apache.pig.data.DataByteArray; //导入方法依赖的package包/类
static void updateSketch(
final DataBag bag, final ArrayOfDoublesUpdatableSketch sketch, final int numValues)
throws ExecException {
if (bag == null) {
throw new IllegalArgumentException("InputTuple.Field0: Bag may not be null");
}
final double[] values = new double[numValues];
for (final Tuple tuple: bag) {
if (tuple.size() != numValues + 1) {
throw new IllegalArgumentException("Inner tuple of input bag must have " + (numValues + 1)
+ " fields.");
}
final Object key = tuple.get(0);
if (key == null) { continue; }
for (int i = 0; i < numValues; i++) {
values[i] = (Double) tuple.get(i + 1);
}
switch (tuple.getType(0)) {
case DataType.BYTE:
sketch.update(((Byte) key).longValue(), values);
break;
case DataType.INTEGER:
sketch.update(((Integer) key).longValue(), values);
break;
case DataType.LONG:
sketch.update((Long) key, values);
break;
case DataType.FLOAT:
sketch.update((Float) key, values);
break;
case DataType.DOUBLE:
sketch.update((Double) key, values);
break;
case DataType.BYTEARRAY:
final DataByteArray dba = (DataByteArray) key;
if (dba.size() != 0) {
sketch.update(dba.get(), values);
}
break;
case DataType.CHARARRAY:
final String s = key.toString();
if (!s.isEmpty()) {
sketch.update(s, values);
}
break;
default:
throw new IllegalArgumentException("Field 0 must be one of "
+ "NULL, BYTE, INTEGER, LONG, FLOAT, DOUBLE, BYTEARRAY or CHARARRAY. " + "Type = "
+ DataType.findTypeName(tuple.getType(0)) + ", Object = " + key.toString());
}
}
}
示例5: updateSketch
import org.apache.pig.data.DataByteArray; //导入方法依赖的package包/类
static <U, S extends UpdatableSummary<U>> void updateSketch(final DataBag bag,
final UpdatableSketch<U, S> sketch) throws ExecException {
if (bag == null) {
throw new IllegalArgumentException("InputTuple.Field0: Bag may not be null");
}
for (final Tuple tuple: bag) {
if (tuple.size() != 2) {
throw new IllegalArgumentException("Inner tuple of input bag must have 2 fields.");
}
final Object key = tuple.get(0);
if (key == null) { continue; }
@SuppressWarnings("unchecked")
final U value = (U) tuple.get(1);
switch (tuple.getType(0)) {
case DataType.BYTE:
sketch.update(((Byte) key).longValue(), value);
break;
case DataType.INTEGER:
sketch.update(((Integer) key).longValue(), value);
break;
case DataType.LONG:
sketch.update((Long) key, value);
break;
case DataType.FLOAT:
sketch.update((Float) key, value);
break;
case DataType.DOUBLE:
sketch.update((Double) key, value);
break;
case DataType.BYTEARRAY:
final DataByteArray dba = (DataByteArray) key;
if (dba.size() != 0) {
sketch.update(dba.get(), value);
}
break;
case DataType.CHARARRAY:
final String s = key.toString();
if (!s.isEmpty()) {
sketch.update(s, value);
}
break;
default:
throw new IllegalArgumentException("Field 0 must be one of "
+ "NULL, BYTE, INTEGER, LONG, FLOAT, DOUBLE, BYTEARRAY or CHARARRAY. " + "Type = "
+ DataType.findTypeName(tuple.getType(0)) + ", Object = " + key.toString());
}
}
}