Products | Versions |
---|---|
TIBCO Streaming | - |
How to enqueue a list of tuples using the StreamBase .NET API.
dotnet.sbapp application's 'InputStream1' Input Stream schema. In addition, include myTupleList in the Map Operator's Input Fields so its values can be seen on the application's Output Stream.
4. In the Main method, create the Field object for myTupleList:
// turn the field names into Field objects outside the enqueue loop,
// for efficiency of the loop
Schema.Field field1 = schema.GetField(FIELD1);
Schema.Field field2 = schema.GetField(FIELD2);
Schema.Field field3 = schema.GetField(FIELD3);
Schema.Field field4 = schema.GetField(FIELD4); //add
5. Create a Tuple object for the myTupleList field, and turn sub-field names into field objects:
// create a Tuple object for the sub-tuple field,
// and turn sub-field names into field objects
Schema subschema = client.GetSchemaForStream(SUBTUPLE_STREAM);
Tuple subtuple = subschema.CreateTuple();
Schema.Field subfield1 = subschema.GetField(SUBFIELD1);
Schema.Field subfield2 = subschema.GetField(SUBFIELD2);
6. Create a List object and add the myTupleList field:
//create a List object and add the sub-tuple
List<object> myAL = new List<object>();
myAL.Add(subtuple);
7. Use the Field objects, field4/subfield1/subfield2, to set the values of myTupleList/subField1/subField2 in the enqueue loop:
for (int i = 1; i <= NUM_TUPLES; i++) {
// initialize the tuple's fields
tuple.SetInt(field1, i);
tuple.SetString(field2, "Tuple #"+i);
tuple.SetDouble(field3, i / 10.0);
subtuple.SetInt(subfield1, i);
subtuple.SetString(subfield2, "subVal" + i);
tuple.SetList(field4, myAL);
For details on using the SetList() method, refer to the .NET API Help included with your installation of StreamBase.