From a20fbf713018337498608d83ac8d5f5e9adfac75 Mon Sep 17 00:00:00 2001 From: Shai Erera Date: Sun, 10 Feb 2013 10:07:23 +0000 Subject: [PATCH] remove redundat stuff from facet Consts git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1444522 13f79535-47bb-0310-9956-ffa450edef68 --- .../facet/taxonomy/directory/Consts.java | 26 ------------------- .../directory/DirectoryTaxonomyReader.java | 7 +++-- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/Consts.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/Consts.java index 527c3898b42..c86431f65e4 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/Consts.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/Consts.java @@ -1,7 +1,5 @@ package org.apache.lucene.facet.taxonomy.directory; -import org.apache.lucene.index.FieldInfo; -import org.apache.lucene.index.StoredFieldVisitor; import org.apache.lucene.util.BytesRef; /* @@ -30,30 +28,6 @@ abstract class Consts { static final String FIELD_PAYLOADS = "$payloads$"; static final String PAYLOAD_PARENT = "p"; static final BytesRef PAYLOAD_PARENT_BYTES_REF = new BytesRef(PAYLOAD_PARENT); - static final char[] PAYLOAD_PARENT_CHARS = PAYLOAD_PARENT.toCharArray(); - - /** - * 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 class LoadFullPathOnly extends StoredFieldVisitor { - private String fullPath; - - @Override - public void stringField(FieldInfo fieldInfo, String value) { - fullPath = value; - } - - @Override - public Status needsField(FieldInfo fieldInfo) { - return fullPath == null ? Status.YES : Status.STOP; - } - - public String getFullPath() { - return fullPath; - } - } /** * Delimiter used for creating the full path of a category from the list of diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java index 2f1fb30dfbd..34bca4320a6 100644 --- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java +++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/directory/DirectoryTaxonomyReader.java @@ -8,12 +8,12 @@ import java.util.logging.Logger; import org.apache.lucene.facet.collections.LRUHashMap; import org.apache.lucene.facet.taxonomy.CategoryPath; import org.apache.lucene.facet.taxonomy.TaxonomyReader; -import org.apache.lucene.facet.taxonomy.directory.Consts.LoadFullPathOnly; import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.DocsEnum; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.MultiFields; +import org.apache.lucene.index.StoredDocument; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.store.Directory; import org.apache.lucene.util.BytesRef; @@ -320,9 +320,8 @@ public class DirectoryTaxonomyReader extends TaxonomyReader { } } - final LoadFullPathOnly loader = new LoadFullPathOnly(); - indexReader.document(ordinal, loader); - CategoryPath ret = new CategoryPath(loader.getFullPath(), delimiter); + StoredDocument doc = indexReader.document(ordinal); + CategoryPath ret = new CategoryPath(doc.get(Consts.FULL), delimiter); synchronized (categoryCache) { categoryCache.put(catIDInteger, ret); }