mirror of https://github.com/apache/lucene.git
rename/refactor a bit
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1433118 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e4508c59e7
commit
91c58c364e
|
@ -37,11 +37,11 @@ class DiskDocValuesConsumer extends SimpleDVConsumer {
|
|||
final int maxDoc;
|
||||
|
||||
DiskDocValuesConsumer(SegmentWriteState state) throws IOException {
|
||||
String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "dvd");
|
||||
String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "ddvd");
|
||||
data = state.directory.createOutput(dataName, state.context);
|
||||
CodecUtil.writeHeader(data, DiskDocValuesFormat.DATA_CODEC,
|
||||
DiskDocValuesFormat.VERSION_CURRENT);
|
||||
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "dvm");
|
||||
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "ddvm");
|
||||
meta = state.directory.createOutput(metaName, state.context);
|
||||
CodecUtil.writeHeader(meta, DiskDocValuesFormat.METADATA_CODEC,
|
||||
DiskDocValuesFormat.VERSION_CURRENT);
|
||||
|
|
|
@ -44,7 +44,7 @@ class DiskDocValuesProducer extends SimpleDVProducer {
|
|||
private final IndexInput data;
|
||||
|
||||
DiskDocValuesProducer(SegmentReadState state) throws IOException {
|
||||
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "dvm");
|
||||
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "ddvm");
|
||||
// read in the entries from the metadata file.
|
||||
IndexInput in = state.directory.openInput(metaName, state.context);
|
||||
boolean success = false;
|
||||
|
@ -65,7 +65,7 @@ class DiskDocValuesProducer extends SimpleDVProducer {
|
|||
}
|
||||
}
|
||||
|
||||
String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "dvd");
|
||||
String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "ddvd");
|
||||
data = state.directory.openInput(dataName, state.context);
|
||||
CodecUtil.checkHeader(data, DiskDocValuesFormat.DATA_CODEC,
|
||||
DiskDocValuesFormat.VERSION_START,
|
||||
|
|
|
@ -41,21 +41,22 @@ import org.apache.lucene.util.packed.PackedInts.FormatAndBits;
|
|||
* the latter is typically much smaller with lucene's sims, as only some byte values are used,
|
||||
* but its often a nonlinear mapping, especially if you dont use crazy boosts.
|
||||
*/
|
||||
class Lucene41SimpleNormsConsumer extends SimpleDVConsumer {
|
||||
class Lucene41SimpleDocValuesConsumer extends SimpleDVConsumer {
|
||||
static final int VERSION_START = 0;
|
||||
static final int VERSION_CURRENT = VERSION_START;
|
||||
|
||||
final IndexOutput data, meta;
|
||||
final int maxDoc;
|
||||
|
||||
Lucene41SimpleNormsConsumer(SegmentWriteState state) throws IOException {
|
||||
Lucene41SimpleDocValuesConsumer(SegmentWriteState state, String dataCodec, String dataExtension, String metaCodec, String metaExtension) throws IOException {
|
||||
boolean success = false;
|
||||
try {
|
||||
String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "nvd");
|
||||
String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, dataExtension);
|
||||
data = state.directory.createOutput(dataName, state.context);
|
||||
CodecUtil.writeHeader(data, Lucene41SimpleNormsFormat.DATA_CODEC,
|
||||
Lucene41SimpleNormsFormat.VERSION_CURRENT);
|
||||
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "nvm");
|
||||
CodecUtil.writeHeader(data, dataCodec, VERSION_CURRENT);
|
||||
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, metaExtension);
|
||||
meta = state.directory.createOutput(metaName, state.context);
|
||||
CodecUtil.writeHeader(meta, Lucene41SimpleNormsFormat.METADATA_CODEC,
|
||||
Lucene41SimpleNormsFormat.VERSION_CURRENT);
|
||||
CodecUtil.writeHeader(meta, metaCodec, VERSION_CURRENT);
|
||||
maxDoc = state.segmentInfo.getDocCount();
|
||||
success = true;
|
||||
} finally {
|
|
@ -0,0 +1,44 @@
|
|||
package org.apache.lucene.codecs.lucene41;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.codecs.SimpleDVConsumer;
|
||||
import org.apache.lucene.codecs.SimpleDVProducer;
|
||||
import org.apache.lucene.codecs.SimpleNormsFormat;
|
||||
import org.apache.lucene.index.SegmentReadState;
|
||||
import org.apache.lucene.index.SegmentWriteState;
|
||||
|
||||
public class Lucene41SimpleDocValuesFormat extends SimpleNormsFormat {
|
||||
|
||||
@Override
|
||||
public SimpleDVConsumer normsConsumer(SegmentWriteState state) throws IOException {
|
||||
return new Lucene41SimpleDocValuesConsumer(state, DATA_CODEC, DATA_EXTENSION, METADATA_CODEC, METADATA_EXTENSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleDVProducer normsProducer(SegmentReadState state) throws IOException {
|
||||
return new Lucene41SimpleDocValuesProducer(state, DATA_CODEC, DATA_EXTENSION, METADATA_CODEC, METADATA_EXTENSION);
|
||||
}
|
||||
|
||||
private static final String DATA_CODEC = "Lucene41DocValuesData";
|
||||
private static final String DATA_EXTENSION = "dvd";
|
||||
private static final String METADATA_CODEC = "Lucene41DocValuesMetadata";
|
||||
private static final String METADATA_EXTENSION = "dvm";
|
||||
}
|
|
@ -34,7 +34,7 @@ import org.apache.lucene.store.IndexInput;
|
|||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.packed.PackedInts;
|
||||
|
||||
class Lucene41SimpleNormsProducer extends SimpleDVProducer {
|
||||
class Lucene41SimpleDocValuesProducer extends SimpleDVProducer {
|
||||
private final Map<Integer,NumericEntry> numerics;
|
||||
private final IndexInput data;
|
||||
|
||||
|
@ -42,15 +42,15 @@ class Lucene41SimpleNormsProducer extends SimpleDVProducer {
|
|||
private final Map<Integer,NumericDocValues> ramInstances =
|
||||
new HashMap<Integer,NumericDocValues>();
|
||||
|
||||
Lucene41SimpleNormsProducer(SegmentReadState state) throws IOException {
|
||||
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "nvm");
|
||||
Lucene41SimpleDocValuesProducer(SegmentReadState state, String dataCodec, String dataExtension, String metaCodec, String metaExtension) throws IOException {
|
||||
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, metaExtension);
|
||||
// read in the entries from the metadata file.
|
||||
IndexInput in = state.directory.openInput(metaName, state.context);
|
||||
boolean success = false;
|
||||
try {
|
||||
CodecUtil.checkHeader(in, Lucene41SimpleNormsFormat.METADATA_CODEC,
|
||||
Lucene41SimpleNormsFormat.VERSION_START,
|
||||
Lucene41SimpleNormsFormat.VERSION_START);
|
||||
CodecUtil.checkHeader(in, metaCodec,
|
||||
Lucene41SimpleDocValuesConsumer.VERSION_START,
|
||||
Lucene41SimpleDocValuesConsumer.VERSION_START);
|
||||
numerics = new HashMap<Integer,NumericEntry>();
|
||||
readFields(in, state.fieldInfos);
|
||||
success = true;
|
||||
|
@ -62,11 +62,11 @@ class Lucene41SimpleNormsProducer extends SimpleDVProducer {
|
|||
}
|
||||
}
|
||||
|
||||
String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, "nvd");
|
||||
String dataName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, dataExtension);
|
||||
data = state.directory.openInput(dataName, state.context);
|
||||
CodecUtil.checkHeader(data, Lucene41SimpleNormsFormat.DATA_CODEC,
|
||||
Lucene41SimpleNormsFormat.VERSION_START,
|
||||
Lucene41SimpleNormsFormat.VERSION_START);
|
||||
CodecUtil.checkHeader(data, dataCodec,
|
||||
Lucene41SimpleDocValuesConsumer.VERSION_START,
|
||||
Lucene41SimpleDocValuesConsumer.VERSION_START);
|
||||
}
|
||||
|
||||
private void readFields(IndexInput meta, FieldInfos infos) throws IOException {
|
|
@ -29,16 +29,16 @@ public class Lucene41SimpleNormsFormat extends SimpleNormsFormat {
|
|||
|
||||
@Override
|
||||
public SimpleDVConsumer normsConsumer(SegmentWriteState state) throws IOException {
|
||||
return new Lucene41SimpleNormsConsumer(state);
|
||||
return new Lucene41SimpleDocValuesConsumer(state, DATA_CODEC, DATA_EXTENSION, METADATA_CODEC, METADATA_EXTENSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleDVProducer normsProducer(SegmentReadState state) throws IOException {
|
||||
return new Lucene41SimpleNormsProducer(state);
|
||||
return new Lucene41SimpleDocValuesProducer(state, DATA_CODEC, DATA_EXTENSION, METADATA_CODEC, METADATA_EXTENSION);
|
||||
}
|
||||
|
||||
static final String DATA_CODEC = "Lucene41NormsData";
|
||||
static final String METADATA_CODEC = "Lucene41DocValuesMetadata";
|
||||
static final int VERSION_START = 0;
|
||||
static final int VERSION_CURRENT = VERSION_START;
|
||||
private static final String DATA_CODEC = "Lucene41NormsData";
|
||||
private static final String DATA_EXTENSION = "nvd";
|
||||
private static final String METADATA_CODEC = "Lucene41NormsMetadata";
|
||||
private static final String METADATA_EXTENSION = "nvm";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue