Skip to content

Commit

Permalink
LUCENE-3622: move SortedBytesMergeUtils to index package (to eventual…
Browse files Browse the repository at this point in the history
…ly hook into MultiDocValues)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3622@1212854 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
rmuir committed Dec 10, 2011
1 parent 3d59971 commit 00ba6bd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -22,8 +22,6 @@
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;
Expand All @@ -37,13 +35,18 @@
/**
* @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<BytesRef> comp, MergeState mergeState) {
int size = -1;
if (type == Type.BYTES_FIXED_SORTED) {
Expand All @@ -61,10 +64,10 @@ static MergeContext init(Type type, DocValues[] docValues,
public static final class MergeContext {
private final Comparator<BytesRef> 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<BytesRef> comp, MergeState mergeState,
int size, Type type) {
Expand All @@ -80,7 +83,7 @@ public MergeContext(Comparator<BytesRef> comp, MergeState mergeState,
}
}

static List<SortedSourceSlice> buildSlices(MergeState mergeState,
public static List<SortedSourceSlice> buildSlices(MergeState mergeState,
DocValues[] docValues, MergeContext ctx) throws IOException {
final List<SortedSourceSlice> slices = new ArrayList<SortedSourceSlice>();
for (int i = 0; i < docValues.length; i++) {
Expand Down Expand Up @@ -142,7 +145,7 @@ private static void createOrdMapping(MergeState mergeState,
}
}

static int mergeRecords(MergeContext ctx, IndexOutput datOut,
public static int mergeRecords(MergeContext ctx, IndexOutput datOut,
List<SortedSourceSlice> slices) throws IOException {
final RecordMerger merger = new RecordMerger(new MergeQueue(slices.size(),
ctx.comp), slices.toArray(new SortedSourceSlice[0]));
Expand Down Expand Up @@ -217,7 +220,7 @@ private void pushTop() throws IOException {
}
}

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 */
Expand Down Expand Up @@ -267,7 +270,7 @@ BytesRef next() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
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;
Expand Down

0 comments on commit 00ba6bd

Please sign in to comment.