当前位置: 首页>>代码示例>>Java>>正文


Java Tuple.getObject方法代码示例

本文整理汇总了Java中cascading.tuple.Tuple.getObject方法的典型用法代码示例。如果您正苦于以下问题:Java Tuple.getObject方法的具体用法?Java Tuple.getObject怎么用?Java Tuple.getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cascading.tuple.Tuple的用法示例。


在下文中一共展示了Tuple.getObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:27,代码来源:CascadingValueWriter.java

示例2: convert

import cascading.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void convert(Object from, BytesArray to) {
    // expect a tuple holding one field - chararray or bytearray
    Assert.isTrue(from instanceof SinkCall,
            String.format("Unexpected object type, expecting [%s], given [%s]", SinkCall.class, from.getClass()));

    // handle common cases
    SinkCall sinkCall = (SinkCall) from;
    Tuple rawTuple = sinkCall.getOutgoingEntry().getTuple();

    if (rawTuple == null || rawTuple.isEmpty()) {
        to.bytes("{}");
        return;
    }
    Assert.isTrue(rawTuple.size() == 1, "When using JSON input, only one field is expected");

    // postpone the coercion
    Tuple tuple = CascadingUtils.coerceToString(sinkCall);
    super.convert(tuple.getObject(0), to);
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:21,代码来源:CascadingLocalBytesConverter.java

示例3: 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);
	}
}
 
开发者ID:dataArtisans,项目名称:cascading-flink,代码行数:26,代码来源:NullMaskSerDeUtils.java

示例4: 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;
}
 
开发者ID:dataArtisans,项目名称:cascading-flink,代码行数:21,代码来源:DefinedTupleSerializer.java

示例5: 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);
			}
		}
	}
}
 
开发者ID:dataArtisans,项目名称:cascading-flink,代码行数:20,代码来源:DefinedTupleSerializer.java

示例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);
		}
	}
}
 
开发者ID:dataArtisans,项目名称:cascading-flink,代码行数:17,代码来源:UnknownTupleSerializer.java


注:本文中的cascading.tuple.Tuple.getObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。