Developing Apama Applications > Developing Apama Applications in EPL > Using Correlator Plug-ins in EPL > About the chunk data type
About the chunk data type
The chunk data type allows data to be referenced from EPL that has no equivalent EPL type. It is not possible to perform operations on data of type chunk from EPL directly; the chunk data type exists purely to allow data output by one external library function to pass through to another function. Apama does not modify the internal structure of chunk values in any way. As long as a receiving function expects the same type as that output by the original function, any complex data structure can be passed around using this mechanism.
To use chunks with plug-ins, you must first declare a variable of type chunk. You can then assign the chunk to the return value of an external function or use the chunk as the value of the out parameter in the function call.
The following example illustrates this. The complex.test4() method prints output to stdout. The source code for complex_plugin is in the samples\correlator_plugin\cpp directory of your Apama installation directory.
monitor ComplexPluginTest {
 
   // Load the plugin
  import "complex_plugin" as complex;
 
   // Opaque chunk value
   chunk myChunk;
 
   action onload() {
      // Generate a new chunk
      myChunk := complex.test3(20);
 
      // Do some computation on the chunk
      complex.test4(myChunk);
   }
}
Although the chunk type was designed to support unknown data types, it is also a useful mechanism to improve performance. Where data returned by external plug-in functions does not need to be accessed from EPL, using a chunk can cut down on unnecessary data type conversion. For example, suppose the output of a localtime() method is a 9-element array of type float. While you could declare this output to be of type sequence<float>, there is no need to do so because the EPL never accesses the value. Consequently, you can declare the output to be of type chunk and avoid an unnecessary conversion from native array to EPL sequence and back again.
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.