lucene41 -> disk

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1433088 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2013-01-14 20:07:06 +00:00
parent b6c9791358
commit 71e6ea1e24
10 changed files with 57 additions and 31 deletions

View File

@ -1,4 +1,4 @@
package org.apache.lucene.codecs.lucene41;
package org.apache.lucene.codecs.diskdv;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -32,19 +32,19 @@ import org.apache.lucene.util.packed.PackedInts;
import org.apache.lucene.util.packed.PackedInts.FormatAndBits;
// nocommit fix exception handling (make sure tests find problems first)
class Lucene41SimpleDocValuesConsumer extends SimpleDVConsumer {
class DiskDocValuesConsumer extends SimpleDVConsumer {
final IndexOutput data, meta;
final int maxDoc;
Lucene41SimpleDocValuesConsumer(SegmentWriteState state) throws IOException {
DiskDocValuesConsumer(SegmentWriteState state) throws IOException {
String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "dvd");
data = state.directory.createOutput(dataName, state.context);
CodecUtil.writeHeader(data, Lucene41SimpleDocValuesFormat.DATA_CODEC,
Lucene41SimpleDocValuesFormat.VERSION_CURRENT);
CodecUtil.writeHeader(data, DiskDocValuesFormat.DATA_CODEC,
DiskDocValuesFormat.VERSION_CURRENT);
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "dvm");
meta = state.directory.createOutput(metaName, state.context);
CodecUtil.writeHeader(meta, Lucene41SimpleDocValuesFormat.METADATA_CODEC,
Lucene41SimpleDocValuesFormat.VERSION_CURRENT);
CodecUtil.writeHeader(meta, DiskDocValuesFormat.METADATA_CODEC,
DiskDocValuesFormat.VERSION_CURRENT);
maxDoc = state.segmentInfo.getDocCount();
}

View File

@ -1,4 +1,4 @@
package org.apache.lucene.codecs.lucene41;
package org.apache.lucene.codecs.diskdv;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -37,24 +37,24 @@ import org.apache.lucene.index.SegmentWriteState;
* fixedLength SortedField = BINARY + NUMERIC (ords)
* variableLength SortedField = BINARY + NUMERIC (addresses) + NUMERIC (ords)
*/
public class Lucene41SimpleDocValuesFormat extends SimpleDocValuesFormat {
public class DiskDocValuesFormat extends SimpleDocValuesFormat {
public Lucene41SimpleDocValuesFormat() {
super("Lucene41");
public DiskDocValuesFormat() {
super("Disk");
}
@Override
public SimpleDVConsumer fieldsConsumer(SegmentWriteState state) throws IOException {
return new Lucene41SimpleDocValuesConsumer(state);
return new DiskDocValuesConsumer(state);
}
@Override
public SimpleDVProducer fieldsProducer(SegmentReadState state) throws IOException {
return new Lucene41SimpleDocValuesProducer(state);
return new DiskDocValuesProducer(state);
}
static final String DATA_CODEC = "Lucene41DocValuesData";
static final String METADATA_CODEC = "Lucene41DocValuesMetadata";
static final String DATA_CODEC = "DiskDocValuesData";
static final String METADATA_CODEC = "DiskDocValuesMetadata";
static final int VERSION_START = 0;
static final int VERSION_CURRENT = VERSION_START;
}

View File

@ -1,4 +1,4 @@
package org.apache.lucene.codecs.lucene41;
package org.apache.lucene.codecs.diskdv;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@ -37,21 +37,21 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.packed.PackedInts;
class Lucene41SimpleDocValuesProducer extends SimpleDVProducer {
class DiskDocValuesProducer extends SimpleDVProducer {
private final Map<Integer,NumericEntry> numerics;
private final Map<Integer,NumericEntry> ords;
private final Map<Integer,BinaryEntry> binaries;
private final IndexInput data;
Lucene41SimpleDocValuesProducer(SegmentReadState state) throws IOException {
DiskDocValuesProducer(SegmentReadState state) throws IOException {
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "dvm");
// read in the entries from the metadata file.
IndexInput in = state.directory.openInput(metaName, state.context);
boolean success = false;
try {
CodecUtil.checkHeader(in, Lucene41SimpleDocValuesFormat.METADATA_CODEC,
Lucene41SimpleDocValuesFormat.VERSION_START,
Lucene41SimpleDocValuesFormat.VERSION_START);
CodecUtil.checkHeader(in, DiskDocValuesFormat.METADATA_CODEC,
DiskDocValuesFormat.VERSION_START,
DiskDocValuesFormat.VERSION_START);
numerics = new HashMap<Integer,NumericEntry>();
ords = new HashMap<Integer,NumericEntry>();
binaries = new HashMap<Integer,BinaryEntry>();
@ -67,9 +67,9 @@ class Lucene41SimpleDocValuesProducer extends SimpleDVProducer {
String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "dvd");
data = state.directory.openInput(dataName, state.context);
CodecUtil.checkHeader(data, Lucene41SimpleDocValuesFormat.DATA_CODEC,
Lucene41SimpleDocValuesFormat.VERSION_START,
Lucene41SimpleDocValuesFormat.VERSION_START);
CodecUtil.checkHeader(data, DiskDocValuesFormat.DATA_CODEC,
DiskDocValuesFormat.VERSION_START,
DiskDocValuesFormat.VERSION_START);
}
private void readFields(IndexInput meta, FieldInfos infos) throws IOException {

View File

@ -0,0 +1,25 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<!--
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.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
DocValuesFormat that accesses values directly from disk.
</body>
</html>

View File

@ -36,7 +36,7 @@ import org.apache.lucene.util.packed.PackedInts;
/** Indexes doc values to disk and loads them in RAM at
* search time. */
// nocommit: nuke this wrapper and just make a nice impl (e.g. FST for sortedbytes)
// nocommit: nuke this wrapper and just make a nice impl for 4.1 (e.g. FST for sortedbytes)
public class MemoryDocValuesFormat extends SimpleDocValuesFormat {
public MemoryDocValuesFormat() {

View File

@ -13,5 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
org.apache.lucene.codecs.diskdv.DiskDocValuesFormat
org.apache.lucene.codecs.memory.MemoryDocValuesFormat
org.apache.lucene.codecs.simpletext.SimpleTextSimpleDocValuesFormat

View File

@ -144,7 +144,7 @@ public class Lucene41Codec extends Codec {
private final PostingsFormat defaultFormat = PostingsFormat.forName("Lucene41");
// nocommit
private final SimpleDocValuesFormat defaultDVFormat = SimpleDocValuesFormat.forName("Lucene41");
private final SimpleDocValuesFormat defaultDVFormat = SimpleDocValuesFormat.forName("Disk");
private final SimpleNormsFormat simpleNormsFormat = new Lucene41SimpleNormsFormat();

View File

@ -13,6 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
org.apache.lucene.codecs.lucene41.Lucene41SimpleDocValuesFormat
org.apache.lucene.codecs.memory.MemoryDocValuesFormat
org.apache.lucene.codecs.simpletext.SimpleTextSimpleDocValuesFormat
#nocommit org.apache.lucene.codecs.lucene41.Lucene41SimpleDocValuesFormat

View File

@ -27,6 +27,8 @@ import org.apache.lucene.search.spans.*;
* on the assumption that if the explanations work out right for them,
* they should work for anything.
*/
// nocommit: fix this slow-wrapper sortedDV fail:
// ant test -Dtestcase=TestComplexExplanations -Dtests.method=testMPQ7 -Dtests.seed=8FB070EE0C4130E9 -Dtests.slow=true -Dtests.locale=it_CH -Dtests.timezone=America/Grand_Turk -Dtests.file.encoding=UTF-8
public class TestComplexExplanations extends TestExplanations {
/**

View File

@ -32,9 +32,9 @@ import org.apache.lucene.codecs.SimpleDocValuesFormat;
import org.apache.lucene.codecs.asserting.AssertingPostingsFormat;
import org.apache.lucene.codecs.lucene41.Lucene41Codec;
import org.apache.lucene.codecs.lucene41.Lucene41PostingsFormat;
import org.apache.lucene.codecs.lucene41.Lucene41SimpleDocValuesFormat;
import org.apache.lucene.codecs.lucene41ords.Lucene41WithOrds;
import org.apache.lucene.codecs.bloom.TestBloomFilteredLucene41Postings;
import org.apache.lucene.codecs.diskdv.DiskDocValuesFormat;
import org.apache.lucene.codecs.memory.DirectPostingsFormat;
import org.apache.lucene.codecs.memory.MemoryDocValuesFormat;
import org.apache.lucene.codecs.memory.MemoryPostingsFormat;
@ -142,7 +142,7 @@ public class RandomCodec extends Lucene41Codec {
new MemoryPostingsFormat(false, random.nextFloat()));
addDocValues(avoidCodecs,
new Lucene41SimpleDocValuesFormat(),
new DiskDocValuesFormat(),
new SimpleTextSimpleDocValuesFormat(),
new MemoryDocValuesFormat());