<?xml version="1.0" encoding="UTF-8"?>
<!--
     # Licensed Materials - Property of IBM
     # Copyright IBM Corp. 2017
-->
<operatorModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.ibm.com/xmlns/prod/streams/spl/operator" xmlns:cmn="http://www.ibm.com/xmlns/prod/streams/spl/common" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/streams/spl/operator operatorModel.xsd">
  <cppOperatorModel>
    <context>
      <description>
Score customers using a model.
Customers that are a good match are submitted to port 0 (&#x27;MATCH&#x27;)
while customers that are a near match are submitted to port 1 (&#x27;NEAR_MATCH&#x27;).
        
Customers that are not a good or near match are not submitted to any port. 
# Python
    @spl.primitive(output_ports=['MATCH', 'NEAR_MATCH'])
    class SelectCustomers(spl.PrimitiveOperator):
        &quot;&quot;&quot;Score customers using a model.
        Customers that are a good match are submitted to port 0 (&#x27;MATCH&#x27;)
        while customers that are a near match are submitted to port 1 (&#x27;NEAR_MATCH&#x27;).
                
        Customers that are not a good or near match are not submitted to any port. 
        &quot;&quot;&quot;
        def __init__(self, match, near_match):
            self.match = match
            self.near_match = near_match
        
        @spl.input_port()
        def customers(self, **tuple_):
            customer_score = self.score(tuple_)
            if customer_score &gt;= self.match:
                self.submit(&#x27;MATCH&#x27;, tuple_)
            elif customer_score &gt;= self.near_match:
                self.submit(&#x27;NEAR_MATCH&#x27;, tuple_)
    
        def score(self, **customer):
            # Real scoring omitted
            score = random.random()
            return score

      </description>
      <iconUri size="16">../../opt/.splpy/icons/python-powered16.gif</iconUri>
      <iconUri size="32">../../opt/.splpy/icons/python-powered32.gif</iconUri>
      <metrics>
      </metrics>
      <libraryDependencies>
        <library>
          <cmn:description>SPLPY header</cmn:description>
          <cmn:managedLibrary>
            <cmn:includePath>../../opt/.splpy/include</cmn:includePath>
          </cmn:managedLibrary>
        </library>
        <library>
          <cmn:description>Python libraries.</cmn:description>
          <cmn:managedLibrary>
            <cmn:command>../../opt/.splpy/common/pyversion3.sh</cmn:command>
          </cmn:managedLibrary>
        </library>
      </libraryDependencies>
      <providesSingleThreadedContext>Always</providesSingleThreadedContext>
      <allowCustomLogic>false</allowCustomLogic>
    </context>
    <parameters>
      <allowAny>false</allowAny>
      
 <parameter>
  <name>match</name>
  <description></description>
  <optional>false</optional>
  <rewriteAllowed>true</rewriteAllowed>
  <expressionMode>AttributeFree</expressionMode>
  <type></type>
  <cardinality>1</cardinality>
 </parameter>
 <parameter>
  <name>near_match</name>
  <description></description>
  <optional>false</optional>
  <rewriteAllowed>true</rewriteAllowed>
  <expressionMode>AttributeFree</expressionMode>
  <type></type>
  <cardinality>1</cardinality>
 </parameter>
    </parameters>
    <inputPorts>

<inputPortSet>
  <description>
                                    customers
  </description>
  <tupleMutationAllowed>false</tupleMutationAllowed>
  <windowingMode>NonWindowed</windowingMode>
  <windowPunctuationInputMode>Oblivious</windowPunctuationInputMode>
  <cardinality>1</cardinality>
  <optional>false</optional>
</inputPortSet>

    </inputPorts>
    <outputPorts>

<outputPortSet>
  <description>
    __SPLPY__OUTPORT_DESCRIPTION__SPLPY__
  </description>
  <expressionMode>Nonexistent</expressionMode>
  <autoAssignment>false</autoAssignment>
  <completeAssignment>false</completeAssignment>
  <rewriteAllowed>true</rewriteAllowed>
  <windowPunctuationOutputMode>Free</windowPunctuationOutputMode>
  <tupleMutationAllowed>false</tupleMutationAllowed>
  <cardinality>1</cardinality>
  <optional>false</optional>
</outputPortSet>

<outputPortSet>
  <description>
    __SPLPY__OUTPORT_DESCRIPTION__SPLPY__
  </description>
  <expressionMode>Nonexistent</expressionMode>
  <autoAssignment>false</autoAssignment>
  <completeAssignment>false</completeAssignment>
  <rewriteAllowed>true</rewriteAllowed>
  <windowPunctuationOutputMode>Free</windowPunctuationOutputMode>
  <tupleMutationAllowed>false</tupleMutationAllowed>
  <cardinality>1</cardinality>
  <optional>false</optional>
</outputPortSet>

    </outputPorts>
  </cppOperatorModel>
</operatorModel>
