本文整理汇总了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()});
}
}
示例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();
}
}
示例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));
}
示例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);
}
}
示例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));
}
示例6: convertFrom
import com.ibm.streams.operator.Tuple; //导入方法依赖的package包/类
@Override
public String convertFrom(Tuple tuple) {
return tuple.getString(0);
}
示例7: apply
import com.ibm.streams.operator.Tuple; //导入方法依赖的package包/类
@Override
public String apply(Tuple v) {
return "SPL:" + v.getString("id");
}
示例8: Ticker
import com.ibm.streams.operator.Tuple; //导入方法依赖的package包/类
Ticker(Tuple tuple) {
this(tuple.getString("ticker"));
}