Table of Contents

Search

  1. Preface
  2. Introduction to Edge Data Streaming Custom Entity Types
  3. Managing Custom Entity Types
  4. Custom Entities from Maven Archetypes
  5. REST APIs
  6. HTTP Request and Response Parameters
  7. Sample JSON Requests and Responses
  8. Glossary

Developer Guide

Developer Guide

Implementing the VDSTransform Interface

Implementing the VDSTransform Interface

Implement the
VDSTransform
interface to create a custom transformation type.
The following sample code shows how to implement the
VDSTransform
interface:
package ...; import java.io.IOException; import java.nio.ByteBuffer; import com.informatica.vds.api.VDSConfiguration; import com.informatica.vds.api.VDSEvent; import com.informatica.vds.api.VDSEventList; import com.informatica.vds.api.VDSTransform; public class CustomTransform implements VDSTransform { @Override public void close() throws IOException { /* Clean up. */ ... } /* Apply a transformation to the data. */ @Override public void apply(VDSEvent vdsevent, VDSEventList vdsevents) throws Exception { /* Get data from the VDSEvent object. */ ByteBuffer bytebuff = vdsevent.getBuffer(); byte[] totdata = new byte[vdsevent.getBufferLen()]; bytebuff.get(totdata); /* Transform the data. */ ... /* Assume that the transformation returns a byte[] that is stored in a * variable named transformedData. Add transformedData to the event * list. */ vdsevents.addEvent(transformedData, transformedData.length); } /* Initialize the VDSTarget object. */ @Override public void open(VDSConfiguration vdsconfiguration) throws Exception { /* The internal name of the key. */ String exprVal = "ExpressionFromUI"; /* The default value of the key. */ String exprDefault = "DefaultValue" /* Retrieve the value of the key ExpressionFromUI. */ String Expr = vdsconfiguration.optString(exprVal, exprDefault); /* Similarly, retrieve other keys. */ ... /* Create or initialize the transformation by using * the configuration. */ ... } }
The following sample code shows how to implement the
VDSTransform
interface to shard events:
package ...; import java.io.IOException; import java.nio.ByteBuffer; import com.informatica.vds.api.VDSConfiguration; import com.informatica.vds.api.VDSEvent; import com.informatica.vds.api.VDSEventList; import com.informatica.vds.api.VDSTransform; public class CustomTransform implements VDSTransform { @Override public void close() throws IOException { /* Clean up. */ ... } /* Apply a transformation to the data. */ @Override public void apply(VDSEvent vdsevent, VDSEventList vdsevents) throws Exception { System.out.println("Applying transform..."); ByteBuffer byteBuffer = vdsevent.getBuffer(); byte[] event = new byte[vdsevent.getBufferLen()]; byteBuffer.get(event); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); outputStream.write(event); outputStream.write(txtField.getBytes()); System.out.println("Transformed data " + outputStream.toString()); Map<String, String> map = new HashMap(); String str = new String(event); if (str.contains("secure")) { map.put("transportTopic", "SecureTopic"); } else { map.put("transportTopic", "NonsecureTopic"); } vdsevents.addEvent(outputStream.toByteArray(), outputStream.toByteArray().length, map); } @Override public void open(VDSConfiguration vdsconfiguration) throws Exception { /* The internal name of the key. */ String exprVal = "ExpressionFromUI"; /* The default value of the key. */ String exprDefault = "DefaultValue" /* Retrieve the value of the key ExpressionFromUI. */ String Expr = vdsconfiguration.optString(exprVal, exprDefault); /* Similarly, retrieve other keys. */ ... /* Create or initialize the transformation by using * the configuration. */ ... } }

0 COMMENTS

We’d like to hear from you!