Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LucenePropertyIndex.java Tue Sep 25 12:24:15 2018 @@ -18,6 +18,7 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene; +import javax.jcr.PropertyType; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -29,31 +30,26 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicReference; - -import javax.jcr.PropertyType; +import java.util.function.Predicate; import com.google.common.base.Joiner; import com.google.common.collect.AbstractIterator; import com.google.common.collect.FluentIterable; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; -import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Queues; import com.google.common.collect.Sets; -import com.google.common.primitives.Chars; import org.apache.jackrabbit.oak.api.PropertyValue; -import org.apache.jackrabbit.oak.api.Result.SizePrecision; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.commons.PerfLogger; -import org.apache.jackrabbit.oak.commons.json.JsopBuilder; -import org.apache.jackrabbit.oak.commons.json.JsopWriter; -import org.apache.jackrabbit.oak.plugins.index.Cursors; -import org.apache.jackrabbit.oak.plugins.index.Cursors.PathCursor; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.IndexingRule; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexPlanner.PlanResult; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexPlanner.PropertyIndexResult; +import org.apache.jackrabbit.oak.plugins.index.lucene.util.fv.SimSearchUtils; +import org.apache.jackrabbit.oak.plugins.index.search.FieldNames; +import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; +import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; +import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition.IndexingRule; import org.apache.jackrabbit.oak.plugins.index.lucene.property.HybridPropertyIndexLookup; import org.apache.jackrabbit.oak.plugins.index.lucene.score.ScorerProviderFactory; import org.apache.jackrabbit.oak.plugins.index.lucene.spi.FulltextQueryTermsProvider; @@ -62,22 +58,23 @@ import org.apache.jackrabbit.oak.plugins import org.apache.jackrabbit.oak.plugins.index.lucene.util.PathStoredFieldVisitor; import org.apache.jackrabbit.oak.plugins.index.lucene.util.SpellcheckHelper; import org.apache.jackrabbit.oak.plugins.index.lucene.util.SuggestHelper; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.fv.SimSearchUtils; -import org.apache.jackrabbit.oak.plugins.memory.PropertyValues; -import org.apache.jackrabbit.oak.spi.query.Cursor; -import org.apache.jackrabbit.oak.spi.query.Filter; -import org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction; -import org.apache.jackrabbit.oak.spi.query.IndexRow; -import org.apache.jackrabbit.oak.spi.query.QueryConstants; -import org.apache.jackrabbit.oak.spi.query.QueryIndex; -import org.apache.jackrabbit.oak.spi.query.QueryIndex.AdvanceFulltextQueryIndex; -import org.apache.jackrabbit.oak.spi.query.QueryLimits; +import org.apache.jackrabbit.oak.plugins.index.search.IndexNode; +import org.apache.jackrabbit.oak.plugins.index.search.PropertyDefinition; +import org.apache.jackrabbit.oak.plugins.index.search.SizeEstimator; +import org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndex; +import org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndexPlanner.PlanResult; +import org.apache.jackrabbit.oak.plugins.index.search.spi.query.FulltextIndexPlanner.PropertyIndexResult; import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextAnd; import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextContains; import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextExpression; import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextOr; import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextTerm; import org.apache.jackrabbit.oak.spi.query.fulltext.FullTextVisitor; +import org.apache.jackrabbit.oak.spi.query.Cursor; +import org.apache.jackrabbit.oak.spi.query.Filter; +import org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction; +import org.apache.jackrabbit.oak.spi.query.QueryConstants; +import org.apache.jackrabbit.oak.spi.query.QueryLimits; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStateUtils; import org.apache.lucene.analysis.Analyzer; @@ -139,22 +136,21 @@ import static org.apache.jackrabbit.oak. import static org.apache.jackrabbit.oak.api.Type.STRING; import static org.apache.jackrabbit.oak.commons.PathUtils.denotesRoot; import static org.apache.jackrabbit.oak.commons.PathUtils.getParentPath; -import static org.apache.jackrabbit.oak.plugins.index.lucene.FieldNames.ANALYZED_FIELD_PREFIX; -import static org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition.NATIVE_SORT_ORDER; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.EXCERPT_NODE_FIELD_NAME; +import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.TYPE_LUCENE; +import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexLookupUtil.LUCENE_INDEX_DEFINITION_PREDICATE; +import static org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition.NATIVE_SORT_ORDER; import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.VERSION; import static org.apache.jackrabbit.oak.plugins.index.lucene.TermFactory.newAncestorTerm; import static org.apache.jackrabbit.oak.plugins.index.lucene.TermFactory.newPathTerm; import static org.apache.jackrabbit.oak.plugins.memory.PropertyValues.newName; import static org.apache.jackrabbit.oak.spi.query.QueryConstants.JCR_PATH; import static org.apache.jackrabbit.oak.spi.query.QueryConstants.REP_EXCERPT; -import static org.apache.jackrabbit.oak.spi.query.QueryIndex.AdvancedQueryIndex; -import static org.apache.jackrabbit.oak.spi.query.QueryIndex.NativeQueryIndex; -import static org.apache.lucene.search.BooleanClause.Occur.MUST; -import static org.apache.lucene.search.BooleanClause.Occur.MUST_NOT; -import static org.apache.lucene.search.BooleanClause.Occur.SHOULD; +import static org.apache.lucene.search.BooleanClause.Occur.*; /** + * + * Used to query new (compatVersion 2) Lucene indexes. + * * Provides a QueryIndex that does lookups against a Lucene-based index * * <p> @@ -189,17 +185,14 @@ import static org.apache.lucene.search.B * @see org.apache.jackrabbit.oak.spi.query.QueryIndex * */ -public class LucenePropertyIndex implements AdvancedQueryIndex, QueryIndex, NativeQueryIndex, - AdvanceFulltextQueryIndex { +public class LucenePropertyIndex extends FulltextIndex { private static double MIN_COST = 2.1; private static final Logger LOG = LoggerFactory - .getLogger(LucenePropertyIndex.class); + .getLogger(LucenePropertyIndex.class); private static final PerfLogger PERF_LOGGER = - new PerfLogger(LoggerFactory.getLogger(LucenePropertyIndex.class.getName() + ".perf")); - - static final String ATTR_PLAN_RESULT = "oak.lucene.planResult"; + new PerfLogger(LoggerFactory.getLogger(LucenePropertyIndex.class.getName() + ".perf")); /** * Batch size for fetching results from Lucene queries. @@ -211,7 +204,7 @@ public class LucenePropertyIndex impleme private final ScorerProviderFactory scorerProviderFactory; private final Highlighter highlighter = new Highlighter(new SimpleHTMLFormatter("<strong>", "</strong>"), - new SimpleHTMLEncoder(), null); + new SimpleHTMLEncoder(), null); private final PostingsHighlighter postingsHighlighter = new PostingsHighlighter(); @@ -242,98 +235,6 @@ public class LucenePropertyIndex impleme } @Override - public List<IndexPlan> getPlans(Filter filter, List<OrderEntry> sortOrder, NodeState rootState) { - Collection<String> indexPaths = new LuceneIndexLookup(rootState).collectIndexNodePaths(filter); - List<IndexPlan> plans = Lists.newArrayListWithCapacity(indexPaths.size()); - for (String path : indexPaths) { - IndexNode indexNode = null; - try { - indexNode = tracker.acquireIndexNode(path); - - if (indexNode != null) { - IndexPlan plan = new IndexPlanner(indexNode, path, filter, sortOrder).getPlan(); - if (plan != null) { - plans.add(plan); - } - } - } catch (Exception e) { - LOG.error("Error getting plan for {}", path); - LOG.error("Exception:", e); - } finally { - if (indexNode != null) { - indexNode.release(); - } - } - } - return plans; - } - - @Override - public double getCost(Filter filter, NodeState root) { - throw new UnsupportedOperationException("Not supported as implementing AdvancedQueryIndex"); - } - - @Override - public String getPlan(Filter filter, NodeState root) { - throw new UnsupportedOperationException("Not supported as implementing AdvancedQueryIndex"); - } - - @Override - public String getPlanDescription(IndexPlan plan, NodeState root) { - Filter filter = plan.getFilter(); - IndexNode index = tracker.acquireIndexNode(getPlanResult(plan).indexPath); - checkState(index != null, "The Lucene index is not available"); - try { - FullTextExpression ft = filter.getFullTextConstraint(); - StringBuilder sb = new StringBuilder("lucene:"); - String path = getPlanResult(plan).indexPath; - sb.append(getIndexName(plan)) - .append("(") - .append(path) - .append(") "); - sb.append(getLuceneRequest(plan, augmentorFactory, null)); - if (plan.getSortOrder() != null && !plan.getSortOrder().isEmpty()) { - sb.append(" ordering:").append(plan.getSortOrder()); - } - if (ft != null) { - sb.append(" ft:(").append(ft).append(")"); - } - addSyncIndexPlan(plan, sb); - return sb.toString(); - } finally { - index.release(); - } - } - - private static void addSyncIndexPlan(IndexPlan plan, StringBuilder sb) { - PlanResult pr = getPlanResult(plan); - if (pr.hasPropertyIndexResult()) { - PropertyIndexResult pres = pr.getPropertyIndexResult(); - sb.append(" sync:(") - .append(pres.propertyName); - - if (!pres.propertyName.equals(pres.pr.propertyName)) { - sb.append("[").append(pres.pr.propertyName).append("]"); - } - - sb.append(" ").append(pres.pr); - sb.append(")"); - } - - if (pr.evaluateSyncNodeTypeRestriction()) { - sb.append(" sync:(nodeType"); - sb.append(" primaryTypes : ").append(plan.getFilter().getPrimaryTypes()); - sb.append(" mixinTypes : ").append(plan.getFilter().getMixinTypes()); - sb.append(")"); - } - } - - @Override - public Cursor query(final Filter filter, final NodeState root) { - throw new UnsupportedOperationException("Not supported as implementing AdvancedQueryIndex"); - } - - @Override public Cursor query(final IndexPlan plan, NodeState rootState) { if (plan.isDeprecated()) { LOG.warn("This index is deprecated: {}; it is used for query {}. " + @@ -343,8 +244,8 @@ public class LucenePropertyIndex impleme final Sort sort = getSort(plan); final PlanResult pr = getPlanResult(plan); QueryLimits settings = filter.getQueryLimits(); - Iterator<LuceneResultRow> itr = new AbstractIterator<LuceneResultRow>() { - private final Deque<LuceneResultRow> queue = Queues.newArrayDeque(); + Iterator<FulltextResultRow> itr = new AbstractIterator<FulltextResultRow>() { + private final Deque<FulltextResultRow> queue = Queues.newArrayDeque(); private final Set<String> seenPaths = Sets.newHashSet(); private ScoreDoc lastDoc; private int nextBatchSize = LUCENE_QUERY_BATCH_SIZE; @@ -353,7 +254,7 @@ public class LucenePropertyIndex impleme private int indexNodeId = -1; @Override - protected LuceneResultRow computeNext() { + protected FulltextResultRow computeNext() { while (!queue.isEmpty() || loadDocs()) { return queue.remove(); } @@ -361,8 +262,8 @@ public class LucenePropertyIndex impleme return endOfData(); } - private LuceneResultRow convertToRow(ScoreDoc doc, IndexSearcher searcher, Map<String, String> excerpts, Facets facets, - String explanation) throws IOException { + private FulltextResultRow convertToRow(ScoreDoc doc, IndexSearcher searcher, Map<String, String> excerpts, Facets facets, + String explanation) throws IOException { IndexReader reader = searcher.getIndexReader(); //TODO Look into usage of field cache for retrieving the path //instead of reading via reader if no of docs in index are limited @@ -392,8 +293,9 @@ public class LucenePropertyIndex impleme boolean shouldIncludeForHierarchy = shouldInclude(path, plan); LOG.trace("Matched path {}; shouldIncludeForHierarchy: {}", path, shouldIncludeForHierarchy); - return shouldIncludeForHierarchy? new LuceneResultRow(path, doc.score, excerpts, facets, explanation) - : null; + return shouldIncludeForHierarchy? new FulltextResultRow(path, doc.score, excerpts, + new LuceneFacetProvider(facets), explanation) + : null; } return null; } @@ -410,7 +312,7 @@ public class LucenePropertyIndex impleme ScoreDoc lastDocToRecord = null; - final IndexNode indexNode = acquireIndexNode(plan); + final LuceneIndexNode indexNode = acquireIndexNode(plan); checkState(indexNode != null); try { IndexSearcher searcher = getCurrentSearcher(indexNode); @@ -483,7 +385,7 @@ public class LucenePropertyIndex impleme explanation = searcher.explain(query, doc.doc).toString(); } - LuceneResultRow row = convertToRow(doc, searcher, excerpts, facets, explanation); + FulltextResultRow row = convertToRow(doc, searcher, excerpts, facets, explanation); if (row != null) { queue.add(row); } @@ -520,7 +422,7 @@ public class LucenePropertyIndex impleme prefix = ""; } if (filter.isAccessible(prefix + retrievedDoc.get(FieldNames.PATH))) { - queue.add(new LuceneResultRow(suggestion.string)); + queue.add(new FulltextResultRow(suggestion.string)); break; } } @@ -552,7 +454,7 @@ public class LucenePropertyIndex impleme prefix = ""; } if (filter.isAccessible(prefix + retrievedDoc.get(FieldNames.PATH))) { - queue.add(new LuceneResultRow(suggestion.key.toString(), suggestion.value)); + queue.add(new FulltextResultRow(suggestion.key.toString(), suggestion.value)); break; } } @@ -572,7 +474,7 @@ public class LucenePropertyIndex impleme return !queue.isEmpty(); } - private IndexSearcher getCurrentSearcher(IndexNode indexNode) { + private IndexSearcher getCurrentSearcher(LuceneIndexNode indexNode) { //The searcher once obtained is held till either cursor is finished //or if the index gets updated. It needs to be ensured that //searcher is obtained via this method only in this iterator @@ -581,7 +483,7 @@ public class LucenePropertyIndex impleme //For NRT case its fine to keep a reference to searcher i.e. not //acquire it for every loadDocs call otherwise with frequent change //the reset of lastDoc would happen very frequently. - //Upon IndexNode change i.e. when new async index update is detected + //Upon LuceneIndexNode change i.e. when new async index update is detected //the searcher would be refreshed as done earlier if (indexNodeId != indexNode.getIndexNodeId()){ //if already initialized then log about change @@ -601,37 +503,13 @@ public class LucenePropertyIndex impleme indexSearcher = null; } }; - SizeEstimator sizeEstimator = new SizeEstimator() { - @Override - public long getSize() { - IndexNode indexNode = acquireIndexNode(plan); - checkState(indexNode != null); - try { - IndexSearcher searcher = indexNode.getSearcher(); - LuceneRequestFacade luceneRequestFacade = getLuceneRequest(plan, augmentorFactory, searcher.getIndexReader()); - if (luceneRequestFacade.getLuceneRequest() instanceof Query) { - Query query = (Query) luceneRequestFacade.getLuceneRequest(); - TotalHitCountCollector collector = new TotalHitCountCollector(); - searcher.search(query, collector); - int totalHits = collector.getTotalHits(); - LOG.debug("Estimated size for query {} is {}", query, totalHits); - return totalHits; - } - LOG.debug("estimate size: not a Query: {}", luceneRequestFacade.getLuceneRequest()); - } catch (IOException e) { - LOG.warn("query via {} failed.", LucenePropertyIndex.this, e); - } finally { - indexNode.release(); - } - return -1; - } - }; + SizeEstimator sizeEstimator = getSizeEstimator(plan); if (pr.hasPropertyIndexResult() || pr.evaluateSyncNodeTypeRestriction()) { itr = mergePropertyIndexResult(plan, rootState, itr); } - return new LucenePathCursor(itr, plan, settings, sizeEstimator); + return new FulltextPathCursor(itr, plan, settings, sizeEstimator); } private static Query addDescendantClauseIfRequired(Query query, IndexPlan plan) { @@ -658,27 +536,6 @@ public class LucenePropertyIndex impleme return query; } - private static boolean shouldInclude(String docPath, IndexPlan plan) { - String path = getPathRestriction(plan); - - boolean include = true; - - Filter filter = plan.getFilter(); - switch (filter.getPathRestriction()) { - case EXACT: - include = path.equals(docPath); - break; - case DIRECT_CHILDREN: - include = PathUtils.getParentPath(docPath).equals(path); - break; - case ALL_CHILDREN: - include = PathUtils.isAncestor(path, docPath); - break; - } - - return include; - } - private Map<String, String> getExcerpt(Query query, Set<String> excerptFields, Analyzer analyzer, IndexSearcher searcher, ScoreDoc doc, FieldInfos fieldInfos) throws IOException { @@ -690,12 +547,12 @@ public class LucenePropertyIndex impleme excerptFields.forEach(columnName -> { String fieldName; if (REP_EXCERPT.equals(columnName)) { - fieldName = EXCERPT_NODE_FIELD_NAME; + fieldName = FulltextIndexConstants.EXCERPT_NODE_FIELD_NAME; } else { fieldName = columnName.substring(REP_EXCERPT.length() + 1, columnName.length() - 1); } - if (!EXCERPT_NODE_FIELD_NAME.equals(fieldName)) { + if (!FulltextIndexConstants.EXCERPT_NODE_FIELD_NAME.equals(fieldName)) { excerptFieldNames.add(fieldName); fieldNameToColumnNameMap.put(fieldName, columnName); } else { @@ -711,7 +568,7 @@ public class LucenePropertyIndex impleme for (IndexableField field : searcher.getIndexReader().document(docID).getFields()) { String name = field.name(); // postings highlighter can be used on analyzed fields with docs, freqs, positions and offsets stored. - if (name.startsWith(ANALYZED_FIELD_PREFIX) && fieldInfos.hasProx() && fieldInfos.hasOffsets()) { + if (name.startsWith(FieldNames.ANALYZED_FIELD_PREFIX) && fieldInfos.hasProx() && fieldInfos.hasOffsets()) { names.add(name); } } @@ -792,23 +649,54 @@ public class LucenePropertyIndex impleme } @Override - public NodeAggregator getNodeAggregator() { - return null; + protected LuceneIndexNode acquireIndexNode(String indexPath) { + return tracker.acquireIndexNode(indexPath); } - /** - * In a fulltext term for jcr:contains(foo, 'bar') 'foo' - * is the property name. While in jcr:contains(foo/*, 'bar') - * 'foo' is node name - * - * @return true if the term is related to node - */ - public static boolean isNodePath(String fulltextTermPath) { - return fulltextTermPath.endsWith("/*"); + @Override + protected LuceneIndexNode acquireIndexNode(IndexPlan plan) { + return (LuceneIndexNode)super.acquireIndexNode(plan); + } + + @Override + protected String getType() { + return TYPE_LUCENE; + } + + @Override + protected SizeEstimator getSizeEstimator(IndexPlan plan) { + return () -> { + LuceneIndexNode indexNode = acquireIndexNode(plan); + checkState(indexNode != null); + try { + IndexSearcher searcher = indexNode.getSearcher(); + LuceneRequestFacade luceneRequestFacade = getLuceneRequest(plan, augmentorFactory, searcher.getIndexReader()); + if (luceneRequestFacade.getLuceneRequest() instanceof Query) { + Query query = (Query) luceneRequestFacade.getLuceneRequest(); + TotalHitCountCollector collector = new TotalHitCountCollector(); + searcher.search(query, collector); + int totalHits = collector.getTotalHits(); + LOG.debug("Estimated size for query {} is {}", query, totalHits); + return totalHits; + } + LOG.debug("estimate size: not a Query: {}", luceneRequestFacade.getLuceneRequest()); + } catch (IOException e) { + LOG.warn("query via {} failed.", LucenePropertyIndex.this, e); + } finally { + indexNode.release(); + } + return -1; + }; } - private IndexNode acquireIndexNode(IndexPlan plan) { - return tracker.acquireIndexNode(getPlanResult(plan).indexPath); + @Override + protected Predicate<NodeState> getIndexDefinitionPredicate() { + return LUCENE_INDEX_DEFINITION_PREDICATE; + } + + @Override + protected String getFulltextRequestString(IndexPlan plan, IndexNode indexNode) { + return getLuceneRequest(plan, augmentorFactory, null).toString(); } private static Sort getSort(IndexPlan plan) { @@ -883,10 +771,6 @@ public class LucenePropertyIndex impleme } } - private static String getIndexName(IndexPlan plan) { - return PathUtils.getName(getPlanResult(plan).indexPath); - } - /** * Get the Lucene query for the given filter. * @@ -900,7 +784,7 @@ public class LucenePropertyIndex impleme Filter filter = plan.getFilter(); FullTextExpression ft = filter.getFullTextConstraint(); PlanResult planResult = getPlanResult(plan); - IndexDefinition defn = planResult.indexDefinition; + LuceneIndexDefinition defn = (LuceneIndexDefinition) planResult.indexDefinition; Analyzer analyzer = defn.getAnalyzer(); if (ft == null) { // there might be no full-text constraint @@ -961,7 +845,7 @@ public class LucenePropertyIndex impleme } if (qs.size() == 0 - && plan.getSortOrder() != null) { + && plan.getSortOrder() != null) { //This case indicates that query just had order by and no //property restriction defined. In this case property //existence queries for each sort entry @@ -1178,33 +1062,6 @@ public class LucenePropertyIndex impleme } } - private static int determinePropertyType(PropertyDefinition defn, PropertyRestriction pr) { - int typeFromRestriction = pr.propertyType; - if (typeFromRestriction == PropertyType.UNDEFINED) { - //If no explicit type defined then determine the type from restriction - //value - if (pr.first != null && pr.first.getType() != Type.UNDEFINED) { - typeFromRestriction = pr.first.getType().tag(); - } else if (pr.last != null && pr.last.getType() != Type.UNDEFINED) { - typeFromRestriction = pr.last.getType().tag(); - } else if (pr.list != null && !pr.list.isEmpty()) { - typeFromRestriction = pr.list.get(0).getType().tag(); - } - } - return getPropertyType(defn, pr.propertyName, typeFromRestriction); - } - - private static int getPropertyType(PropertyDefinition defn, String name, int defaultVal) { - if (defn.isTypeDefined()) { - return defn.getType(); - } - return defaultVal; - } - - private static PlanResult getPlanResult(IndexPlan plan) { - return (PlanResult) plan.getAttribute(ATTR_PLAN_RESULT); - } - private static Query createLikeQuery(String name, String first) { first = first.replace('%', WildcardQuery.WILDCARD_STRING); first = first.replace('_', WildcardQuery.WILDCARD_CHAR); @@ -1590,67 +1447,14 @@ public class LucenePropertyIndex impleme } } - /** - * Following chars are used as operators in Lucene Query and should be escaped - */ - private static final char[] LUCENE_QUERY_OPERATORS = {':' , '/', '!', '&', '|', '='}; - - /** - * Following logic is taken from org.apache.jackrabbit.core.query.lucene.JackrabbitQueryParser#parse(java.lang.String) - */ - static String rewriteQueryText(String textsearch) { - // replace escaped ' with just ' - StringBuilder rewritten = new StringBuilder(); - // the default lucene query parser recognizes 'AND' and 'NOT' as - // keywords. - textsearch = textsearch.replaceAll("AND", "and"); - textsearch = textsearch.replaceAll("NOT", "not"); - boolean escaped = false; - for (int i = 0; i < textsearch.length(); i++) { - char c = textsearch.charAt(i); - if (c == '\\') { - if (escaped) { - rewritten.append("\\\\"); - escaped = false; - } else { - escaped = true; - } - } else if (c == '\'') { - if (escaped) { - escaped = false; - } - rewritten.append(c); - } else if (Chars.contains(LUCENE_QUERY_OPERATORS, c)) { - rewritten.append('\\').append(c); - } else { - if (escaped) { - rewritten.append('\\'); - escaped = false; - } - rewritten.append(c); - } - } - return rewritten.toString(); - } - - private static String getPathRestriction(IndexPlan plan) { - Filter f = plan.getFilter(); - String pathPrefix = plan.getPathPrefix(); - if (pathPrefix.isEmpty()) { - return f.getPath(); - } - String relativePath = PathUtils.relativize(pathPrefix, f.getPath()); - return "/" + relativePath; - } - private static Query newDepthQuery(String path) { int depth = PathUtils.getDepth(path) + 1; return NumericRangeQuery.newIntRange(FieldNames.PATH_DEPTH, depth, depth, true, true); } @SuppressWarnings("Guava") - private static Iterator<LuceneResultRow> mergePropertyIndexResult(IndexPlan plan, NodeState rootState, - Iterator<LuceneResultRow> itr) { + private static Iterator<FulltextResultRow> mergePropertyIndexResult(IndexPlan plan, NodeState rootState, + Iterator<FulltextResultRow> itr) { PlanResult pr = getPlanResult(plan); HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(pr.indexPath, NodeStateUtils.getNode(rootState, pr.indexPath), plan.getPathPrefix(), false); @@ -1672,191 +1476,41 @@ public class LucenePropertyIndex impleme //No need for path restriction evaluation as thats taken care by PropertyIndex impl itself //via content mirror strategy - FluentIterable<LuceneResultRow> propIndex = paths - .transform(path -> new LuceneResultRow(path, 0, null, null, null)); + FluentIterable<FulltextResultRow> propIndex = paths + .transform(path -> new FulltextResultRow(path, 0, null, null, null)); //Property index itr should come first return Iterators.concat(propIndex.iterator(), itr); } - static class LuceneResultRow { - final String path; - final double score; - final String suggestion; - final boolean isVirutal; - final Map<String, String> excerpts; - final String explanation; - final Facets facets; - - LuceneResultRow(String path, double score, Map<String, String> excerpts, Facets facets, String explanation) { - this.explanation = explanation; - this.excerpts = excerpts; - this.facets = facets; - this.isVirutal = false; - this.path = path; - this.score = score; - this.suggestion = null; - } - - LuceneResultRow(String suggestion, long weight) { - this.isVirutal = true; - this.path = "/"; - this.score = weight; - this.suggestion = suggestion; - this.excerpts = null; - this.facets = null; - this.explanation = null; - } - - LuceneResultRow(String suggestion) { - this(suggestion, 1); - } - - @Override - public String toString() { - return String.format("%s (%1.2f)", path, score); - } - } - - /** - * A cursor over Lucene results. The result includes the path, - * and the jcr:score pseudo-property as returned by Lucene. - */ - static class LucenePathCursor implements Cursor { - - private static final int TRAVERSING_WARNING = Integer.getInteger("oak.traversing.warning", 10000); + static class LuceneFacetProvider implements FacetProvider { - private final Cursor pathCursor; - private final String pathPrefix; - LuceneResultRow currentRow; - private final SizeEstimator sizeEstimator; - private long estimatedSize; - private int numberOfFacets; - - LucenePathCursor(final Iterator<LuceneResultRow> it, final IndexPlan plan, QueryLimits settings, SizeEstimator sizeEstimator) { - pathPrefix = plan.getPathPrefix(); - this.sizeEstimator = sizeEstimator; - Iterator<String> pathIterator = new Iterator<String>() { - - private int readCount; - - @Override - public boolean hasNext() { - return it.hasNext(); - } - - @Override - public String next() { - currentRow = it.next(); - readCount++; - if (readCount % TRAVERSING_WARNING == 0) { - Cursors.checkReadLimit(readCount, settings); - LOG.warn("Index-Traversed {} nodes with filter {}", readCount, plan.getFilter()); - } - return currentRow.path; - } - - @Override - public void remove() { - it.remove(); - } - - }; + private final Facets facets; - PlanResult planResult = getPlanResult(plan); - pathCursor = new PathCursor(pathIterator, planResult.isUniquePathsRequired(), settings); - numberOfFacets = planResult.indexDefinition.getNumberOfTopFacets(); + LuceneFacetProvider(Facets facets) { + this.facets = facets; } - @Override - public boolean hasNext() { - return pathCursor.hasNext(); - } + public List<Facet> getFacets(int numberOfFacets, String columnName) throws IOException { + String facetFieldName = FulltextIndex.parseFacetField(columnName); - @Override - public void remove() { - pathCursor.remove(); - } + if (facets != null) { + ImmutableList.Builder res = new ImmutableList.Builder<Facet>(); + FacetResult topChildren = facets.getTopChildren(numberOfFacets, facetFieldName); - @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); + if (topChildren != null) { + for (LabelAndValue lav : topChildren.labelValues) { + res.add(new Facet( + lav.label, lav.value.intValue() + )); } - } - @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)) { - String facetFieldName = FacetHelper.parseFacetField(columnName); - Facets facets = currentRow.facets; - try { - if (facets != null) { - FacetResult topChildren = facets.getTopChildren(numberOfFacets, facetFieldName); - if (topChildren != null) { - JsopWriter writer = new JsopBuilder(); - writer.object(); - for (LabelAndValue lav : topChildren.labelValues) { - writer.key(lav.label).value(lav.value.intValue()); - } - writer.endObject(); - return PropertyValues.newString(writer.toString()); - } else { - return null; - } - } - } catch (Exception e) { - throw new RuntimeException(e); - } - } - return pathRow.getValue(columnName); + return res.build(); } - - }; - } - - - @Override - public long getSize(SizePrecision precision, long max) { - if (estimatedSize != 0) { - return estimatedSize; } - return estimatedSize = sizeEstimator.getSize(); + + return null; } } - }
Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneRequestFacade.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneRequestFacade.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneRequestFacade.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneRequestFacade.java Tue Sep 25 12:24:15 2018 @@ -19,7 +19,8 @@ package org.apache.jackrabbit.oak.plugin import org.jetbrains.annotations.NotNull; /** - * Facade for possible requests to be done to Lucene, like queries, spellchecking requests, etc.. + * Facade for possible requests to be done to Lucene, like queries, + * spellchecking requests, etc.. * * @param <T> the actual Lucene class representing the request / use case. */ Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/NodeStateAnalyzerFactory.java Tue Sep 25 12:24:15 2018 @@ -37,8 +37,8 @@ import org.apache.jackrabbit.oak.api.Blo import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; -import org.apache.jackrabbit.oak.plugins.index.lucene.util.ConfigUtil; import org.apache.jackrabbit.oak.plugins.index.lucene.util.TokenizerChain; +import org.apache.jackrabbit.oak.plugins.index.search.util.ConfigUtil; import org.apache.jackrabbit.oak.plugins.tree.factories.TreeFactory; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStateUtils; @@ -62,11 +62,13 @@ import static com.google.common.base.Pre import static com.google.common.collect.Lists.newArrayList; /** - * Constructs the TokenizerChain based on NodeState content. Approach taken is similar - * to one taken in org.apache.solr.schema.FieldTypePluginLoader which is implemented for - * xml based config. Resource lookup are performed via binary property access + * Constructs a Lucene Analyzer from nodes (based on NodeState content). + * + * Approach taken is similar to one taken in + * org.apache.solr.schema.FieldTypePluginLoader which is implemented for xml + * based config. Resource lookup are performed via binary property access */ -final class NodeStateAnalyzerFactory{ +final class NodeStateAnalyzerFactory { private static final AtomicBoolean versionWarningAlreadyLogged = new AtomicBoolean(false); private static final Set<String> IGNORE_PROP_NAMES = ImmutableSet.of( @@ -80,11 +82,11 @@ final class NodeStateAnalyzerFactory{ private final ResourceLoader defaultLoader; private final Version defaultVersion; - public NodeStateAnalyzerFactory(Version defaultVersion){ + NodeStateAnalyzerFactory(Version defaultVersion){ this(new ClasspathResourceLoader(NodeStateAnalyzerFactory.class.getClassLoader()), defaultVersion); } - public NodeStateAnalyzerFactory(ResourceLoader defaultLoader, Version defaultVersion) { + NodeStateAnalyzerFactory(ResourceLoader defaultLoader, Version defaultVersion) { this.defaultLoader = defaultLoader; this.defaultVersion = defaultVersion; } @@ -239,7 +241,7 @@ final class NodeStateAnalyzerFactory{ } private static CharArraySet loadStopwordSet(NodeState file, String name, - Version matchVersion) throws IOException { + Version matchVersion) throws IOException { Blob blob = ConfigUtil.getBlob(file, name); Reader stopwords = new InputStreamReader(blob.getNewStream(), IOUtils.CHARSET_UTF_8); try { Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakAnalyzer.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakAnalyzer.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakAnalyzer.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakAnalyzer.java Tue Sep 25 12:24:15 2018 @@ -25,6 +25,9 @@ import org.apache.lucene.analysis.miscel import org.apache.lucene.analysis.standard.StandardTokenizer; import org.apache.lucene.util.Version; +/** + * The default Lucene Analyzer used in Oak. + */ public class OakAnalyzer extends Analyzer { private final Version matchVersion; @@ -33,7 +36,7 @@ public class OakAnalyzer extends Analyze /** * Creates a new {@link OakAnalyzer} - * + * * @param matchVersion * Lucene version to match See * {@link #matchVersion above} Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakCodec.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakCodec.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakCodec.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/OakCodec.java Tue Sep 25 12:24:15 2018 @@ -38,7 +38,8 @@ import org.apache.lucene.codecs.lucene46 /** * Oak specific {@link org.apache.lucene.codecs.Codec}. * - * It simply mimics {@link org.apache.lucene.codecs.lucene46.Lucene46Codec} but with uncompressed {@link org.apache.lucene.codecs.StoredFieldsFormat}. + * It simply mimics {@link Lucene46Codec} but + * with uncompressed {@link StoredFieldsFormat}. */ public class OakCodec extends FilterCodec { Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/TermFactory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/TermFactory.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/TermFactory.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/TermFactory.java Tue Sep 25 12:24:15 2018 @@ -16,11 +16,11 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene; +import org.apache.jackrabbit.oak.plugins.index.search.FieldNames; import org.apache.lucene.index.Term; /** - * {@code TermFactory} is a factory for <code>Term</code> instances with - * frequently used field names. + * A factory for Lucene Term instances with frequently used field names. */ public final class TermFactory { Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/ActiveDeletedBlobCollectorFactory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/ActiveDeletedBlobCollectorFactory.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/ActiveDeletedBlobCollectorFactory.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/ActiveDeletedBlobCollectorFactory.java Tue Sep 25 12:24:15 2018 @@ -16,6 +16,26 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene.directory; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; + import com.google.common.base.Charsets; import com.google.common.base.Joiner; import com.google.common.collect.Lists; @@ -38,25 +58,6 @@ import org.jetbrains.annotations.NotNull import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.Properties; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; import static com.google.common.base.Preconditions.checkArgument; public class ActiveDeletedBlobCollectorFactory { Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/BlobFactory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/BlobFactory.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/BlobFactory.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/BlobFactory.java Tue Sep 25 12:24:15 2018 @@ -16,15 +16,15 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene.directory; +import java.io.IOException; +import java.io.InputStream; + import org.apache.jackrabbit.oak.api.Blob; import org.apache.jackrabbit.oak.plugins.blob.BlobStoreBlob; import org.apache.jackrabbit.oak.spi.blob.BlobOptions; import org.apache.jackrabbit.oak.spi.blob.BlobStore; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; -import java.io.IOException; -import java.io.InputStream; - import static org.apache.jackrabbit.oak.spi.blob.BlobOptions.UploadType.SYNCHRONOUS; public interface BlobFactory { Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/BufferedOakDirectory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/BufferedOakDirectory.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/BufferedOakDirectory.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/BufferedOakDirectory.java Tue Sep 25 12:24:15 2018 @@ -16,8 +16,14 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene.directory; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Arrays; +import java.util.Collection; +import java.util.Set; + import com.google.common.collect.Sets; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition; +import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition; import org.apache.jackrabbit.oak.plugins.index.lucene.directory.ActiveDeletedBlobCollectorFactory.BlobDeletionCallback; import org.apache.jackrabbit.oak.spi.blob.BlobStore; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; @@ -32,11 +38,6 @@ import org.jetbrains.annotations.Nullabl import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collection; -import java.util.Set; import static com.google.common.base.Preconditions.checkNotNull; import static java.util.Arrays.asList; import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; @@ -87,7 +88,7 @@ public final class BufferedOakDirectory private final String dataNodeName; - private final IndexDefinition definition; + private final LuceneIndexDefinition definition; private final OakDirectory base; @@ -102,16 +103,16 @@ public final class BufferedOakDirectory public BufferedOakDirectory(@NotNull NodeBuilder builder, @NotNull String dataNodeName, - @NotNull IndexDefinition definition, + @NotNull LuceneIndexDefinition definition, @Nullable BlobStore blobStore) { this(builder, dataNodeName, definition, blobStore, BlobDeletionCallback.NOOP); } public BufferedOakDirectory(@NotNull NodeBuilder builder, @NotNull String dataNodeName, - @NotNull IndexDefinition definition, + @NotNull LuceneIndexDefinition definition, @Nullable BlobStore blobStore, - @NotNull BlobDeletionCallback blobDeletionCallback) { + @NotNull ActiveDeletedBlobCollectorFactory.BlobDeletionCallback blobDeletionCallback) { this.blobFactory = blobStore != null ? BlobFactory.getBlobStoreBlobFactory(blobStore) : BlobFactory.getNodeBuilderBlobFactory(builder); Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/CopyOnReadDirectory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/CopyOnReadDirectory.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/CopyOnReadDirectory.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/CopyOnReadDirectory.java Tue Sep 25 12:24:15 2018 @@ -34,7 +34,6 @@ import java.util.stream.Collectors; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Sets; - import org.apache.jackrabbit.oak.commons.PerfLogger; import org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier; import org.apache.lucene.store.Directory; @@ -273,7 +272,7 @@ public class CopyOnReadDirectory extends } //Always remove old index file on close as it ensures that //no other IndexSearcher are opened with previous revision of Index due to - //way IndexTracker closes IndexNode. At max there would be only two IndexNode + //way IndexTracker closes LuceneIndexNode. At max there would be only two LuceneIndexNode //opened pinned to different revision of same Lucene index executor.execute(new Runnable() { @Override Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/CopyOnWriteDirectory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/CopyOnWriteDirectory.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/CopyOnWriteDirectory.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/CopyOnWriteDirectory.java Tue Sep 25 12:24:15 2018 @@ -42,7 +42,6 @@ import org.apache.jackrabbit.oak.commons import org.apache.jackrabbit.oak.commons.PerfLogger; import org.apache.jackrabbit.oak.commons.concurrent.NotifyingFutureTask; import org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopierClosedException; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FilterDirectory; import org.apache.lucene.store.IOContext; Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/DefaultDirectoryFactory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/DefaultDirectoryFactory.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/DefaultDirectoryFactory.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/DefaultDirectoryFactory.java Tue Sep 25 12:24:15 2018 @@ -22,8 +22,10 @@ package org.apache.jackrabbit.oak.plugin import java.io.File; import java.io.IOException; -import org.apache.jackrabbit.oak.plugins.index.lucene.*; +import org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier; +import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition; import org.apache.jackrabbit.oak.plugins.index.lucene.directory.ActiveDeletedBlobCollectorFactory.BlobDeletionCallback; +import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; import org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.lucene.store.Directory; @@ -31,7 +33,6 @@ import org.apache.lucene.store.FSDirecto import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.PERSISTENCE_PATH; import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.SUGGEST_DATA_CHILD_NAME; import static org.apache.lucene.store.NoLockFactory.getNoLockFactory; @@ -44,14 +45,14 @@ public class DefaultDirectoryFactory imp this(indexCopier, blobStore, BlobDeletionCallback.NOOP); } public DefaultDirectoryFactory(@Nullable IndexCopier indexCopier, @Nullable GarbageCollectableBlobStore blobStore, - @NotNull BlobDeletionCallback blobDeletionCallback) { + @NotNull ActiveDeletedBlobCollectorFactory.BlobDeletionCallback blobDeletionCallback) { this.indexCopier = indexCopier; this.blobStore = blobStore; this.blobDeletionCallback = blobDeletionCallback; } @Override - public Directory newInstance(IndexDefinition definition, NodeBuilder builder, + public Directory newInstance(LuceneIndexDefinition definition, NodeBuilder builder, String dirName, boolean reindex) throws IOException { Directory directory = newIndexDirectory(definition, builder, dirName); if (indexCopier != null && !(SUGGEST_DATA_CHILD_NAME.equals(dirName) && definition.getUniqueId() == null)) { @@ -65,13 +66,13 @@ public class DefaultDirectoryFactory imp return indexCopier == null; } - private Directory newIndexDirectory(IndexDefinition indexDefinition, + private Directory newIndexDirectory(LuceneIndexDefinition indexDefinition, NodeBuilder definition, String dirName) throws IOException { String path = null; - if (LuceneIndexConstants.PERSISTENCE_FILE.equalsIgnoreCase( - definition.getString(LuceneIndexConstants.PERSISTENCE_NAME))) { - path = definition.getString(PERSISTENCE_PATH); + if (FulltextIndexConstants.PERSISTENCE_FILE.equalsIgnoreCase( + definition.getString(FulltextIndexConstants.PERSISTENCE_NAME))) { + path = definition.getString(FulltextIndexConstants.PERSISTENCE_PATH); } if (path == null) { if (!remoteDirectory()) { Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/DirectoryFactory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/DirectoryFactory.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/DirectoryFactory.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/DirectoryFactory.java Tue Sep 25 12:24:15 2018 @@ -21,13 +21,13 @@ package org.apache.jackrabbit.oak.plugin import java.io.IOException; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition; +import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.lucene.store.Directory; public interface DirectoryFactory { - Directory newInstance(IndexDefinition definition, NodeBuilder builder, String dirName, + Directory newInstance(LuceneIndexDefinition definition, NodeBuilder builder, String dirName, boolean reindex) throws IOException; /** Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/FSDirectoryFactory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/FSDirectoryFactory.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/FSDirectoryFactory.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/FSDirectoryFactory.java Tue Sep 25 12:24:15 2018 @@ -23,7 +23,7 @@ import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition; +import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; @@ -39,7 +39,7 @@ public class FSDirectoryFactory implemen } @Override - public Directory newInstance(IndexDefinition definition, NodeBuilder builder, + public Directory newInstance(LuceneIndexDefinition definition, NodeBuilder builder, String dirName, boolean reindex) throws IOException { File indexDir = DirectoryUtils.createIndexDir(baseDir, definition.getIndexPath()); File readMe = new File(indexDir, INDEX_METADATA_FILE_NAME); Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexConsistencyChecker.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexConsistencyChecker.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexConsistencyChecker.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexConsistencyChecker.java Tue Sep 25 12:24:15 2018 @@ -43,8 +43,8 @@ import org.apache.jackrabbit.oak.api.Roo import org.apache.jackrabbit.oak.api.Tree; import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition; import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants; +import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition; import org.apache.jackrabbit.oak.plugins.index.lucene.writer.MultiplexersLucene; import org.apache.jackrabbit.oak.plugins.tree.factories.RootFactory; import org.apache.jackrabbit.oak.spi.state.NodeState; @@ -273,7 +273,7 @@ public class IndexConsistencyChecker { private void checkIndex(Result result, Closer closer) throws IOException { NodeState idx = NodeStateUtils.getNode(rootState, indexPath); - IndexDefinition defn = IndexDefinition.newBuilder(rootState, idx, indexPath).build(); + LuceneIndexDefinition defn = LuceneIndexDefinition.newBuilder(rootState, idx, indexPath).build(); workDir = createWorkDir(workDirRoot, PathUtils.getName(indexPath)); for (String dirName : idx.getChildNodeNames()){ @@ -296,7 +296,7 @@ public class IndexConsistencyChecker { } } - private void checkIndexDirectory(DirectoryStatus dirStatus, NodeState idx, IndexDefinition defn, + private void checkIndexDirectory(DirectoryStatus dirStatus, NodeState idx, LuceneIndexDefinition defn, File workDir, String dirName, Closer closer) throws IOException { File idxDir = createWorkDir(workDir, dirName); Directory sourceDir = new OakDirectory(new ReadOnlyBuilder(idx), dirName, defn, true); Added: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexCopierClosedException.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexCopierClosedException.java?rev=1841926&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexCopierClosedException.java (added) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexCopierClosedException.java Tue Sep 25 12:24:15 2018 @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.jackrabbit.oak.plugins.index.lucene.directory; + +public class IndexCopierClosedException extends RuntimeException{ + public IndexCopierClosedException(String message) { + super(message); + } +} Propchange: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexCopierClosedException.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexRootDirectory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexRootDirectory.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexRootDirectory.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/IndexRootDirectory.java Tue Sep 25 12:24:15 2018 @@ -40,8 +40,8 @@ import com.google.common.hash.Hashing; import org.apache.commons.io.FileUtils; import org.apache.jackrabbit.oak.commons.IOUtils; import org.apache.jackrabbit.oak.commons.PathUtils; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition; import org.apache.jackrabbit.oak.plugins.index.lucene.hybrid.NRTIndex; +import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; import org.apache.jackrabbit.oak.stats.Clock; import org.jetbrains.annotations.Nullable; import org.slf4j.Logger; Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/LocalIndexFile.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/LocalIndexFile.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/LocalIndexFile.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/LocalIndexFile.java Tue Sep 25 12:24:15 2018 @@ -22,7 +22,6 @@ package org.apache.jackrabbit.oak.plugin import java.io.File; import java.util.concurrent.TimeUnit; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexCopier; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; import org.apache.lucene.store.FilterDirectory; Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/LuceneIndexDumper.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/LuceneIndexDumper.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/LuceneIndexDumper.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/LuceneIndexDumper.java Tue Sep 25 12:24:15 2018 @@ -23,7 +23,7 @@ import java.io.File; import java.io.IOException; import com.google.common.io.Closer; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition; +import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition; import org.apache.jackrabbit.oak.spi.state.NodeState; import org.apache.jackrabbit.oak.spi.state.NodeStateUtils; import org.apache.jackrabbit.oak.spi.state.ReadOnlyBuilder; @@ -59,7 +59,7 @@ public class LuceneIndexDumper { public void dump() throws IOException { try (Closer closer = Closer.create()) { NodeState idx = NodeStateUtils.getNode(rootState, indexPath); - IndexDefinition defn = IndexDefinition.newBuilder(rootState, idx, indexPath).build(); + LuceneIndexDefinition defn = LuceneIndexDefinition.newBuilder(rootState, idx, indexPath).build(); indexDir = DirectoryUtils.createIndexDir(baseDir, indexPath); IndexMeta meta = new IndexMeta(indexPath); @@ -82,7 +82,7 @@ public class LuceneIndexDumper { return indexDir; } - private void copyContent(NodeState idx, IndexDefinition defn, IndexMeta meta, File dir, String dirName, Closer closer) throws IOException { + private void copyContent(NodeState idx, LuceneIndexDefinition defn, IndexMeta meta, File dir, String dirName, Closer closer) throws IOException { File idxDir = DirectoryUtils.createSubDir(dir, dirName); meta.addDirectoryMapping(dirName, idxDir.getName()); Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/LuceneIndexImporter.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/LuceneIndexImporter.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/LuceneIndexImporter.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/LuceneIndexImporter.java Tue Sep 25 12:24:15 2018 @@ -24,8 +24,9 @@ import java.io.IOException; import com.google.common.io.Closer; import org.apache.jackrabbit.oak.plugins.index.importer.IndexImporterProvider; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition; -import org.apache.jackrabbit.oak.plugins.index.lucene.ReindexOperations; +import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition; +import org.apache.jackrabbit.oak.plugins.index.search.IndexDefinition; +import org.apache.jackrabbit.oak.plugins.index.search.ReindexOperations; import org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; @@ -55,8 +56,9 @@ public class LuceneIndexImporter impleme definitionBuilder.getChildNode(IndexDefinition.STATUS_NODE).remove(); - ReindexOperations reindexOps = new ReindexOperations(root, definitionBuilder, localIndex.getJcrPath()); - IndexDefinition definition = reindexOps.apply(true); + ReindexOperations reindexOps = new ReindexOperations(root, definitionBuilder, localIndex.getJcrPath(), + new LuceneIndexDefinition.Builder()); + LuceneIndexDefinition definition = (LuceneIndexDefinition)reindexOps.apply(true); for (File dir : localIndex.dir.listFiles(File::isDirectory)) { String jcrName = localIndex.indexMeta.getJcrNameFromFSName(dir.getName()); @@ -75,7 +77,7 @@ public class LuceneIndexImporter impleme this.blobStore = blobStore; } - private void copyDirectory(IndexDefinition definition, NodeBuilder definitionBuilder, String jcrName, File dir) + private void copyDirectory(LuceneIndexDefinition definition, NodeBuilder definitionBuilder, String jcrName, File dir) throws IOException { try (Closer closer = Closer.create()) { Directory sourceDir = FSDirectory.open(dir); Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakBufferedIndexFile.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakBufferedIndexFile.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakBufferedIndexFile.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakBufferedIndexFile.java Tue Sep 25 12:24:15 2018 @@ -16,6 +16,12 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene.directory; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.SequenceInputStream; +import java.util.List; + import com.google.common.io.ByteStreams; import com.google.common.primitives.Ints; import org.apache.jackrabbit.oak.api.Blob; @@ -26,11 +32,6 @@ import org.apache.jackrabbit.oak.spi.sta import org.apache.lucene.store.DataInput; import org.jetbrains.annotations.NotNull; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.SequenceInputStream; -import java.util.List; import static com.google.common.base.Preconditions.checkElementIndex; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkPositionIndexes; Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakDirectory.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakDirectory.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakDirectory.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakDirectory.java Tue Sep 25 12:24:15 2018 @@ -16,6 +16,12 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene.directory; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.security.SecureRandom; +import java.util.Collection; +import java.util.Set; + import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Sets; @@ -25,8 +31,9 @@ import org.apache.jackrabbit.oak.api.Typ import org.apache.jackrabbit.oak.commons.PerfLogger; import org.apache.jackrabbit.oak.commons.StringUtils; import org.apache.jackrabbit.oak.plugins.blob.datastore.InMemoryDataRecord; -import org.apache.jackrabbit.oak.plugins.index.lucene.IndexDefinition; +import org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexDefinition; import org.apache.jackrabbit.oak.plugins.index.lucene.directory.ActiveDeletedBlobCollectorFactory.BlobDeletionCallback; +import org.apache.jackrabbit.oak.plugins.index.search.FulltextIndexConstants; import org.apache.jackrabbit.oak.spi.blob.GarbageCollectableBlobStore; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.lucene.store.Directory; @@ -41,18 +48,12 @@ import org.jetbrains.annotations.Nullabl import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.security.SecureRandom; -import java.util.Collection; -import java.util.Set; import static com.google.common.base.Preconditions.checkArgument; import static org.apache.jackrabbit.JcrConstants.JCR_DATA; import static org.apache.jackrabbit.oak.api.Type.BINARIES; import static org.apache.jackrabbit.oak.api.Type.BINARY; import static org.apache.jackrabbit.oak.api.Type.BOOLEAN; import static org.apache.jackrabbit.oak.api.Type.STRINGS; -import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.INDEX_DATA_CHILD_NAME; import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE; import static org.apache.jackrabbit.oak.plugins.memory.PropertyStates.createProperty; @@ -74,7 +75,7 @@ public class OakDirectory extends Direct protected final NodeBuilder builder; protected final String dataNodeName; protected final NodeBuilder directoryBuilder; - private final IndexDefinition definition; + private final LuceneIndexDefinition definition; private LockFactory lockFactory; private final boolean readOnly; private final boolean streamingWriteEnabled; @@ -85,41 +86,41 @@ public class OakDirectory extends Direct private final BlobDeletionCallback blobDeletionCallback; private volatile boolean dirty; - public OakDirectory(NodeBuilder builder, IndexDefinition definition, boolean readOnly) { - this(builder, INDEX_DATA_CHILD_NAME, definition, readOnly); + public OakDirectory(NodeBuilder builder, LuceneIndexDefinition definition, boolean readOnly) { + this(builder, FulltextIndexConstants.INDEX_DATA_CHILD_NAME, definition, readOnly); } - public OakDirectory(NodeBuilder builder, String dataNodeName, IndexDefinition definition, boolean readOnly) { + public OakDirectory(NodeBuilder builder, String dataNodeName, LuceneIndexDefinition definition, boolean readOnly) { this(builder, dataNodeName, definition, readOnly, BlobFactory.getNodeBuilderBlobFactory(builder)); } - public OakDirectory(NodeBuilder builder, String dataNodeName, IndexDefinition definition, + public OakDirectory(NodeBuilder builder, String dataNodeName, LuceneIndexDefinition definition, boolean readOnly, @Nullable GarbageCollectableBlobStore blobStore) { this(builder, dataNodeName, definition, readOnly, blobStore, BlobDeletionCallback.NOOP); } - public OakDirectory(NodeBuilder builder, String dataNodeName, IndexDefinition definition, + public OakDirectory(NodeBuilder builder, String dataNodeName, LuceneIndexDefinition definition, boolean readOnly, @Nullable GarbageCollectableBlobStore blobStore, - @NotNull BlobDeletionCallback blobDeletionCallback) { + @NotNull ActiveDeletedBlobCollectorFactory.BlobDeletionCallback blobDeletionCallback) { this(builder, dataNodeName, definition, readOnly, blobStore != null ? BlobFactory.getBlobStoreBlobFactory(blobStore) : BlobFactory.getNodeBuilderBlobFactory(builder), blobDeletionCallback); } - public OakDirectory(NodeBuilder builder, String dataNodeName, IndexDefinition definition, + public OakDirectory(NodeBuilder builder, String dataNodeName, LuceneIndexDefinition definition, boolean readOnly, BlobFactory blobFactory) { this(builder, dataNodeName, definition, readOnly, blobFactory, BlobDeletionCallback.NOOP); } - public OakDirectory(NodeBuilder builder, String dataNodeName, IndexDefinition definition, + public OakDirectory(NodeBuilder builder, String dataNodeName, LuceneIndexDefinition definition, boolean readOnly, BlobFactory blobFactory, - @NotNull BlobDeletionCallback blobDeletionCallback) { + @NotNull ActiveDeletedBlobCollectorFactory.BlobDeletionCallback blobDeletionCallback) { this(builder, dataNodeName, definition, readOnly, blobFactory, blobDeletionCallback, false); } - public OakDirectory(NodeBuilder builder, String dataNodeName, IndexDefinition definition, + public OakDirectory(NodeBuilder builder, String dataNodeName, LuceneIndexDefinition definition, boolean readOnly, BlobFactory blobFactory, - @NotNull BlobDeletionCallback blobDeletionCallback, + @NotNull ActiveDeletedBlobCollectorFactory.BlobDeletionCallback blobDeletionCallback, boolean streamingWriteEnabled) { this.lockFactory = NoLockFactory.getNoLockFactory(); Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakIndexFile.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakIndexFile.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakIndexFile.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakIndexFile.java Tue Sep 25 12:24:15 2018 @@ -16,12 +16,13 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene.directory; +import java.io.IOException; + import org.apache.jackrabbit.oak.api.PropertyState; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.lucene.store.DataInput; import org.jetbrains.annotations.NotNull; -import java.io.IOException; import static org.apache.jackrabbit.JcrConstants.JCR_DATA; import static org.apache.jackrabbit.oak.api.Type.BINARY; Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakIndexInput.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakIndexInput.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakIndexInput.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakIndexInput.java Tue Sep 25 12:24:15 2018 @@ -16,14 +16,14 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene.directory; +import java.io.IOException; +import java.util.Iterator; + import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.IndexInput; import org.apache.lucene.util.WeakIdentityMap; -import java.io.IOException; -import java.util.Iterator; - import static org.apache.jackrabbit.oak.plugins.index.lucene.directory.OakIndexFile.getOakIndexFile; class OakIndexInput extends IndexInput { Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakIndexOutput.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakIndexOutput.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakIndexOutput.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakIndexOutput.java Tue Sep 25 12:24:15 2018 @@ -16,12 +16,12 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene.directory; +import java.io.IOException; + import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.lucene.store.DataInput; import org.apache.lucene.store.IndexOutput; -import java.io.IOException; - import static org.apache.jackrabbit.oak.plugins.index.lucene.directory.OakIndexFile.getOakIndexFile; final class OakIndexOutput extends IndexOutput { Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakStreamingIndexFile.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakStreamingIndexFile.java?rev=1841926&r1=1841925&r2=1841926&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakStreamingIndexFile.java (original) +++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/directory/OakStreamingIndexFile.java Tue Sep 25 12:24:15 2018 @@ -16,6 +16,11 @@ */ package org.apache.jackrabbit.oak.plugins.index.lucene.directory; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.SequenceInputStream; + import com.google.common.io.ByteStreams; import org.apache.commons.io.IOUtils; import org.apache.jackrabbit.oak.api.Blob; @@ -27,10 +32,6 @@ import org.jetbrains.annotations.NotNull import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.SequenceInputStream; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkPositionIndexes; import static org.apache.jackrabbit.JcrConstants.JCR_DATA; @@ -91,7 +92,7 @@ class OakStreamingIndexFile implements O private final BlobFactory blobFactory; OakStreamingIndexFile(String name, NodeBuilder file, String dirDetails, - @NotNull BlobFactory blobFactory) { + @NotNull BlobFactory blobFactory) { this.name = name; this.file = file; this.dirDetails = dirDetails;