Contents
Use the Manual Input view to send test data to a running StreamBase application one tuple at a time, and watch the results in the Application Output View and the Application Input View.
The command-line equivalent of manual input is to start an sbc enqueue session on an input stream of a running application. You can then type the CSV equivalent of tuples that match that stream's schema.
When your application is running, StreamBase Studio queries the running server instance to determine the number of input streams and the schema for each stream. The Manual Input view shows the application's input streams in the Input stream drop-down list, and shows the schema for the currently selected stream.
If the running application has more than one input stream, select the stream of interest in the Input Stream drop-down list.
If an input stream's schema has field-level descriptions, the description text for a field can be seen as a tooltip when the cursor is in or over that field.
|
Similarly, if the schema for the stream itself has an entry in its Schema Description field, or if there is a description for a named schema used by the stream, hovering over the information icon for the stream shows that description.
|
The example below is taken from the firstapp.sbapp
application shipped with StreamBase in the firstapp
sample. The input stream TradesIn is selected as the
stream onto which data will be enqueued. This input stream's schema had two fields,
symbol and quantity.
When you run an application in Studio, the initial values in the Manual Input view's
input fields are shown as null, which is a reserved word
representing an empty value for this field. This default setting is a convenience
when enqueuing a tuple that contains many fields: you can let some fields remain as
null, and enter non-null values only for the fields that
you know must not be null during your test of downstream components.
|
(For further information on using nulls, see Using Nulls in the Authoring Guide.)
Notice the select link on the right of the Stream field. When working with large applications with many input streams in several modules, click this link to open a dialog that shows all input streams in the current project's module search path.
|
The following example shows values entered to replace the default nulls:
|
You can enter data for any valid StreamBase data type. See StreamBase Data Types for the range of values allowed for each data type. The following data types have specialized input methods:
-
To enter a timestamp value, press Ctrl+Space with the cursor in a timestamp field (illustrated by the red line in the following example). Studio prompts with an autocompletion message as shown below. Select the message and press Enter to fill the field with the current date and time formatted as a timestamp string. You can edit the string to specify another date or time.
Studio calculates the current time value once per application run, the first time you invoke this feature. If you have other timestamp fields in the same Manual Input view, Studio inserts the same timestamp.
-
To enter data in a blob field, the view provides a free-form text field where you can enter multiple lines of text to represent the blob data.
-
To enter data in a field of type list, see Manual Input of List Fields.
-
To enter data in a field of type tuple, see Manual Input of Tuple Fields.
The text in parentheses to the right of each field reminds you of the field's data type.
When you enter valid values for each of the fields in the tuple, Studio enables the Send Data button. When clicked, a tuple with the specified values is enqueued to the selected input stream of the running application. Depending on the application design, sending the data may or may not produce a result in the Application Output view.
Click the Send non-string blank fields as null button
to automatically
send nulls for fields you do not enter, except string fields. The next time you run
or debug an application, this button's on or off state remains as last selected.
By default, each tuple you send is logged to the Application Input view. You can disable this by unchecking the Log to Application Input check box.
When you enter invalid values in a field, an error icon (
) appears in two
places:
-
To the left of the stream name at the top of the view.
-
To the left of each field that contains an input error.
Hover the mouse over the error icon next to a field to show a tooltip that indicates why the field value is incorrect.
When there are errors, the view also shows an errors detected link at the top. Hover over the link to see in one place the tooltips for all errors in the view. Click the link to take the cursor to the fields with errors, so you can fix them.
In the example below, the value entered for the price
field is text, but the field's data type is double. The date field has an extra zero in the year portion of the otherwise
valid timestamp entry. Notice that Studio disables the Send
Data button until the problems are fixed.
|
The Manual Input view has two ways to enter data for fields with data type list:
-
The default list input method, with collapsible list fields and a variable number of element fields.
-
An alternate lists as text input method, where you enter an entire list in a single field in array notation.
The default list input method is illustrated for the prices, symbols, and numshares fields in the following example:
|
Notice the following points about the default input method:
-
The
pricesandsymbolsfields are shown open, and with two elements each. -
All lists have a variable number of elements from zero to hundreds. We could have shown as an example six
priceselements with foursymbolselements. There is no reason the number of elements has to be the same for each list in a tuple. -
The
numsharesfield is shown collapsed. Collapse a list field by clicking the arrow to the left of its name. -
Add an element to a list by clicking the green plus sign on the left of the field's element type.
-
Remove an element by clicking the red X on the left of the element name.
-
Set the entire list field to null by clicking the triangle to the left of the green plus sign. Notice that the
numsharesfield is set to null, and the tooltip for the Set this field to null button is shown. (Setting a list field null is not the same as setting one or more elements of the list to null.)
See Null Lists for a discussion of null lists compared to empty lists.
Click the Enter Lists as Text button
to input lists in array notation with comma-separated values. The
lists as text input method is illustrated in the following example, which shows the
same values being entered as the example above.
|
Notice the following points about the lists as text input method:
-
Use CSV input style, with the entire list enclosed in brackets and list elements separated by commas.
-
For list(string) fields, you do not need to enclose each element in quotes.
-
Notice that the
numsharesfield is designated null, which is the same action performed by the Set this field to null button in the default input method.Setting a list field to null is not the same as setting one or more list elements to null. To enter a list field with a single null element, enter
[null]. A list field with three null elements would be[null, null, null].
See Null Lists for a discussion of null lists compared to empty lists.
The Manual Input view shows fields of type tuple with sub-fields for entering data.
The tuple field is collapsible, and you can set the entire tuple to null, or set
individual fields to null. Tuple field input is illustrated in the following example,
which shows two fields of type tuple, buy_order and
sell_order, both having the same schema:
|
Notice the following points about entering tuple field data:
-
Collapse a tuple field by clicking the arrow to the left of its name. Both tuple fields in the example above are shown open.
-
The schema of the tuple field is shown on the right, across from the field's name.
-
Set the entire tuple field to null by clicking the triangle to the left of the field's schema. (Remember that setting a tuple field null is not the same as setting all the sub-fields of the tuple field to null.)
The following example shows the first tuple, buy_order, with data, and the second tuple, sell_order, set null.
|
See Null Tuples for a discussion of null tuples compared to empty tuples.
The schema for a stream might have a field of type tuple that contains a sub-field, also of type tuple. This inner tuple sub-field is known as a nested tuple. The following example illustrates manual input of a tuple with a nested tuple.
|
The schema of the stream WrappedTuple has three
fields:
| Field | Type |
|---|---|
| time_recd | timestamp |
| source | string |
| recd_field | tuple |
The schema of the recd_field field has two fields:
| Field | Type |
|---|---|
| time_sent | timestamp |
| embedded_trade | tuple |
Finally, the inner tuple field embedded_trade has four
fields:
| Field | Type |
|---|---|
| symbol | string |
| numshares | double |
| pershare | double |
| custid | int |
