Using the TableLookup UDX to Prefetch a Partitioned Part of a Kafka Topic

<< Click to Display Table of Contents >>

Navigation:  Integrating SQLstream Blaze with Other Systems > Reading Data into s-Server > Reading from Other Sources  > Reading from Kafka >

Using the TableLookup UDX to Prefetch a Partitioned Part of a Kafka Topic

Previous pageReturn to chapter overviewNext page

Once you have read in data from Kafka and created a view of this data, as in Using the Kafka ECDA for Fault Tolerance, you can use the TableLookup UDX to prefetch a partitioned portion of a database to form a preloaded cache. The code below prefetches zip codes.

CREATE OR REPLACE FUNCTION "getZipcode"(

     inputRows CURSOR,

        dsName VARCHAR(64),

     tableName VARCHAR(128),

       colName VARCHAR(128),

     cacheSize INTEGER,

  prefetchRows BOOLEAN,

  fuzzyLookups BOOLEAN)

  RETURNS TABLE(

       inputRows.*,

       "zipcode" CHAR(5))

  LANGUAGE JAVA

  PARAMETER STYLE SYSTEM DEFINED JAVA

  NO SQL

  EXTERNAL NAME '"TableLookup":com.sqlstream.plugin.tablelookup.TableLookup.lookup';

 

You can then use the function to prefetch zip code from a partitioned portion of a database:

CREATE OR REPLACE VIEW "transactionAndZipcode" AS

SELECT STREAM

FROM TABLE("getZipcode(CURSOR(SELECT STREAM * FROM "sourceData"), 'customerDb', 'address', 'recipientId', 10000000, true, false));