use of org.apache.hyracks.data.std.util.BinaryEntry in project asterixdb by apache.
the class SimilarityJaccardEvaluator method probeHashMap.
protected int probeHashMap(AbstractAsterixListIterator probeIter, int buildListSize, int probeListSize) throws HyracksDataException {
// Probe phase: Probe items from second list, and compute intersection size.
int intersectionSize = 0;
while (probeIter.hasNext()) {
byte[] buf = probeIter.getData();
int off = probeIter.getPos();
int len = probeIter.getItemLen();
keyEntry.set(buf, off, len);
BinaryEntry entry = hashMap.get(keyEntry);
if (entry != null) {
// Increment second value.
int firstValInt = IntegerPointable.getInteger(entry.getBuf(), entry.getOffset());
// Irrelevant for the intersection size.
if (firstValInt == 0) {
continue;
}
int secondValInt = IntegerPointable.getInteger(entry.getBuf(), entry.getOffset() + 4);
// Subtract old min value.
intersectionSize -= (firstValInt < secondValInt) ? firstValInt : secondValInt;
secondValInt++;
// Add new min value.
intersectionSize += (firstValInt < secondValInt) ? firstValInt : secondValInt;
IntegerPointable.setInteger(entry.getBuf(), entry.getOffset() + 4, secondValInt);
}
probeIter.next();
}
return intersectionSize;
}
use of org.apache.hyracks.data.std.util.BinaryEntry in project asterixdb by apache.
the class SimilarityJaccardEvaluator method buildHashMap.
protected void buildHashMap(AbstractAsterixListIterator buildIter) throws HyracksDataException {
// Build phase: Add items into hash map, starting with first list.
// Value in map is a pair of integers. Set first integer to 1.
IntegerPointable.setInteger(valEntry.getBuf(), 0, 1);
while (buildIter.hasNext()) {
byte[] buf = buildIter.getData();
int off = buildIter.getPos();
int len = buildIter.getItemLen();
keyEntry.set(buf, off, len);
BinaryEntry entry = hashMap.put(keyEntry, valEntry);
if (entry != null) {
// Increment value.
int firstValInt = IntegerPointable.getInteger(entry.getBuf(), entry.getOffset());
IntegerPointable.setInteger(entry.getBuf(), entry.getOffset(), firstValInt + 1);
}
buildIter.next();
}
}
Aggregations