mirror of https://github.com/apache/lucene.git
fix TODO: move lucene40-impl specific classes to lucene40 package, and make pkg-private (so generic names like Ints,Writer etc arent public)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1244217 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fe0c6ae0ae
commit
3ba23367ea
|
@ -18,7 +18,6 @@ package org.apache.lucene.codecs;
|
|||
*/
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.codecs.lucene40.values.Writer;
|
||||
import org.apache.lucene.document.DocValuesField;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.index.DocValues.Source;
|
||||
|
@ -155,7 +154,7 @@ public abstract class DocValuesConsumer {
|
|||
* <p>
|
||||
* All documents IDs between the given ID and the previously given ID or
|
||||
* <tt>0</tt> if the method is call the first time are filled with default
|
||||
* values depending on the {@link Writer} implementation. The given document
|
||||
* values depending on the implementation. The given document
|
||||
* ID must always be greater than the previous ID or <tt>0</tt> if called the
|
||||
* first time.
|
||||
*/
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.lucene.codecs.lucene40;
|
|||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.lucene.codecs.DocValuesWriterBase;
|
||||
import org.apache.lucene.codecs.lucene40.values.DocValuesWriterBase;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.FieldInfos;
|
||||
import org.apache.lucene.index.IndexFileNames;
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.lucene.codecs.DocValuesReaderBase;
|
||||
import org.apache.lucene.codecs.lucene40.values.DocValuesReaderBase;
|
||||
import org.apache.lucene.index.DocValues;
|
||||
import org.apache.lucene.index.IndexFileNames;
|
||||
import org.apache.lucene.index.SegmentReadState;
|
||||
|
|
|
@ -64,7 +64,7 @@ import org.apache.lucene.util.packed.PackedInts;
|
|||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public final class Bytes {
|
||||
final class Bytes {
|
||||
|
||||
static final String DV_SEGMENT_SUFFIX = "dv";
|
||||
|
||||
|
@ -256,7 +256,7 @@ public final class Bytes {
|
|||
boolean success = false;
|
||||
try {
|
||||
datOut = dir.createOutput(IndexFileNames.segmentFileName(id, DV_SEGMENT_SUFFIX,
|
||||
DATA_EXTENSION), context);
|
||||
DocValuesWriterBase.DATA_EXTENSION), context);
|
||||
CodecUtil.writeHeader(datOut, codecName, version);
|
||||
success = true;
|
||||
} finally {
|
||||
|
@ -281,7 +281,7 @@ public final class Bytes {
|
|||
try {
|
||||
if (idxOut == null) {
|
||||
idxOut = dir.createOutput(IndexFileNames.segmentFileName(id, DV_SEGMENT_SUFFIX,
|
||||
INDEX_EXTENSION), context);
|
||||
DocValuesWriterBase.INDEX_EXTENSION), context);
|
||||
CodecUtil.writeHeader(idxOut, codecName, version);
|
||||
}
|
||||
success = true;
|
||||
|
@ -331,11 +331,11 @@ public final class Bytes {
|
|||
boolean success = false;
|
||||
try {
|
||||
dataIn = dir.openInput(IndexFileNames.segmentFileName(id, DV_SEGMENT_SUFFIX,
|
||||
Writer.DATA_EXTENSION), context);
|
||||
DocValuesWriterBase.DATA_EXTENSION), context);
|
||||
version = CodecUtil.checkHeader(dataIn, codecName, maxVersion, maxVersion);
|
||||
if (doIndex) {
|
||||
indexIn = dir.openInput(IndexFileNames.segmentFileName(id, DV_SEGMENT_SUFFIX,
|
||||
Writer.INDEX_EXTENSION), context);
|
||||
DocValuesWriterBase.INDEX_EXTENSION), context);
|
||||
final int version2 = CodecUtil.checkHeader(indexIn, codecName,
|
||||
maxVersion, maxVersion);
|
||||
assert version == version2;
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.lucene.util.BytesRef;
|
|||
*
|
||||
* @lucene.internal
|
||||
*/
|
||||
public final class BytesRefUtils {
|
||||
final class BytesRefUtils {
|
||||
|
||||
private BytesRefUtils() {
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.lucene.codecs.lucene40.values;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.index.DocValues;
|
||||
import org.apache.lucene.index.DocValues.Source;
|
||||
import org.apache.lucene.index.DocValues.Type;
|
||||
import org.apache.lucene.store.IndexInput;
|
||||
|
@ -29,7 +28,7 @@ import org.apache.lucene.util.BytesRef;
|
|||
* Base class for disk resident source implementations
|
||||
* @lucene.internal
|
||||
*/
|
||||
public abstract class DirectSource extends Source {
|
||||
abstract class DirectSource extends Source {
|
||||
|
||||
protected final IndexInput data;
|
||||
private final ToNumeric toNumeric;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.codecs;
|
||||
package org.apache.lucene.codecs.lucene40.values;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -24,6 +24,7 @@ import java.util.Comparator;
|
|||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.lucene.codecs.PerDocProducer;
|
||||
import org.apache.lucene.codecs.lucene40.values.Bytes;
|
||||
import org.apache.lucene.codecs.lucene40.values.Floats;
|
||||
import org.apache.lucene.codecs.lucene40.values.Ints;
|
||||
|
@ -39,7 +40,6 @@ import org.apache.lucene.util.BytesRef;
|
|||
* Abstract base class for PerDocProducer implementations
|
||||
* @lucene.experimental
|
||||
*/
|
||||
// TODO: this needs to go under lucene40 codec (its specific to its impl)
|
||||
public abstract class DocValuesReaderBase extends PerDocProducer {
|
||||
|
||||
protected abstract void closeInternal(Collection<? extends Closeable> closeables) throws IOException;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.codecs;
|
||||
package org.apache.lucene.codecs.lucene40.values;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
|
@ -20,6 +20,8 @@ package org.apache.lucene.codecs;
|
|||
import java.io.IOException;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.apache.lucene.codecs.DocValuesConsumer;
|
||||
import org.apache.lucene.codecs.PerDocConsumer;
|
||||
import org.apache.lucene.codecs.lucene40.values.Writer;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.PerDocWriteState;
|
||||
|
@ -34,13 +36,22 @@ import org.apache.lucene.util.Counter;
|
|||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
//TODO: this needs to go under lucene40 codec (its specific to its impl)
|
||||
public abstract class DocValuesWriterBase extends PerDocConsumer {
|
||||
protected final String segmentName;
|
||||
private final Counter bytesUsed;
|
||||
protected final IOContext context;
|
||||
private final boolean fasterButMoreRam;
|
||||
|
||||
/**
|
||||
* Filename extension for index files
|
||||
*/
|
||||
public static final String INDEX_EXTENSION = "idx";
|
||||
|
||||
/**
|
||||
* Filename extension for data files.
|
||||
*/
|
||||
public static final String DATA_EXTENSION = "dat";
|
||||
|
||||
/**
|
||||
* @param state The state to initiate a {@link PerDocConsumer} instance
|
||||
*/
|
|
@ -39,7 +39,7 @@ import org.apache.lucene.util.IOUtils;
|
|||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public class Floats {
|
||||
class Floats {
|
||||
|
||||
protected static final String CODEC_NAME = "Floats";
|
||||
protected static final int VERSION_START = 0;
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.apache.lucene.util.IOUtils;
|
|||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public final class Ints {
|
||||
final class Ints {
|
||||
protected static final String CODEC_NAME = "Ints";
|
||||
protected static final int VERSION_START = 0;
|
||||
protected static final int VERSION_CURRENT = VERSION_START;
|
||||
|
|
|
@ -169,7 +169,7 @@ class PackedIntValues {
|
|||
protected PackedIntsReader(Directory dir, String id, int numDocs,
|
||||
IOContext context) throws IOException {
|
||||
datIn = dir.openInput(
|
||||
IndexFileNames.segmentFileName(id, Bytes.DV_SEGMENT_SUFFIX, Writer.DATA_EXTENSION),
|
||||
IndexFileNames.segmentFileName(id, Bytes.DV_SEGMENT_SUFFIX, DocValuesWriterBase.DATA_EXTENSION),
|
||||
context);
|
||||
this.numDocs = numDocs;
|
||||
boolean success = false;
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.lucene.util.Counter;
|
|||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public abstract class Writer extends DocValuesConsumer {
|
||||
abstract class Writer extends DocValuesConsumer {
|
||||
protected final Counter bytesUsed;
|
||||
|
||||
/**
|
||||
|
@ -53,16 +53,6 @@ public abstract class Writer extends DocValuesConsumer {
|
|||
this.bytesUsed = bytesUsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filename extension for index files
|
||||
*/
|
||||
public static final String INDEX_EXTENSION = "idx";
|
||||
|
||||
/**
|
||||
* Filename extension for data files.
|
||||
*/
|
||||
public static final String DATA_EXTENSION = "dat";
|
||||
|
||||
/**
|
||||
* Factory method to create a {@link Writer} instance for a given type. This
|
||||
* method returns default implementations for each of the different types
|
||||
|
|
|
@ -21,8 +21,7 @@ import java.io.IOException;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.lucene.codecs.DocValuesWriterBase;
|
||||
import org.apache.lucene.codecs.lucene40.values.Writer;
|
||||
import org.apache.lucene.codecs.lucene40.values.DocValuesWriterBase;
|
||||
import org.apache.lucene.index.FieldInfo;
|
||||
import org.apache.lucene.index.FieldInfos;
|
||||
import org.apache.lucene.index.IndexFileNames;
|
||||
|
@ -67,10 +66,10 @@ public class SepDocValuesConsumer extends DocValuesWriterBase {
|
|||
case BYTES_FIXED_SORTED:
|
||||
case BYTES_VAR_SORTED:
|
||||
files.add(IndexFileNames.segmentFileName(filename, "",
|
||||
Writer.INDEX_EXTENSION));
|
||||
INDEX_EXTENSION));
|
||||
try {
|
||||
assert dir.fileExists(IndexFileNames.segmentFileName(filename, "",
|
||||
Writer.INDEX_EXTENSION));
|
||||
INDEX_EXTENSION));
|
||||
} catch (IOException e) {
|
||||
// don't throw checked exception - dir is only used in assert
|
||||
throw new RuntimeException(e);
|
||||
|
@ -85,10 +84,10 @@ public class SepDocValuesConsumer extends DocValuesWriterBase {
|
|||
case FIXED_INTS_64:
|
||||
case FIXED_INTS_8:
|
||||
files.add(IndexFileNames.segmentFileName(filename, "",
|
||||
Writer.DATA_EXTENSION));
|
||||
DATA_EXTENSION));
|
||||
try {
|
||||
assert dir.fileExists(IndexFileNames.segmentFileName(filename, "",
|
||||
Writer.DATA_EXTENSION));
|
||||
DATA_EXTENSION));
|
||||
} catch (IOException e) {
|
||||
// don't throw checked exception - dir is only used in assert
|
||||
throw new RuntimeException(e);
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.lucene.codecs.DocValuesReaderBase;
|
||||
import org.apache.lucene.codecs.lucene40.values.DocValuesReaderBase;
|
||||
import org.apache.lucene.index.DocValues;
|
||||
import org.apache.lucene.index.SegmentReadState;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.lucene.codecs.lucene40;
|
||||
package org.apache.lucene.codecs.lucene40.values;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
@ -23,13 +23,13 @@ import java.util.Random;
|
|||
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.codecs.Codec;
|
||||
import org.apache.lucene.codecs.lucene40.values.BytesRefUtils;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.DocValuesField;
|
||||
import org.apache.lucene.document.TextField;
|
||||
import org.apache.lucene.index.DocValues.Source;
|
||||
import org.apache.lucene.index.DocValues.Type;
|
||||
import org.apache.lucene.store.ByteArrayDataOutput;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
|
@ -135,13 +135,17 @@ public class TestTypePromotion extends LuceneTestCase {
|
|||
value = bytes.bytes[bytes.offset];
|
||||
break;
|
||||
case 2:
|
||||
value = BytesRefUtils.asShort(bytes);
|
||||
value = ((bytes.bytes[bytes.offset] & 0xFF) << 8) | (bytes.bytes[bytes.offset+1] & 0xFF);
|
||||
break;
|
||||
case 4:
|
||||
value = BytesRefUtils.asInt(bytes);
|
||||
value = ((bytes.bytes[bytes.offset] & 0xFF) << 24) | ((bytes.bytes[bytes.offset+1] & 0xFF) << 16)
|
||||
| ((bytes.bytes[bytes.offset+2] & 0xFF) << 8) | (bytes.bytes[bytes.offset+3] & 0xFF);
|
||||
break;
|
||||
case 8:
|
||||
value = BytesRefUtils.asLong(bytes);
|
||||
value = (((long)(bytes.bytes[bytes.offset] & 0xff) << 56) | ((long)(bytes.bytes[bytes.offset+1] & 0xff) << 48) |
|
||||
((long)(bytes.bytes[bytes.offset+2] & 0xff) << 40) | ((long)(bytes.bytes[bytes.offset+3] & 0xff) << 32) |
|
||||
((long)(bytes.bytes[bytes.offset+4] & 0xff) << 24) | ((long)(bytes.bytes[bytes.offset+5] & 0xff) << 16) |
|
||||
((long)(bytes.bytes[bytes.offset+6] & 0xff) << 8) | ((long)(bytes.bytes[bytes.offset+7] & 0xff)));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -243,20 +247,27 @@ public class TestTypePromotion extends LuceneTestCase {
|
|||
case BYTES_FIXED_SORTED:
|
||||
case BYTES_FIXED_STRAIGHT:
|
||||
values[i] = random.nextLong();
|
||||
BytesRefUtils.copyLong(ref, values[i]);
|
||||
valField.setValue(ref);
|
||||
byte bytes[] = new byte[8];
|
||||
ByteArrayDataOutput out = new ByteArrayDataOutput(bytes, 0, 8);
|
||||
out.writeLong(values[i]);
|
||||
valField.setValue(new BytesRef(bytes));
|
||||
break;
|
||||
case BYTES_VAR_DEREF:
|
||||
case BYTES_VAR_SORTED:
|
||||
case BYTES_VAR_STRAIGHT:
|
||||
byte lbytes[] = new byte[8];
|
||||
ByteArrayDataOutput lout = new ByteArrayDataOutput(lbytes, 0, 8);
|
||||
final int len;
|
||||
if (random.nextBoolean()) {
|
||||
BytesRefUtils.copyInt(ref, random.nextInt());
|
||||
values[i] = BytesRefUtils.asInt(ref);
|
||||
values[i] = random.nextInt();
|
||||
lout.writeInt((int)values[i]);
|
||||
len = 4;
|
||||
} else {
|
||||
BytesRefUtils.copyLong(ref, random.nextLong());
|
||||
values[i] = BytesRefUtils.asLong(ref);
|
||||
values[i] = random.nextLong();
|
||||
lout.writeLong(values[i]);
|
||||
len = 8;
|
||||
}
|
||||
valField.setValue(ref);
|
||||
valField.setValue(new BytesRef(lbytes, 0, len));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue