nfsantos commented on code in PR #1148:
URL: https://github.com/apache/jackrabbit-oak/pull/1148#discussion_r1358022250


##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/FulltextIndex.java:
##########
@@ -465,67 +470,13 @@ public void remove() {
         @Override
         public IndexRow next() {
             final IndexRow pathRow = pathCursor.next();
-            return new IndexRow() {
-
-                @Override
-                public boolean isVirtualRow() {
-                    return currentRow.isVirutal;
-                }
-
-                @Override
-                public String getPath() {
-                    String sub = pathRow.getPath();
-                    if (isVirtualRow()) {
-                        return sub;
-                    } else if (!"".equals(pathPrefix) && 
PathUtils.denotesRoot(sub)) {
-                        return pathPrefix;
-                    } else if (PathUtils.isAbsolute(sub)) {
-                        return pathPrefix + sub;
-                    } else {
-                        return PathUtils.concat(pathPrefix, sub);
-                    }
-                }
 
-                @Override
-                public PropertyValue getValue(String columnName) {
-                    // overlay the score
-                    if (QueryConstants.JCR_SCORE.equals(columnName)) {
-                        return PropertyValues.newDouble(currentRow.score);
-                    }
-                    if (QueryConstants.REP_SPELLCHECK.equals(columnName) || 
QueryConstants.REP_SUGGEST.equals(columnName)) {
-                        return PropertyValues.newString(currentRow.suggestion);
-                    }
-                    if 
(QueryConstants.OAK_SCORE_EXPLANATION.equals(columnName)) {
-                        return 
PropertyValues.newString(currentRow.explanation);
-                    }
-                    if (columnName.startsWith(QueryConstants.REP_EXCERPT)) {
-                        String excerpt = currentRow.excerpts.get(columnName);
-                        if (excerpt != null) {
-                            return PropertyValues.newString(excerpt);
-                        }
-                    }
-                    if (columnName.startsWith(QueryConstants.REP_FACET)) {
-                        try {
-                            List<Facet> facets = 
currentRow.getFacets(numberOfFacets, columnName);
-                            if (facets != null) {
-                                JsopWriter writer = new JsopBuilder();
-                                writer.object();
-                                for (Facet f : facets) {
-                                    
writer.key(f.getLabel()).value(f.getCount());
-                                }
-                                writer.endObject();
-                                return 
PropertyValues.newString(writer.toString());
-                            }
-                        } catch (IOException | RuntimeException e) {
-                            LOG.warn(e.getMessage());
-                            LOG.debug(e.getMessage(), e);
-                            throw new RuntimeException(e);
-                        }
-                    }
-                    return pathRow.getValue(columnName);
-                }
+            // we need to copy the reference to the current row here,
+            // otherwise all the returned IndexRows might reference the same 
row
+            // (and then we use _this_ row in the IndexRow class below)

Review Comment:
   This comment may not be needed anymore. Or else rephrase it because the copy 
of the reference is now implicit, it's just the standard call-by-value Java 
behaviour so maybe there is no need for comments. 



-- 
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]

Reply via email to