org.apache.datasketches.pig.hash

## Class MurmurHash3

- java.lang.Object
- - org.apache.pig.EvalFunc<org.apache.pig.data.Tuple>
  - - org.apache.datasketches.pig.hash.MurmurHash3

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

Computes a 128-bit MurmurHash3 hash of data input types: String, DataByteArray, Long, Integer, Double, and Float. The 2nd optional parameter can be a Long or Integer seed. The 3rd optional parameter can be a positive Integer modulus divisor. If the divisor is provided, the Integer modulus remainder is computed on the entire 128-bit hash output treated as if it were a 128-bit positive value.

### 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
`MurmurHash3()`

### Method Summary

All Methods Instance Methods Concrete Methods
`org.apache.pig.data.Tuple` `exec(org.apache.pig.data.Tuple input)` Top Level Exec Function.
`org.apache.pig.impl.logicalLayer.schema.Schema` `outputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input)` The output consists of two longs, or 128 bits, plus the result of the modulo division if specified.

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

`allowCompileTimeCalculation, finish, getArgToFuncMapping, getCacheFiles, getInputSchema, getLoadCaster, getLogger, getPigLogger, getReporter, getReturnType, getSchemaName, getSchemaType, getShipFiles, isAsynchronous, needEndOfAllInputProcessing, 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

#### MurmurHash3

    public MurmurHash3()

### Method Detail

#### exec

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

Top Level Exec Function.

This method accepts an object to be hashed and returns a Hash Result Tuple.

Hash Input Tuple

- Tuple: TUPLE (Must contain 1 field and may contain 2 or 3):
  - index 0: Object to be hashed: one of String, DataByteArray, Long, Integer, Double, Float.
  - index 1: Seed: Long or Integer
  - index 2: Modulus divisor: Integer; must be positive.

Any other input tuple will throw an exception!

Hash Result Tuple

- Tuple: TUPLE (Contains 3 fields)
  - index 0: Long: LONG: The 1st 64 bits of the hash.
  - index 1: Long: LONG: The 2nd 64 bits of the hash.
  - index 2: Integer: INTEGER: Result of modulo operation, -1 if not computed.

Specified by:
  `exec` in class `org.apache.pig.EvalFunc<org.apache.pig.data.Tuple>`
Parameters:
  `input` - Hash Input Tuple. If null or empty exec returns null.
Throws:
  `IOException`

#### outputSchema

    public org.apache.pig.impl.logicalLayer.schema.Schema outputSchema(org.apache.pig.impl.logicalLayer.schema.Schema input)

The output consists of two longs, or 128 bits, plus the result of the modulo division if specified.

Overrides:
  `outputSchema` in class `org.apache.pig.EvalFunc<org.apache.pig.data.Tuple>`