本文整理汇总了Java中org.apache.lucene.index.BinaryDocValues类的典型用法代码示例。如果您正苦于以下问题:Java BinaryDocValues类的具体用法?Java BinaryDocValues怎么用?Java BinaryDocValues使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BinaryDocValues类属于org.apache.lucene.index包,在下文中一共展示了BinaryDocValues类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBinary
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
@Override
public synchronized BinaryDocValues getBinary(FieldInfo field) throws IOException {
BinaryDocValues instance = binaryInstances.get(field.number);
if (instance == null) {
switch(LegacyDocValuesType.valueOf(field.getAttribute(legacyKey))) {
case BYTES_FIXED_STRAIGHT:
instance = loadBytesFixedStraight(field);
break;
case BYTES_VAR_STRAIGHT:
instance = loadBytesVarStraight(field);
break;
case BYTES_FIXED_DEREF:
instance = loadBytesFixedDeref(field);
break;
case BYTES_VAR_DEREF:
instance = loadBytesVarDeref(field);
break;
default:
throw new AssertionError();
}
binaryInstances.put(field.number, instance);
}
return instance;
}
示例2: getVariableBinary
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
private BinaryDocValues getVariableBinary(FieldInfo field, final BinaryEntry bytes) throws IOException {
final IndexInput data = this.data.clone();
final MonotonicBlockPackedReader addresses = getAddressInstance(data, field, bytes);
return new LongBinaryDocValues() {
final BytesRef term = new BytesRef(Math.max(0, bytes.maxLength));
@Override
public BytesRef get(long id) {
long startAddress = bytes.offset + (id == 0 ? 0 : addresses.get(id-1));
long endAddress = bytes.offset + addresses.get(id);
int length = (int) (endAddress - startAddress);
try {
data.seek(startAddress);
data.readBytes(term.bytes, 0, length);
term.length = length;
return term;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}
示例3: getVariableBinary
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
private BinaryDocValues getVariableBinary(FieldInfo field, final BinaryEntry bytes) throws IOException {
final IndexInput data = this.data.clone();
final MonotonicBlockPackedReader addresses = getAddressInstance(data, field, bytes);
return new LongBinaryDocValues() {
final BytesRef term = new BytesRef(Math.max(0, bytes.maxLength));
@Override
public BytesRef get(long id) {
long startAddress = bytes.offset + addresses.get(id);
long endAddress = bytes.offset + addresses.get(id+1);
int length = (int) (endAddress - startAddress);
try {
data.seek(startAddress);
data.readBytes(term.bytes, 0, length);
term.length = length;
return term;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}
示例4: getFixedBinary
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
private BinaryDocValues getFixedBinary(FieldInfo field, final BinaryEntry bytes) throws IOException {
final IndexInput data = this.data.slice("fixed-binary", bytes.offset, bytes.count * bytes.maxLength);
final BytesRef term = new BytesRef(bytes.maxLength);
final byte[] buffer = term.bytes;
final int length = term.length = bytes.maxLength;
return new LongBinaryDocValues() {
@Override
public BytesRef get(long id) {
try {
data.seek(id * length);
data.readBytes(buffer, 0, buffer.length);
return term;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}
示例5: getVariableBinary
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
private BinaryDocValues getVariableBinary(FieldInfo field, final BinaryEntry bytes) throws IOException {
final MonotonicBlockPackedReader addresses = getAddressInstance(field, bytes);
final IndexInput data = this.data.slice("var-binary", bytes.offset, bytes.addressesOffset - bytes.offset);
final BytesRef term = new BytesRef(Math.max(0, bytes.maxLength));
final byte buffer[] = term.bytes;
return new LongBinaryDocValues() {
@Override
public BytesRef get(long id) {
long startAddress = addresses.get(id);
long endAddress = addresses.get(id+1);
int length = (int) (endAddress - startAddress);
try {
data.seek(startAddress);
data.readBytes(buffer, 0, length);
term.length = length;
return term;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}
示例6: getTerms
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
public BinaryDocValues getTerms(AtomicReader reader, String field, boolean setDocsWithField, float acceptableOverheadRatio) throws IOException {
BinaryDocValues valuesIn = reader.getBinaryDocValues(field);
if (valuesIn == null) {
valuesIn = reader.getSortedDocValues(field);
}
if (valuesIn != null) {
// Not cached here by FieldCacheImpl (cached instead
// per-thread by SegmentReader):
return valuesIn;
}
final FieldInfo info = reader.getFieldInfos().fieldInfo(field);
if (info == null) {
return DocValues.emptyBinary();
} else if (info.hasDocValues()) {
throw new IllegalStateException("Type mismatch: " + field + " was indexed as " + info.getDocValuesType());
} else if (!info.isIndexed()) {
return DocValues.emptyBinary();
}
BinaryDocValuesImpl impl = (BinaryDocValuesImpl) caches.get(BinaryDocValues.class).get(reader, new CacheKey(field, acceptableOverheadRatio), setDocsWithField);
return impl.iterator();
}
示例7: getBinary
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
@Override
public synchronized BinaryDocValues getBinary(FieldInfo field) throws IOException {
BinaryRawValues instance = binaryInstances.get(field.number);
if (instance == null) {
// Lazy load
instance = loadBinary(binaries.get(field.number));
binaryInstances.put(field.number, instance);
}
final byte[] bytes = instance.bytes;
final int[] address = instance.address;
return new BinaryDocValues() {
final BytesRef term = new BytesRef();
@Override
public BytesRef get(int docID) {
term.bytes = bytes;
term.offset = address[docID];
term.length = address[docID+1] - term.offset;
return term;
}
};
}
示例8: newSortedInstance
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
private SortedDocValues newSortedInstance(final NumericDocValues docToOrd, final BinaryDocValues values, final int count) {
return new SortedDocValues() {
@Override
public int getOrd(int docID) {
return (int) docToOrd.get(docID);
}
@Override
public BytesRef lookupOrd(int ord) {
return values.get(ord);
}
@Override
public int getValueCount() {
return count;
}
// Leave lookupTerm to super's binary search
// Leave termsEnum to super
};
}
示例9: getReader
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
@Override
public OrdinalsSegmentReader getReader(AtomicReaderContext context) throws IOException {
BinaryDocValues values0 = context.reader().getBinaryDocValues(field);
if (values0 == null) {
values0 = DocValues.emptyBinary();
}
final BinaryDocValues values = values0;
return new OrdinalsSegmentReader() {
@Override
public void get(int docID, IntsRef ordinals) throws IOException {
final BytesRef bytes = values.get(docID);
decode(bytes, ordinals);
}
};
}
示例10: getFixedBinary
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
private BinaryDocValues getFixedBinary(FieldInfo field, final BinaryEntry bytes) {
final IndexInput data = this.data.clone();
return new LongBinaryDocValues() {
final BytesRef term;
{
term = new BytesRef(bytes.maxLength);
term.offset = 0;
term.length = bytes.maxLength;
}
@Override
public BytesRef get(long id) {
long address = bytes.offset + id * bytes.maxLength;
try {
data.seek(address);
data.readBytes(term.bytes, 0, term.length);
return term;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}
示例11: getFixedBinary
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
private BinaryDocValues getFixedBinary(FieldInfo field, final BinaryEntry bytes) {
final IndexInput data = this.data.clone();
return new LongBinaryDocValues() {
final BytesRef term;
{
term = new BytesRef(bytes.maxLength);
term.offset = 0;
term.length = bytes.maxLength;
}
@Override
public BytesRef get(long id) {
long address = bytes.offset + id * bytes.maxLength;
try {
data.seek(address);
data.readBytes(term.bytes, 0, term.length);
return term;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}
示例12: getFixedBinary
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
private BinaryDocValues getFixedBinary(FieldInfo field, final BinaryEntry bytes) {
final IndexInput data = this.data.clone();
return new LongBinaryDocValues() {
@Override
public void get(long id, BytesRef result) {
long address = bytes.offset + id * bytes.maxLength;
try {
data.seek(address);
// NOTE: we could have one buffer, but various consumers (e.g. FieldComparatorSource)
// assume "they" own the bytes after calling this!
final byte[] buffer = new byte[bytes.maxLength];
data.readBytes(buffer, 0, buffer.length);
result.bytes = buffer;
result.offset = 0;
result.length = buffer.length;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}
示例13: getSorted
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
@Override
public SortedDocValues getSorted(FieldInfo field) throws IOException {
final int valueCount = (int) binaries.get(field.number).count;
final BinaryDocValues binary = getBinary(field);
final NumericDocValues ordinals = getNumeric(field, ords.get(field.number));
return new SortedDocValues() {
@Override
public int getOrd(int docID) {
return (int) ordinals.get(docID);
}
@Override
public void lookupOrd(int ord, BytesRef result) {
binary.get(ord, result);
}
@Override
public int getValueCount() {
return valueCount;
}
};
}
示例14: getBinary
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
@Override
public BinaryDocValues getBinary(FieldInfo field) throws IOException {
BinaryDocValues binaryDocValues = _binaryDocValuesCache.get(field.number);
if (binaryDocValues != null) {
return binaryDocValues;
}
synchronized (_binaryDocValuesCache) {
binaryDocValues = _binaryDocValuesCache.get(field.number);
if (binaryDocValues != null) {
return binaryDocValues;
}
binaryDocValues = newBinary(field);
if (_cache && binaryDocValues != null) {
_binaryDocValuesCache.put(field.number, binaryDocValues);
}
return binaryDocValues;
}
}
示例15: testBinaryDocValues
import org.apache.lucene.index.BinaryDocValues; //导入依赖的package包/类
@Test
public void testBinaryDocValues() throws IOException {
SecureAtomicReader secureReader = getSecureReader();
BinaryDocValues binaryDocValues = secureReader.getBinaryDocValues("bin");
BytesRef result = new BytesRef();
binaryDocValues.get(0, result);
assertEquals(new BytesRef("0".getBytes()), result);
binaryDocValues.get(1, result);
assertEquals(new BytesRef(), result);
binaryDocValues.get(2, result);
assertEquals(new BytesRef("2".getBytes()), result);
binaryDocValues.get(3, result);
assertEquals(new BytesRef(), result);
}