Make the ChildrenQuery and ParentQuery not rely on the fact that score of 0 means that there isn't a match.
This commit is contained in:
parent
1285894f5f
commit
04675f85cf
|
@ -54,7 +54,6 @@ import java.util.Set;
|
||||||
* all parent documents having the same uid value that is collected in the first phase are emitted as hit including
|
* all parent documents having the same uid value that is collected in the first phase are emitted as hit including
|
||||||
* a score based on the aggregated child scores and score type.
|
* a score based on the aggregated child scores and score type.
|
||||||
*/
|
*/
|
||||||
// TODO We use a score of 0 to indicate a doc was not scored in uidToScore, this means score of 0 can be problematic, if we move to HPCC, we can use lset/...
|
|
||||||
public class ChildrenQuery extends Query {
|
public class ChildrenQuery extends Query {
|
||||||
|
|
||||||
private final String parentType;
|
private final String parentType;
|
||||||
|
@ -292,7 +291,9 @@ public class ChildrenQuery extends Query {
|
||||||
|
|
||||||
HashedBytesArray uid = idTypeCache.idByDoc(currentDocId);
|
HashedBytesArray uid = idTypeCache.idByDoc(currentDocId);
|
||||||
currentScore = uidToScore.get(uid);
|
currentScore = uidToScore.get(uid);
|
||||||
if (currentScore != 0) {
|
if (uidToScore.containsKey(uid)) {
|
||||||
|
// Can use lget b/c uidToScore is only used by one thread at the time (via CacheRecycler)
|
||||||
|
currentScore = uidToScore.lget();
|
||||||
remaining--;
|
remaining--;
|
||||||
return currentDocId;
|
return currentDocId;
|
||||||
}
|
}
|
||||||
|
@ -312,8 +313,9 @@ public class ChildrenQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedBytesArray uid = idTypeCache.idByDoc(currentDocId);
|
HashedBytesArray uid = idTypeCache.idByDoc(currentDocId);
|
||||||
currentScore = uidToScore.get(uid);
|
if (uidToScore.containsKey(uid)) {
|
||||||
if (currentScore != 0) {
|
// Can use lget b/c uidToScore is only used by one thread at the time (via CacheRecycler)
|
||||||
|
currentScore = uidToScore.lget();
|
||||||
remaining--;
|
remaining--;
|
||||||
return currentDocId;
|
return currentDocId;
|
||||||
} else {
|
} else {
|
||||||
|
@ -350,10 +352,11 @@ public class ChildrenQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedBytesArray uid = idTypeCache.idByDoc(currentDocId);
|
HashedBytesArray uid = idTypeCache.idByDoc(currentDocId);
|
||||||
currentScore = uidToScore.get(uid);
|
if (uidToScore.containsKey(uid)) {
|
||||||
if (currentScore != 0) {
|
// Can use lget b/c uidToScore is only used by one thread at the time (via CacheRecycler)
|
||||||
remaining--;
|
currentScore = uidToScore.lget();
|
||||||
currentScore /= uidToCount.get(uid);
|
currentScore /= uidToCount.get(uid);
|
||||||
|
remaining--;
|
||||||
return currentDocId;
|
return currentDocId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -372,10 +375,11 @@ public class ChildrenQuery extends Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
HashedBytesArray uid = idTypeCache.idByDoc(currentDocId);
|
HashedBytesArray uid = idTypeCache.idByDoc(currentDocId);
|
||||||
currentScore = uidToScore.get(uid);
|
if (uidToScore.containsKey(uid)) {
|
||||||
if (currentScore != 0) {
|
// Can use lget b/c uidToScore is only used by one thread at the time (via CacheRecycler)
|
||||||
remaining--;
|
currentScore = uidToScore.lget();
|
||||||
currentScore /= uidToCount.get(uid);
|
currentScore /= uidToCount.get(uid);
|
||||||
|
remaining--;
|
||||||
return currentDocId;
|
return currentDocId;
|
||||||
} else {
|
} else {
|
||||||
return nextDoc();
|
return nextDoc();
|
||||||
|
|
|
@ -46,7 +46,6 @@ import java.util.Set;
|
||||||
* connects the matching parent docs to the related child documents
|
* connects the matching parent docs to the related child documents
|
||||||
* using the {@link IdReaderTypeCache}.
|
* using the {@link IdReaderTypeCache}.
|
||||||
*/
|
*/
|
||||||
// TODO We use a score of 0 to indicate a doc was not scored in uidToScore, this means score of 0 can be problematic, if we move to HPCC, we can use lset/...
|
|
||||||
public class ParentQuery extends Query {
|
public class ParentQuery extends Query {
|
||||||
|
|
||||||
private final Query originalParentQuery;
|
private final Query originalParentQuery;
|
||||||
|
@ -278,8 +277,9 @@ public class ParentQuery extends Query {
|
||||||
if (uid == null) {
|
if (uid == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
currentScore = uidToScore.get(uid);
|
if (uidToScore.containsKey(uid)) {
|
||||||
if (currentScore != 0) {
|
// Can use lget b/c uidToScore is only used by one thread at the time (via CacheRecycler)
|
||||||
|
currentScore = uidToScore.lget();
|
||||||
return currentChildDoc;
|
return currentChildDoc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,11 +295,14 @@ public class ParentQuery extends Query {
|
||||||
if (uid == null) {
|
if (uid == null) {
|
||||||
return nextDoc();
|
return nextDoc();
|
||||||
}
|
}
|
||||||
currentScore = uidToScore.get(uid);
|
|
||||||
if (currentScore == 0) {
|
if (uidToScore.containsKey(uid)) {
|
||||||
|
// Can use lget b/c uidToScore is only used by one thread at the time (via CacheRecycler)
|
||||||
|
currentScore = uidToScore.lget();
|
||||||
|
return currentChildDoc;
|
||||||
|
} else {
|
||||||
return nextDoc();
|
return nextDoc();
|
||||||
}
|
}
|
||||||
return currentChildDoc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue