use of org.apache.hyracks.data.std.accessors.PointableBinaryHashFunctionFactory in project asterixdb by apache.
the class ListItemBinaryHashFunctionFactory method createBinaryHashFunction.
public IBinaryHashFunction createBinaryHashFunction(final ATypeTag itemTypeTag, final boolean ignoreCase) {
return new IBinaryHashFunction() {
private IBinaryHashFunction lowerCaseStringHash = new PointableBinaryHashFunctionFactory(UTF8StringLowercasePointable.FACTORY).createBinaryHashFunction();
private IBinaryHashFunction genericBinaryHash = MurmurHash3BinaryHashFunctionFamily.INSTANCE.createBinaryHashFunction(0);
private GrowableArray taggedBytes = new GrowableArray();
@Override
public int hash(byte[] bytes, int offset, int length) throws HyracksDataException {
ATypeTag tag = itemTypeTag;
int skip = 0;
if (itemTypeTag == ATypeTag.ANY) {
tag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]);
skip = 1;
}
switch(tag) {
case STRING:
{
if (ignoreCase) {
return lowerCaseStringHash.hash(bytes, offset + skip, length - skip);
}
}
default:
{
if (itemTypeTag != ATypeTag.ANY) {
// add the itemTypeTag in front of the data
try {
resetTaggedBytes(bytes, offset, length);
return genericBinaryHash.hash(taggedBytes.getByteArray(), 0, length + 1);
} catch (IOException e) {
throw new HyracksDataException(e);
}
} else {
return genericBinaryHash.hash(bytes, offset, length);
}
}
}
}
private void resetTaggedBytes(byte[] data, int offset, int length) throws IOException {
taggedBytes.reset();
taggedBytes.getDataOutput().writeByte(itemTypeTag.serialize());
taggedBytes.getDataOutput().write(data, offset, length);
}
};
}
use of org.apache.hyracks.data.std.accessors.PointableBinaryHashFunctionFactory in project asterixdb by apache.
the class FullTextContainsEvaluator method initializeFullTextContains.
private void initializeFullTextContains() {
// We use a hash set to store tokens from the right side (query predicate).
// Initialize necessary variables.
hashFunc = new PointableBinaryHashFunctionFactory(UTF8StringLowercaseTokenPointable.FACTORY).createBinaryHashFunction();
keyEntry = new BinaryEntry();
// Parameter: number of bucket, frame size, hashFunction, Comparator, byte array
// that contains the key (this array will be set later.)
rightHashSet = new BinaryHashSet(HASH_SET_SLOT_SIZE, HASH_SET_FRAME_SIZE, hashFunc, strLowerCaseTokenCmp, null);
tokenizerForLeftArray = BinaryTokenizerFactoryProvider.INSTANCE.getWordTokenizerFactory(ATypeTag.STRING, false, true).createTokenizer();
}
Aggregations