add missing files

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4547@1410552 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2012-11-16 19:48:12 +00:00
parent f711564486
commit 04af95d20f
6 changed files with 216 additions and 16 deletions

View File

@ -0,0 +1,120 @@
package org.apache.lucene.codecs;
/*
* 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.Closeable;
import java.io.IOException;
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.NumericDocValues;
import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.util.BytesRef;
public abstract class SimpleDVProducer implements Closeable {
private final int maxDoc;
protected SimpleDVProducer(int maxDoc) {
// nocommit kinda messy?
this.maxDoc = maxDoc;
}
public abstract NumericDocValues getDirectNumeric(FieldInfo field) throws IOException;
/** Loads all values into RAM. */
public NumericDocValues getNumeric(FieldInfo field) throws IOException {
NumericDocValues source = getDirectNumeric(field);
// nocommit more ram efficient?
final long[] values = new long[maxDoc];
for(int docID=0;docID<maxDoc;docID++) {
values[docID] = source.get(docID);
}
return new NumericDocValues() {
@Override
public long get(int docID) {
return values[docID];
}
};
}
public abstract BinaryDocValues getDirectBinary(FieldInfo field) throws IOException;
/** Loads all values into RAM. */
public BinaryDocValues getBinary(FieldInfo field) throws IOException {
BinaryDocValues source = getDirectBinary(field);
// nocommit more ram efficient
final byte[][] values = new byte[maxDoc][];
BytesRef scratch = new BytesRef();
for(int docID=0;docID<maxDoc;docID++) {
source.get(docID, scratch);
values[docID] = new byte[scratch.length];
System.arraycopy(scratch.bytes, scratch.offset, values[docID], 0, scratch.length);
}
return new BinaryDocValues() {
@Override
public void get(int docID, BytesRef result) {
result.bytes = values[docID];
result.offset = 0;
result.length = result.bytes.length;
}
};
}
public abstract SortedDocValues getDirectSorted(FieldInfo field) throws IOException;
/** Loads all values into RAM. */
public SortedDocValues getSorted(FieldInfo field) throws IOException {
SortedDocValues source = getDirectSorted(field);
final int valueCount = source.getValueCount();
final byte[][] values = new byte[valueCount][];
BytesRef scratch = new BytesRef();
for(int ord=0;ord<valueCount;ord++) {
source.lookupOrd(ord, scratch);
values[ord] = new byte[scratch.length];
System.arraycopy(scratch.bytes, scratch.offset, values[ord], 0, scratch.length);
}
final int[] ords = new int[maxDoc];
for(int docID=0;docID<maxDoc;docID++) {
ords[docID] = source.getOrd(docID);
}
return new SortedDocValues() {
@Override
public int getOrd(int docID) {
return ords[docID];
}
@Override
public void lookupOrd(int ord, BytesRef result) {
result.bytes = values[ord];
result.offset = 0;
result.length = result.bytes.length;
}
@Override
public int getValueCount() {
return valueCount;
}
};
}
}

View File

@ -1,17 +1,5 @@
package org.apache.lucene.codecs.lucene41.values;
import java.io.IOException;
import org.apache.lucene.codecs.BinaryDocValuesConsumer;
import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.packed.AppendingLongBuffer;
import org.apache.lucene.util.packed.AppendingLongBuffer.Iterator;
import org.apache.lucene.util.packed.PackedInts;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@ -29,6 +17,18 @@ import org.apache.lucene.util.packed.PackedInts;
* limitations under the License.
*/
import java.io.IOException;
import org.apache.lucene.codecs.BinaryDocValuesConsumer;
import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.index.FieldInfos;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.packed.AppendingLongBuffer;
import org.apache.lucene.util.packed.AppendingLongBuffer.Iterator;
import org.apache.lucene.util.packed.PackedInts;
public class Lucene41BinaryDocValuesConsumer extends BinaryDocValuesConsumer {
private final IndexOutput dataOut;

View File

@ -49,13 +49,11 @@ public class Lucene41SimpleDocValuesFormat extends SimpleDocValuesFormat {
@Override
public SimpleDVProducer fieldsProducer(SegmentReadState state)
throws IOException {
// nocommit fixme
//return new Lucene41PerDocProducer(state);
return null;
return new Lucene41DocValuesReader(state);
}
//nocommit this is equivalent to sep - we should pack in CFS
private static final class Lucene41PerDocProducer extends PerDocProducerBase {
private static final class Lucene41DocValuesReader extends SimpleDVProducer {
private final TreeMap<String, DocValues> docValues;
/**

View File

@ -0,0 +1,26 @@
package org.apache.lucene.index;
/*
* 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 org.apache.lucene.util.BytesRef;
// nocommit need marker interface?
public abstract class BinaryDocValues {
// nocommit throws IOE or not?
public abstract void get(int docID, BytesRef result);
}

View File

@ -0,0 +1,24 @@
package org.apache.lucene.index;
/*
* 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.
*/
// nocommit need marker interface?
public abstract class NumericDocValues {
// nocommit throws IOE or not?
public abstract long get(int docID);
}

View File

@ -0,0 +1,32 @@
package org.apache.lucene.index;
/*
* 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 org.apache.lucene.util.BytesRef;
// nocommit need marker interface?
public abstract class SortedDocValues {
// nocommit throws IOE or not?
public abstract int getOrd(int docID);
// nocommit throws IOE or not?
public abstract void lookupOrd(int ord, BytesRef result);
// nocommit throws IOE or not?
public abstract int getValueCount();
}