======================================== Transform Sample ======================================== This sample is intended to demonstrate the use of a transform to manipulate the contents of a single data feed before it arrives to a table. Note: This sample builds on the lv-sample-preprocessor project. If you have not previously done so, load the preprocessor project for reference. A transform is new data source for a table and does not affect any other data sources that might already be defined. However, if there is a preprocessor defined for the table, then the preprocessor will also affect the data from the transform. ================= SETUP ================= This sample starts with the same files as the preprocessor sample, in which a preprocessor was inserted to add some calculated fields to a data feed. The Transform sample adds a new feed with similar data as the other feed, and is intended to go through the same preprocessor. However, this new data feed has the similar fields named differently, so it must be transformed so that the existing preprocessor and data table will recognize it. The data feed that we want to match contains these fields: - symbol, dateTime, price, shares, exchange But our data feed has these fields: - Symbol, Time, Price, Volume To transform the data, you must map corresponding fields, plus add the missing field. The basic strategy uses a transform to map the fields. A transform takes the data from one table, sends the data through an EventFlow application, and treats what comes out as a new data source. ================== RUN THE SAMPLE ================== To run this sample in Studio, you can: - In the LiveView Project Viewer, click the green Run button in the upper right. - Right-click any of the lvconf table configuration files in the Project Explorer view and select Run As > Run Configurations > Run (in the invoked Run Configurations dialog). - Right-click the project folder itself, and select Run As > LiveView Fragment To run this sample from the command line outside of Studio, you must: - Package this sample's LiveView fragment project into a fragment archive. - Create a separate StreamBase Application project, and set the pom.xml for that project to depend on the fragment archive created in the previous step. - Create a separate StreamBase Application archive file. - Install that archive into a StreamBase Runtime node. - Start the node. These steps are described in more detail in the "Deploy with epadmin" page of the Concepts Overview in the StreamBase documentation. When the server displays a message such as: "all tables have loaded," the server is ready for connections from clients such as the LiveView Desktop. ================= PROJECT FILES ================= Trades.lvconf: The primary project table. This is from the same file in the preprocessor sample, with the additional data-source defined. The new data-source is defined to be a transform from the table NSDQTable, processed through the EventFlow application NSDQTransform.sbapp. NSDQDataSource.lvconf: Declares the new data source. In a real application, it would refer to a data feed. In this sample, it refers to the feed simulation, the parts of which are contained within the DataSourceSims folder. NSDQTable.lvconf: Because a transform must be based on another table, this is a simple data table which just wraps our new data feed. DefaultTableSpace.lvconf: The default settings for all data tables for our project (of which there is only one). Even though we are using only default values, we always have a TableSpace in any project. NSDQTransform.sbapp, NSDQTransform.sblayout: This is an EventFlow application which does the transform. While it is very simple, there are a few extra pieces that are required of any transform. - INPUT DataIn: The name of the input must match that declared in the transform element in the lvconf that is referencing the transform (Trades.lvconf, in this case). Also, this input must declare the following fields in addition to the fields that are in the input feed that is being preprocessed. -- PublisherID, string -- PublisherSN, long -- CQSReferredCount, long - OUTPUT DataOut: The name of the output must match that declared in the transform element in the lvconf that is referencing the transform (Trades.lvconf, in this case). Also, this output must pass through the extra fields that are declared in the input, plus add one more, CQSDataUpdatePredicate, which can be assigned an empty string. - MAP map: This accepts the inputs and generates the required outputs. Some fields' values come from input fields, and two (CQSReferredCount and exchange) are set to a fixed value. Note that this also adds the fields "change" and "changeDir," which it sets to fixed values. These values will be overwritten by the preprocessor. However, they must be included here because the LiveView type-checking system expects the output of the transform to match the list of fields in the table. (This is actually unnecessary, in this case, because the preprocessor will fill in those fields, but the type-checking system does not expect a transform with a preprocessor.) NYSEDataSource.lvconf, TradesPreprocessor.sbapp, TradesPreprocessor.layout, sbd.sbconf: These are all identical to their counterparts in the preprocessor sample. DataSourceSims: Within this folder are the pieces that make up the simulation data feed for this sample. In a real LiveView application, the files NSDQDataSource.lvconf and NYSEDataSource.lvconf would reference an external data feed rather than the simulation. The NYSE files are identical as in the preprocessor sample, and the NSDQ files have the same purpose as those for NYSE. Both NSDQ.sbfs and NYSE.sbfs feed their data according to a timestamp column, to simulate a live data feed. Also, they both have "Include in synchronized timestamp group" checked so that the two feeds will have their time-based feeds synchronized to the same time. engine.conf - a LiveView configuration file to set up JVM arguments for this sample.