You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2011/08/17 17:58:45 UTC
svn commit: r1158790 - in
/lucene/dev/branches/fieldtype_conflicted/modules/facet/src/java/org/apache/lucene/facet/taxonomy/lucene:
Consts.java LuceneTaxonomyReader.java
Author: mikemccand
Date: Wed Aug 17 15:58:45 2011
New Revision: 1158790
URL: http://svn.apache.org/viewvc?rev=1158790&view=rev
Log:
LUCENE-2308: cutover facets from FieldSelector to StoredFieldVisitor
Modified:
lucene/dev/branches/fieldtype_conflicted/modules/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/Consts.java
lucene/dev/branches/fieldtype_conflicted/modules/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/LuceneTaxonomyReader.java
Modified: lucene/dev/branches/fieldtype_conflicted/modules/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/Consts.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/modules/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/Consts.java?rev=1158790&r1=1158789&r2=1158790&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/modules/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/Consts.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/modules/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/Consts.java Wed Aug 17 15:58:45 2011
@@ -1,7 +1,6 @@
package org.apache.lucene.facet.taxonomy.lucene;
-import org.apache.lucene.document.FieldSelector;
-import org.apache.lucene.document.FieldSelectorResult;
+import org.apache.lucene.index.StoredFieldVisitor;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -31,17 +30,26 @@ abstract class Consts {
static final char[] PAYLOAD_PARENT_CHARS = PAYLOAD_PARENT.toCharArray();
/**
- * The following is a "field selector", an object which tells Lucene to
- * extract only a single field rather than a whole document.
+ * The following is a "stored field visitor", an object
+ * which tells Lucene to extract only a single field
+ * rather than a whole document.
*/
- public static final FieldSelector fullPathSelector = new FieldSelector() {
- public FieldSelectorResult accept(String fieldName) {
- if (fieldName.equals(FULL)) {
- return FieldSelectorResult.LOAD_AND_BREAK;
- }
- return FieldSelectorResult.NO_LOAD;
- }
- };
+ public static final class LoadFullPathOnly extends StoredFieldVisitor {
+ private String fullPath;
+
+ public boolean stringField(FieldInfo fieldInfo, IndexInput in, int numUTF8Bytes) throws IOException {
+ final byte[] bytes = new byte[numUTF8Bytes];
+ in.readBytes(bytes, 0, bytes.length);
+ fullPath = new String(bytes, "UTF-8");
+
+ // Stop loading:
+ return true;
+ }
+
+ public String getFullPath() {
+ return fullPath;
+ }
+ }
/**
* Delimiter used for creating the full path of a category from the list of
Modified: lucene/dev/branches/fieldtype_conflicted/modules/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/LuceneTaxonomyReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/fieldtype_conflicted/modules/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/LuceneTaxonomyReader.java?rev=1158790&r1=1158789&r2=1158790&view=diff
==============================================================================
--- lucene/dev/branches/fieldtype_conflicted/modules/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/LuceneTaxonomyReader.java (original)
+++ lucene/dev/branches/fieldtype_conflicted/modules/facet/src/java/org/apache/lucene/facet/taxonomy/lucene/LuceneTaxonomyReader.java Wed Aug 17 15:58:45 2011
@@ -295,8 +295,9 @@ public class LuceneTaxonomyReader implem
if (catID<0 || catID>=indexReader.maxDoc()) {
return null;
}
- ret = indexReader.document(catID, Consts.fullPathSelector)
- .get(Consts.FULL);
+ final LoadFullPathOnly loader = new LoadFullPathOnly();
+ indexReader.document(catID, loader);
+ ret = loader.getFullPath();
} finally {
indexReaderLock.readLock().unlock();
}