AlexanderSaydakov commented on code in PR #644:
URL: https://github.com/apache/datasketches-java/pull/644#discussion_r1931271199
##########
src/main/java/org/apache/datasketches/theta/IntersectionImpl.java:
##########
@@ -448,27 +446,16 @@ private void performIntersect(final Sketch sketchIn) {
final long[] matchSet = new long[ min(curCount_,
sketchIn.getRetainedEntries(true)) ];
int matchSetCount = 0;
- if (sketchIn.isOrdered()) {
- //ordered compact, which enables early stop
- for (int i = 0; i < arrLongsIn; i++ ) {
- final long hashIn = cacheIn[i];
- //if (hashIn <= 0L) continue; //<= 0 should not happen
- if (hashIn >= thetaLong_) {
- break; //early stop assumes that hashes in input sketch are ordered!
- }
+ HashIterator it = sketchIn.iterator();
+ while (it.next()) {
+ final long hashIn = it.get();
+ if (hashIn < thetaLong_) {
final int foundIdx = hashSearch(hashTable, lgArrLongs_, hashIn);
- if (foundIdx == -1) { continue; }
- matchSet[matchSetCount++] = hashIn;
- }
- }
- else {
- //either unordered compact or hash table
- for (int i = 0; i < arrLongsIn; i++ ) {
- final long hashIn = cacheIn[i];
- if (hashIn <= 0L || hashIn >= thetaLong_) { continue; }
- final int foundIdx = hashSearch(hashTable, lgArrLongs_, hashIn);
- if (foundIdx == -1) { continue; }
- matchSet[matchSetCount++] = hashIn;
+ if (foundIdx != -1) {
+ matchSet[matchSetCount++] = hashIn;
+ }
+ } else {
+ if (sketchIn.isOrdered()) { break; } // early stop
Review Comment:
Generally I prefer not to introduce aliases, but if you think this can help,
I can do that. Perhaps we could try measuring the effect one day.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]