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


Java Tuple.getString方法代码示例

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


在下文中一共展示了Tuple.getString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processControlPort

import com.ibm.streams.operator.Tuple; //导入方法依赖的package包/类
protected void processControlPort(StreamingInput<Tuple> stream, Tuple tuple) {
	String jsonString = tuple.getString(0);
	try {
		JSONObject config = JSONObject.parse(jsonString);
		Boolean shouldReloadModel = (Boolean)config.get("reloadModel");
		if(shouldReloadModel) {
			synchronized(model) {
				model = loadModel(javaContext.sc(), modelPath);
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
		tracer.log(TraceLevel.ERROR, "TRACE_M_CONTROL_PORT_ERROR", new Object[]{e.getMessage()});
	}
}
 
开发者ID:IBMStreams,项目名称:streamsx.sparkMLLib,代码行数:16,代码来源:AbstractSparkMLlibOperator.java

示例2: process

import com.ibm.streams.operator.Tuple; //导入方法依赖的package包/类
@Override
public void process(StreamingInput<Tuple> stream, Tuple tuple)
        throws Exception {

    final StreamingOutput<OutputTuple> out = getOutput(0);

    String fileName = tuple.getString(0);

    File file = new File(fileName);

    if (!file.isAbsolute()) {
        file = new File(getOperatorContext().getPE().getDataDirectory(),
                fileName);
    }

    FileInputStream fis = new FileInputStream(file);
    try {

        BufferedReader br = new BufferedReader(new InputStreamReader(fis,
                charset), 128 * 1024);

        for (;;) {
            String line = br.readLine();
            if (line == null)
                break;
            out.submitAsTuple(new RString(line));
        }
        br.close();

    } finally {
        fis.close();
    }
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:34,代码来源:TextFileReader.java

示例3: process

import com.ibm.streams.operator.Tuple; //导入方法依赖的package包/类
@Override
public void process(StreamingInput<Tuple> stream, Tuple tuple)
        throws Exception {
    
    String str = tuple.getString(0);
    
    getOutput(0).submitAsTuple(new RString(str));
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:9,代码来源:NoOpJavaPrimitive.java

示例4: process

import com.ibm.streams.operator.Tuple; //导入方法依赖的package包/类
/**
 * Process an incoming tuple that arrived on the specified port.
 */
@Override
public final void process(StreamingInput<Tuple> inputStream, Tuple tuple) throws Exception {

	String jsonInput = tuple.getString(inputJsonMessage);

	if (LOGGER.isTraceEnabled())
		LOGGER.log(TraceLevel.TRACE, "Input JSON string: " + jsonInput);

	// Create a new tuple for output port 0 and copy over any matching
	// attributes
	outStream = getOutput(0);
	outTuple = outStream.newTuple();
	outTuple.assign(tuple);

	// Decode the JSON string
	GenericRecord datum = null;
	try {
		Decoder decodedJson = DecoderFactory.get().jsonDecoder(messageSchema, jsonInput);
		datum = jsonReader.read(null, decodedJson);

		// Encode the datum to Avro
		if (embedAvroSchema) {
			avroDataFileWriter.append(datum);
			avroDataFileWriter.flush();
			numberOfBatchedMessages++;
			// Check if any of the threshold parameters has been exceeded
			if (tuplesPerMessage != 0 && numberOfBatchedMessages >= tuplesPerMessage)
				submitAvroToOuput();
			if (bytesPerMessage != 0 && avroBlockByteArray.size() >= bytesPerMessage)
				submitAvroToOuput();
			if (timePerMessage != 0) {
				if (System.currentTimeMillis() >= (lastSubmitted + (1000 * timePerMessage)))
					submitAvroToOuput();
			}
		} else {
			Encoder encoder = EncoderFactory.get().binaryEncoder(avroMessageByteArray, null);
			avroWriter.write(datum, encoder);
			encoder.flush();
			submitAvroToOuput();
		}
	} catch (Exception e) {
		LOGGER.log(TraceLevel.ERROR, "Error while converting JSON string to AVRO schema: " + e.getMessage()
				+ ". JSON String: " + jsonInput);
		// If parsing errors must not be ignored, make the operator fail
		if (!ignoreParsingError)
			throw new Exception("Error while converting JSON string to AVRO schema: " + e.getMessage()
					+ ". JSON String: " + jsonInput);
	}
}
 
开发者ID:IBMStreams,项目名称:streamsx.avro,代码行数:53,代码来源:JSONToAvro.java

示例5: newDevice

import com.ibm.streams.operator.Tuple; //导入方法依赖的package包/类
public static Device newDevice(Tuple tuple) {
    return new Device(tuple.getString(Schemas.TYPE_ID), tuple.getString(Schemas.DEVICE_ID));
}
 
开发者ID:IBMStreams,项目名称:streamsx.iot,代码行数:4,代码来源:IotUtils.java

示例6: convertFrom

import com.ibm.streams.operator.Tuple; //导入方法依赖的package包/类
@Override
public String convertFrom(Tuple tuple) {
    return tuple.getString(0);
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:5,代码来源:StringMapping.java

示例7: apply

import com.ibm.streams.operator.Tuple; //导入方法依赖的package包/类
@Override
public String apply(Tuple v) {
    return "SPL:" + v.getString("id");
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:5,代码来源:PublishSubscribeSPLTest.java

示例8: Ticker

import com.ibm.streams.operator.Tuple; //导入方法依赖的package包/类
Ticker(Tuple tuple) {
    this(tuple.getString("ticker"));
}
 
开发者ID:IBMStreams,项目名称:streamsx.topology,代码行数:4,代码来源:Ticker.java


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