本文整理汇总了Java中cascading.tuple.Tuple.size方法的典型用法代码示例。如果您正苦于以下问题:Java Tuple.size方法的具体用法?Java Tuple.size怎么用?Java Tuple.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cascading.tuple.Tuple
的用法示例。
在下文中一共展示了Tuple.size方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import cascading.tuple.Tuple; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Result write(SinkCall<Object[], ?> sinkCall, Generator generator) {
Tuple tuple = CascadingUtils.coerceToString(sinkCall);
// consider names (in case of aliases these are already applied)
List<String> names = (List<String>) sinkCall.getContext()[0];
generator.writeBeginObject();
for (int i = 0; i < tuple.size(); i++) {
String name = (i < names.size() ? names.get(i) : "tuple" + i);
// filter out fields
if (shouldKeep(generator.getParentPath(), name)) {
generator.writeFieldName(name);
Object object = tuple.getObject(i);
Result result = jdkWriter.write(object, generator);
if (!result.isSuccesful()) {
if (object instanceof Writable) {
return writableWriter.write((Writable) object, generator);
}
return Result.FAILED(object);
}
}
}
generator.writeEndObject();
return Result.SUCCESFUL();
}
示例2: writeNullMask
import cascading.tuple.Tuple; //导入方法依赖的package包/类
public static void writeNullMask(
Tuple t, DataOutputView target) throws IOException {
final int length = t.size();
int b;
int bytePos;
for(int fieldPos = 0; fieldPos < length; ) {
b = 0x00;
// set bits in byte
for(bytePos = 0; bytePos < 8 && fieldPos < length; bytePos++, fieldPos++) {
b = b << 1;
// set bit if field is null
if(t.getObject(fieldPos) == null) {
b |= 0x01;
}
}
// shift bits if last byte is not completely filled
for(; bytePos < 8; bytePos++) {
b = b << 1;
}
// write byte
target.writeByte(b);
}
}
示例3: copy
import cascading.tuple.Tuple; //导入方法依赖的package包/类
@Override
public Tuple copy(Tuple from) {
Tuple target = Tuple.size(from.size());
for (int i = 0; i < from.size(); i++) {
try {
Object orig = from.getObject(i);
if (orig != null) {
target.set(i, fieldSers[i].copy(orig));
}
else {
target.set(i, null);
}
}
catch(ClassCastException cce) {
throw new FlowException("Unexpected type of field \""+fields.get(i)+"\" encountered. " +
"Should have been "+fields.getType(i)+" but was "+from.getObject(i).getClass()+".", cce);
}
}
return target;
}
示例4: serialize
import cascading.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void serialize(Tuple value, DataOutputView target) throws IOException {
// write null mask
NullMaskSerDeUtils.writeNullMask(value, target);
for (int i = 0; i < value.size(); i++) {
Object o = value.getObject(i);
if(o != null) {
try {
fieldSers[i].serialize(o, target);
}
catch(ClassCastException cce) {
throw new FlowException("Unexpected type of field \""+fields.get(i)+"\" encountered. " +
"Should have been "+fields.getType(i)+" but was "+o.getClass()+".", cce);
}
}
}
}
示例5: deserialize
import cascading.tuple.Tuple; //导入方法依赖的package包/类
@Override
public Tuple deserialize(DataInputView source) throws IOException {
// read null mask
NullMaskSerDeUtils.readNullMask(this.nullFields, this.length, source);
// read non-null fields
Tuple tuple = Tuple.size(this.length);
for (int i = 0; i < this.length; i++) {
Object field;
if(!this.nullFields[i]) {
field = fieldSers[i].deserialize(source);
}
else {
field = null;
}
tuple.set(i, field);
}
return tuple;
}
示例6: serialize
import cascading.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void serialize(Tuple value, DataOutputView target) throws IOException {
// write length
target.writeInt(value.size());
// write null mask
NullMaskSerDeUtils.writeNullMask(value, target);
for (int i = 0; i < value.size(); i++) {
Object o = value.getObject(i);
if(o != null) {
fieldSer.serialize(o, target);
}
}
}
示例7: createInstance
import cascading.tuple.Tuple; //导入方法依赖的package包/类
@Override
public Tuple createInstance() {
try {
return Tuple.size(length);
} catch (Exception e) {
throw new RuntimeException("Cannot instantiate tuple.", e);
}
}
示例8: getReuseOrNew
import cascading.tuple.Tuple; //导入方法依赖的package包/类
private Tuple getReuseOrNew(Tuple reuse) {
if(reuse.isUnmodifiable()) {
return Tuple.size(this.length);
}
else {
return reuse;
}
}
示例9: createInstance
import cascading.tuple.Tuple; //导入方法依赖的package包/类
@Override
public Tuple createInstance() {
try {
return Tuple.size(0);
} catch (Exception e) {
throw new RuntimeException("Cannot instantiate tuple.", e);
}
}
示例10: deserialize
import cascading.tuple.Tuple; //导入方法依赖的package包/类
@Override
public Tuple deserialize(DataInputView source) throws IOException {
// read length
int arity = source.readInt();
// initialize or resize null fields if necessary
if(this.nullFields == null || this.nullFields.length < arity) {
this.nullFields = new boolean[arity];
}
// read null mask
NullMaskSerDeUtils.readNullMask(this.nullFields, arity, source);
// read non-null fields
Tuple tuple = Tuple.size(arity);
for (int i = 0; i < arity; i++) {
Object field;
if(!this.nullFields[i]) {
field = fieldSer.deserialize(source);
}
else {
field = null;
}
tuple.set(i, field);
}
return tuple;
}
示例11: getReuseOrNew
import cascading.tuple.Tuple; //导入方法依赖的package包/类
private Tuple getReuseOrNew(Tuple reuse, int arity) {
if(reuse.isUnmodifiable() || reuse.size() != arity) {
return Tuple.size(arity);
}
else {
return reuse;
}
}
示例12: CoGroupBufferClosure
import cascading.tuple.Tuple; //导入方法依赖的package包/类
public CoGroupBufferClosure(FlowProcess flowProcess, int numSelfJoins, Fields[] joinFields, Fields[] valueFields) {
super(flowProcess, joinFields, valueFields);
this.numSelfJoins = numSelfJoins;
this.emptyTuple = Tuple.size( joinFields[0].size() );
FactoryLoader loader = FactoryLoader.getInstance();
this.tupleCollectionFactory = loader.loadFactoryFrom( flowProcess, TUPLE_COLLECTION_FACTORY, SpillingTupleCollectionFactory.class );
initLists();
}
示例13: createTuples
import cascading.tuple.Tuple; //导入方法依赖的package包/类
private List<Tuple> createTuples() {
List<Tuple> tuples = new LinkedList<>();
Tuple tuple = Tuple.size(structTypeInfo.getAllStructFieldNames().size());
for (int i = 0; i < 1000000; i++) {
Number n = i;
tuple.clear();
tuple.add(n.toString());
tuple.add(i % 2 == 0);
tuple.add(n.byteValue());
tuple.add(n.shortValue());
tuple.add(i);
tuple.add(n.longValue());
tuple.add(n.floatValue());
tuple.add(n.doubleValue());
tuple.add(new Timestamp(i));
tuple.add(new Date(i));
tuple.add(n.toString().getBytes());
tuple.add(new BigDecimal(n.toString()));
tuple.add(Arrays.asList(i));
tuple.add(createMap(i));
tuple.add(Arrays.asList(i));
tuple.add(n.toString());
tuples.add(tuple);
}
return tuples;
}
示例14: JoinClosure
import cascading.tuple.Tuple; //导入方法依赖的package包/类
public JoinClosure(FlowProcess flowProcess, Fields[] joinFields, Fields[] valueFields) {
super(flowProcess, joinFields, valueFields);
this.emptyKeyTuple = Tuple.size( joinFields[0].size() );
this.keyTuples = new Tuple[joinFields.length];
this.joinedKeysTupleBuilder = makeJoinedBuilder( joinFields );
}