Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixing some problems

By the end of this chapter you will be able to:

Table of Contents

Use an output multiplier to break out a record into multiple output records

So far your model has merged data from two files, then grouped and sorted the records. You now have a stream that has the latest data about the TV package that each customer has.

You now want to get a set of records for each channel all the channels that the customer has ordered. This data is currently in a You will look up the data about the channels provided by each package in database table. PhixFlow can look-up this data. To make sure that PhixFlow finds all the channels, you will use an ouptut multiplier You will use this to break out each customer record, in Latest Package Update, into a set of records for each channel that the customer has orderedoutput multiplier.

Load data from a database table

First, you will load the database table SOURCE_PACKAGE_CHANNELS into a stream. Your model will then have the full list of channels available in each package.

...

  1. In the repository browser, expand the list of Datasources.
  2. Drag the datasource called Rating and Billing into your model.
  3. In your model, hover your mouse pointer over Rating and Billing and click 
    Insert excerpt
    _show_tables
    _show_tables
    nopaneltrue
    . PhixFlow displays a list of the tables available in this database. You can resize the list to make it easier to browse.
  4. Right-click on SOURCE_PACKAGE_CHANNELS and select 
    Insert excerpt
    _create_collector
    _create_collector
    nopaneltrue
    . PhixFlow adds a new database collector  to the model, and gives it the same name as the source data table, SOURCE_PACKAGE_CHANNELS. In the settings → Basic Settings section → Statement Expression, you can see the database query is: 
        select * from SOURCE_PACKAGE_CHANNELS.
  5. Hover your mouse pointer over the new database collector, and click 
    Insert excerpt
    _add_stream_with_attributes
    _add_stream_with_attributes
    nopaneltrue
    . PhixFlow adds a new stream to your model and also gives it the name SOURCE_PACKAGE_CHANNELS. In the settings → Attributes section, you can see that the data has two attributes (columns): Package and Channel.
  6. To load the data into the stream, run analysis on this section of the model and check the data has loaded.

    Expand
    titleHow?
    1. Hover your mouse pointer over the SOURCE_PACKAGE_CHANNELS stream , click 
      Insert excerpt
      _run_analysis
      _run_analysis
      nopaneltrue
       then click YES to confirm.
    2. When PhixFlow notifies you that the analysis is finished, hover your mouse pointer over the stream again.
    3. Click 
      Insert excerpt
      _show_stream_views
      _show_stream_views
      nopaneltrue
      .
    4. In the drop-down list, select 
      Insert excerpt
      _default_view
      _default_view
      nopaneltrue
      .  PhixFlow displays the data.

    Snapshot of your model and the data you have loaded:

Take a moment to look at this data. For each package, there are multiple channels included. For example, the News package includes Channel 1, Channel 2, Science 2 and NewsExtra.

Add

...

another stream 

Update your model to add a stream. This stream will take all the data that we have merged, sorted and grouped in the model so far.

  1. Hover your mouse pointer over the Latest Package Update stream and click 
    Insert excerpt
    _add_stream
    _add_stream
    nopaneltrue
    .
  2. In Basic Settings, set the Name to Latest Package All Channels.
  3. Drag all the attributes from Latest Package Update to the settings for Latest Package All Channels.

    Expand
    titleHow?
    1. Hover your mouse pointer over the stream Latest Package Update.
    2. In the context toolbar, click 
      Insert excerpt
      _stream_attributes
      _stream_attributes
      nopaneltrue
      . Phixflow lists the data attributes (column titles) for this stream.
    3. Select all the attributes and drag them into the Latest Package All Channels settings → Attributes section.


  4. Click 
    Insert excerpt
    _finish
    _finish
    nopaneltrue
     to save and close the settings tab.
  5. Close the attributes list.

Supplement the stream with look-up data

You now need to add to the data in the Latest Package All Channels stream. You will use a look-up pipe to add information about the Packagethe channels provided by a package. PhixFlow needs to know how the data in the source stream matches the data in the receiving stream.

  1. In the model, add a pipe from SOURCE_PACKAGE_CHANNELS to Latest Package All Channels. PhixFlow opens the settings for the new pipe.
  2. In the Basic Settings section, set:
    • Name: find_channels
    • Type: Look-up
  3. In the Order/Index section, click 
    Insert excerpt
    _stream_attributes
    _stream_attributes
    nopaneltrue
    . PhixFlow opens two lists of attributes: one list for the source stream and another for the receiving stream. Image Removed
  4. From the source stream list, on the left, drag PACKAGE into the Order/Index grid.
    Image Modified
    This tells PhixFlow about the key column in the source stream. Notice that PhixFlow has added a line to the Order/Index grid.
  5. From the receiving stream list, on the right, drag Package over the top of the line in the Order/Index grid.
    Image Modified
    This tells PhixFlow about the matching key column in the receiving stream. Notice that PhixFlow has now added the Index Expression _outPackage. However, we do not want PhixFlow to use _outPackagebecause output multipliers are calculated before the output is generated. We need it to use the data on the input.
  6. In the Order/Index section, double-click the new line that PhixFlow has added. PhixFlow opens the settings for the PACKAGE attribute. Set:
    •  Basic Settings → Index Expression from _out.Package to: to in.Package.
    • Click 
      Insert excerpt
      _finish
      _finish
      nopaneltrue
       to save  save and close the settings tab.
  7. Close the attribute list.
  8. In the pipe settings, click 
    Insert excerpt
    _finish
    _finish
    nopaneltrue
     to save and close the settings tab.
  9. In the model toolbar, click 
    Insert excerpt
    _save
    _save
    nopaneltrue
     to save your model.

At this point, if you run your model (I think) it will find each customer, e.g. C010, and will read that the customer has the News package. It will then look-up the channel for this to find News: Channel 1. But having done one look-up for the customer it will move onto the next customer.When you run your model, PhixFlow

This means that the lookup will match records in the reference data (SOURCE_PACKAGE_CHANNELS) where PACKAGE = Package from the input pipe in ?????
We must do this, rather than using the value of Package from the output because we are GOING TO USE the lookup to drive an output multiplier – and output multipliers are calculated before the output is generated

Set an output multiplier

What is an output Multiplier

An output multiplier tells PhixFlow to process the same record multiple times, each time producing a new record. This is called breaking-out a record. In this case we want PhixFlow to keep processing the same customer record until it has found all the channels. This means our single input record for each customer :

C010News

becomes multiple output records, like this:

C010

...

NewsChannel 1

...

C010NewsChannel 2

...

C010NewsChannel 3

...

C010NewsNewsExtra

The output multiplier needs to know:

  • which pipe it will use -  find_channels.
  • what data you want to add - the channels.

The stream also needs to know about create the new column to create for the channel information.

...