diff --git a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/SortedBytesMergeUtils.java b/lucene/src/java/org/apache/lucene/index/SortedBytesMergeUtils.java similarity index 92% rename from lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/SortedBytesMergeUtils.java rename to lucene/src/java/org/apache/lucene/index/SortedBytesMergeUtils.java index 3b09a91ecee..19959c3d830 100644 --- a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/SortedBytesMergeUtils.java +++ b/lucene/src/java/org/apache/lucene/index/SortedBytesMergeUtils.java @@ -1,4 +1,4 @@ -package org.apache.lucene.index.codecs.lucene40.values; +package org.apache.lucene.index; /** * Licensed to the Apache Software Foundation (ASF) under one or more @@ -22,8 +22,6 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; -import org.apache.lucene.index.DocValues; -import org.apache.lucene.index.MergeState; import org.apache.lucene.index.DocValues.SortedSource; import org.apache.lucene.index.DocValues.Source; import org.apache.lucene.index.DocValues.Type; @@ -37,13 +35,18 @@ import org.apache.lucene.util.packed.PackedInts; /** * @lucene.internal */ -final class SortedBytesMergeUtils { +// TODO: generalize this a bit more: +// * remove writing (like indexoutput) from here +// * just take IndexReaders (not IR&LiveDocs), doesnt care about liveDocs +// * hook into MultiDocValues to make a MultiSortedSource +// * maybe DV merging should then just use MultiDocValues for simplicity? +public final class SortedBytesMergeUtils { private SortedBytesMergeUtils() { // no instance } - static MergeContext init(Type type, DocValues[] docValues, + public static MergeContext init(Type type, DocValues[] docValues, Comparator comp, MergeState mergeState) { int size = -1; if (type == Type.BYTES_FIXED_SORTED) { @@ -61,10 +64,10 @@ final class SortedBytesMergeUtils { public static final class MergeContext { private final Comparator comp; private final BytesRef missingValue = new BytesRef(); - final int sizePerValues; // -1 if var length + public final int sizePerValues; // -1 if var length final Type type; - final int[] docToEntry; - long[] offsets; // if non-null #mergeRecords collects byte offsets here + public final int[] docToEntry; + public long[] offsets; // if non-null #mergeRecords collects byte offsets here public MergeContext(Comparator comp, MergeState mergeState, int size, Type type) { @@ -80,7 +83,7 @@ final class SortedBytesMergeUtils { } } - static List buildSlices(MergeState mergeState, + public static List buildSlices(MergeState mergeState, DocValues[] docValues, MergeContext ctx) throws IOException { final List slices = new ArrayList(); for (int i = 0; i < docValues.length; i++) { @@ -142,7 +145,7 @@ final class SortedBytesMergeUtils { } } - static int mergeRecords(MergeContext ctx, IndexOutput datOut, + public static int mergeRecords(MergeContext ctx, IndexOutput datOut, List slices) throws IOException { final RecordMerger merger = new RecordMerger(new MergeQueue(slices.size(), ctx.comp), slices.toArray(new SortedSourceSlice[0])); @@ -217,7 +220,7 @@ final class SortedBytesMergeUtils { } } - static class SortedSourceSlice { + public static class SortedSourceSlice { final SortedSource source; final int readerIdx; /* global array indexed by docID containg the relative ord for the doc */ @@ -267,7 +270,7 @@ final class SortedBytesMergeUtils { return null; } - void writeOrds(PackedInts.Writer writer) throws IOException { + public void writeOrds(PackedInts.Writer writer) throws IOException { for (int i = docToOrdStart; i < docToOrdEnd; i++) { final int mappedOrd = docIDToRelativeOrd[i]; assert mappedOrd < ordMapping.length; diff --git a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/FixedSortedBytesImpl.java b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/FixedSortedBytesImpl.java index 617fb64b8f9..0abf11e0531 100644 --- a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/FixedSortedBytesImpl.java +++ b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/FixedSortedBytesImpl.java @@ -22,14 +22,15 @@ import java.util.Comparator; import java.util.List; import org.apache.lucene.index.DocValues; +import org.apache.lucene.index.SortedBytesMergeUtils; import org.apache.lucene.index.DocValues.SortedSource; import org.apache.lucene.index.DocValues.Type; +import org.apache.lucene.index.SortedBytesMergeUtils.MergeContext; +import org.apache.lucene.index.SortedBytesMergeUtils.SortedSourceSlice; import org.apache.lucene.index.MergeState; import org.apache.lucene.index.codecs.lucene40.values.Bytes.BytesReaderBase; import org.apache.lucene.index.codecs.lucene40.values.Bytes.BytesSortedSourceBase; import org.apache.lucene.index.codecs.lucene40.values.Bytes.DerefBytesWriterBase; -import org.apache.lucene.index.codecs.lucene40.values.SortedBytesMergeUtils.MergeContext; -import org.apache.lucene.index.codecs.lucene40.values.SortedBytesMergeUtils.SortedSourceSlice; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput; diff --git a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/VarSortedBytesImpl.java b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/VarSortedBytesImpl.java index 20de637f62e..b50df8430ec 100644 --- a/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/VarSortedBytesImpl.java +++ b/lucene/src/java/org/apache/lucene/index/codecs/lucene40/values/VarSortedBytesImpl.java @@ -22,14 +22,15 @@ import java.util.Comparator; import java.util.List; import org.apache.lucene.index.DocValues; +import org.apache.lucene.index.SortedBytesMergeUtils; import org.apache.lucene.index.DocValues.SortedSource; import org.apache.lucene.index.DocValues.Type; +import org.apache.lucene.index.SortedBytesMergeUtils.MergeContext; +import org.apache.lucene.index.SortedBytesMergeUtils.SortedSourceSlice; import org.apache.lucene.index.MergeState; import org.apache.lucene.index.codecs.lucene40.values.Bytes.BytesReaderBase; import org.apache.lucene.index.codecs.lucene40.values.Bytes.BytesSortedSourceBase; import org.apache.lucene.index.codecs.lucene40.values.Bytes.DerefBytesWriterBase; -import org.apache.lucene.index.codecs.lucene40.values.SortedBytesMergeUtils.MergeContext; -import org.apache.lucene.index.codecs.lucene40.values.SortedBytesMergeUtils.SortedSourceSlice; import org.apache.lucene.store.Directory; import org.apache.lucene.store.IOContext; import org.apache.lucene.store.IndexInput;