SPL File sampling.spl

com.ibm.streamsx.plumbing > com.ibm.streamsx.plumbing 1.0.0 > com.ibm.streamsx.plumbing.sampling > sampling.spl

Content

Operators
Functions

Composites

composite RandomSample(output OUT; input IN)

Randomly sample a stream. Fraction of tuples to pass through is specified by parameter fraction, defaults to 0.01 (1%) . I.e. random selection of 1% of tuples are passed through.

The output stream's schema must be the same as the input schema.

Parameters

Input Ports

Output Ports

SPL Source Code


 public composite RandomSample(input IN; output OUT)
 {
 	param
 	  expression<float64> $fraction : 0.01fl;
 	graph
 	  (stream<IN> OUT) as Sample = Functor(IN) {
            logic state: float64 _fraction = $fraction;
            
 	  	param
 	  	filter : random() < _fraction;
 	  }
 }

   

Functions

float64 percent(float64 percent)

Convert a percent to a fraction by dividing by 100.0.

Parameters

Returns

SPL Source Code


 public float64 percent(float64 percent) {
     return percent / 100.0fl;
 }