org.apache.datasketches.pig.theta

## Class JaccardSimilarity

- java.lang.Object
- - org.apache.pig.EvalFunc<org.apache.pig.data.Tuple>
  - - org.apache.datasketches.pig.theta.JaccardSimilarity

    public class JaccardSimilarity
    extends org.apache.pig.EvalFunc<org.apache.pig.data.Tuple>

This is a Pig UDF that performs the JaccardSimilarity Operation on two given Sketches.

Author:
  eshcar

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.pig.EvalFunc

`org.apache.pig.EvalFunc.SchemaType`

### Field Summary

### Fields inherited from class org.apache.pig.EvalFunc

`log, pigLogger, reporter, returnType`

### Constructor Summary

Constructors
Constructor and Description
`JaccardSimilarity()` Default constructor to make pig validation happy.
`JaccardSimilarity(long seed)` Base constructor.
`JaccardSimilarity(String seedStr)` String constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`org.apache.pig.data.Tuple` `exec(org.apache.pig.data.Tuple inputTuple)` Top Level Exec Function.

### Methods inherited from class org.apache.pig.EvalFunc

`allowCompileTimeCalculation, finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLoadCaster, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, getShipFiles, isAsynchronous, needEndOfAllInputProcessing, outputSchema, progress, setEndOfAllInput, setInputSchema, setPigLogger, setReporter, setUDFContextSignature, warn`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### JaccardSimilarity

    public JaccardSimilarity()

Default constructor to make pig validation happy. Assumes:

- See Default Update Seed

#### JaccardSimilarity

    public JaccardSimilarity(String seedStr)

String constructor.

Parameters:
  `seedStr` - See Update Hash Seed

#### JaccardSimilarity

    public JaccardSimilarity(long seed)

Base constructor.

Parameters:
  `seed` - See Update Hash Seed.

### Method Detail

#### exec

    public org.apache.pig.data.Tuple exec(org.apache.pig.data.Tuple inputTuple)
                                   throws IOException

Top Level Exec Function.

This method accepts a Sketch JaccardSimilarityAB Input Tuple and returns a Tuple {LowerBound, Estimate, UpperBound} of the Jaccard ratio. The Upper and Lower bounds are for a confidence interval of 95.4% or +/- 2 standard deviations.

Sketch JaccardSimilarityAB Input Tuple

- Tuple: TUPLE (Must contain 2 fields):
  Java data type: Pig DataType: Description
  - index 0: DataByteArray: BYTEARRAY: Sketch A
  - index 1: DataByteArray: BYTEARRAY: Sketch B

Any other input tuple will throw an exception!

Tuple {LowerBound, Estimate, UpperBound}

- Tuple: TUPLE (Contains 3 fields)
  - index 0: Double: DOUBLE = The lower bound of the Jaccard Similarity.
  - index 1: Double: DOUBLE = The estimation of the Jaccard Similarity.
  - index 2: Double: DOUBLE = The upper bound of the Jaccard Similarity.

Specified by:
  `exec` in class `org.apache.pig.EvalFunc<org.apache.pig.data.Tuple>`
Throws:
  `org.apache.pig.backend.executionengine.ExecException` - from Pig.
  `IOException`