Main Content

eventStreamImportOptions

Create options for importing events from stream into MATLAB

Since R2022b

    This function requires Streaming Data Framework for MATLAB® Production Server™.

    Description

    Use eventStreamImportOptions only when you are unable to detect import options from the stream object using detectImportOptions.

    opts = eventStreamImportOptions(VariableNames=names,VariableTypes=types) sets the VariableNames and VariableTypes properties of the ImportOptions object opts. names and types are the names and data types of event variables that you want to import from an event stream into MATLAB.

    example

    opts = eventStreamImportOptions(KeyVariable=kv) sets the KeyVariable property of the ImportOptions object opts.

    opts = eventStreamImportOptions(VariableNames=names,VariableTypes=types,KeyVariable=kv) sets the VariableNames, VariableTypes, andKeyVariable properties.

    Examples

    collapse all

    Create a schema for importing data from an event stream into MATLAB by specifying variable names and their data types to use during the import.

    names = ["x","symbol"];
    types = ["double","string"];

    Construct an ImportOptions object using this data import schema.

    opts = eventStreamImportOptions(VariableNames=names,VariableTypes=types)
    opts = 
    
      ImportOptions with properties:
    
                VariableNames: ["x"    "symbol"]
                VariableTypes: ["double"    "string"]
                  KeyVariable: [0×0 string]
        SelectedVariableNames: ["x"    "symbol"]

    Apply the import options when creating a KafkaStream object.

    ks = kafkaStream("kafka.host.com",9092,"Your_Kafka_Topic",ImportOptions=opts);

    Import the data. The "Your_Kafka_Topic" topic must have events with exactly two variables, x and symbol. In addition, the types of these variables must be convertible to double and string, respectively. Otherwise, readtimetable throws an error.

    tt = readtimetable(ks);

    Input Arguments

    collapse all

    Variable names to use when importing variables from the event stream into a timetable, specified as a string scalar, string array, or cell array of character vectors.

    Data Types: string | cell

    Data type of variables to use when importing variables from the event stream into a timetable, specified as a string scalar, string array, or cell array of character vectors containing a set of valid data type names. The VariableTypes property designates the data types.

    Data Types: string | cell

    Event key variable name to use when importing variables from the event stream into a timetable, specified as a string scalar or character vector.

    Data Types: string | char

    Version History

    Introduced in R2022b