本文整理汇总了Java中org.apache.lucene.store.DataInput类的典型用法代码示例。如果您正苦于以下问题:Java DataInput类的具体用法?Java DataInput怎么用?Java DataInput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataInput类属于org.apache.lucene.store包,在下文中一共展示了DataInput类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: skipField
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
private static void skipField(DataInput in, int bits) throws IOException {
switch (bits & TYPE_MASK) {
case BYTE_ARR:
case STRING:
final int length = in.readVInt();
in.skipBytes(length);
break;
case NUMERIC_INT:
case NUMERIC_FLOAT:
in.readInt();
break;
case NUMERIC_LONG:
case NUMERIC_DOUBLE:
in.readLong();
break;
default:
throw new AssertionError("Unknown type flag: " + Integer.toHexString(bits));
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:CompressingStoredFieldsReader.java
示例2: ForUtil
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
/**
* Restore a {@link ForUtil} from a {@link DataInput}.
*/
ForUtil(DataInput in) throws IOException {
int packedIntsVersion = in.readVInt();
PackedInts.checkVersion(packedIntsVersion);
encodedSizes = new int[33];
encoders = new PackedInts.Encoder[33];
decoders = new PackedInts.Decoder[33];
iterations = new int[33];
for (int bpv = 1; bpv <= 32; ++bpv) {
final int code = in.readVInt();
final int formatId = code >>> 5;
final int bitsPerValue = (code & 31) + 1;
final PackedInts.Format format = PackedInts.Format.byId(formatId);
assert format.isSupported(bitsPerValue);
encodedSizes[bpv] = encodedSize(format, packedIntsVersion, bitsPerValue);
encoders[bpv] = PackedInts.getEncoder(
format, packedIntsVersion, bitsPerValue);
decoders[bpv] = PackedInts.getDecoder(
format, packedIntsVersion, bitsPerValue);
iterations[bpv] = computeIterations(decoders[bpv]);
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:ForUtil.java
示例3: checkHeaderNoMagic
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
/** Like {@link
* #checkHeader(DataInput,String,int,int)} except this
* version assumes the first int has already been read
* and validated from the input. */
public static int checkHeaderNoMagic(DataInput in, String codec, int minVersion, int maxVersion) throws IOException {
final String actualCodec = in.readString();
if (!actualCodec.equals(codec)) {
throw new CorruptIndexException("codec mismatch: actual codec=" + actualCodec + " vs expected codec=" + codec + " (resource: " + in + ")");
}
final int actualVersion = in.readInt();
if (actualVersion < minVersion) {
throw new IndexFormatTooOldException(in, actualVersion, minVersion, maxVersion);
}
if (actualVersion > maxVersion) {
throw new IndexFormatTooNewException(in, actualVersion, minVersion, maxVersion);
}
return actualVersion;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:CodecUtil.java
示例4: BytesStore
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
/** Pulls bytes from the provided IndexInput. */
public BytesStore(DataInput in, long numBytes, int maxBlockSize) throws IOException {
int blockSize = 2;
int blockBits = 1;
while(blockSize < numBytes && blockSize < maxBlockSize) {
blockSize *= 2;
blockBits++;
}
this.blockBits = blockBits;
this.blockSize = blockSize;
this.blockMask = blockSize-1;
long left = numBytes;
while(left > 0) {
final int chunk = (int) Math.min(blockSize, left);
byte[] block = new byte[chunk];
in.readBytes(block, 0, block.length);
blocks.add(block);
left -= chunk;
}
// So .getPosition still works
nextWrite = blocks.get(blocks.size()-1).length;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:BytesStore.java
示例5: Packed64
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
/**
* Creates an array with content retrieved from the given DataInput.
* @param in a DataInput, positioned at the start of Packed64-content.
* @param valueCount the number of elements.
* @param bitsPerValue the number of bits available for any given value.
* @throws java.io.IOException if the values for the backing array could not
* be retrieved.
*/
public Packed64(int packedIntsVersion, DataInput in, int valueCount, int bitsPerValue)
throws IOException {
super(valueCount, bitsPerValue);
final PackedInts.Format format = PackedInts.Format.PACKED;
final long byteCount = format.byteCount(packedIntsVersion, valueCount, bitsPerValue); // to know how much to read
final int longCount = format.longCount(PackedInts.VERSION_CURRENT, valueCount, bitsPerValue); // to size the array
blocks = new long[longCount];
// read as many longs as we can
for (int i = 0; i < byteCount / 8; ++i) {
blocks[i] = in.readLong();
}
final int remaining = (int) (byteCount % 8);
if (remaining != 0) {
// read the last bytes
long lastLong = 0;
for (int i = 0; i < remaining; ++i) {
lastLong |= (in.readByte() & 0xFFL) << (56 - i * 8);
}
blocks[blocks.length - 1] = lastLong;
}
maskRight = ~0L << (BLOCK_SIZE-bitsPerValue) >>> (BLOCK_SIZE-bitsPerValue);
bpvMinusBlockSize = bitsPerValue - BLOCK_SIZE;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:Packed64.java
示例6: read
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
@Override
public void read(final DataInput indexIn, final boolean absolute) throws IOException {
if (absolute) {
upto = indexIn.readVInt();
fp = indexIn.readVLong();
} else {
final int uptoDelta = indexIn.readVInt();
if ((uptoDelta & 1) == 1) {
// same block
upto += uptoDelta >>> 1;
} else {
// new block
upto = uptoDelta >>> 1;
fp += indexIn.readVLong();
}
}
assert upto < blockSize;
}
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:FixedIntBlockIndexInput.java
示例7: read
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
@Override
public void read(final DataInput indexIn, final boolean absolute) throws IOException {
if (absolute) {
upto = indexIn.readVInt();
fp = indexIn.readVLong();
} else {
final int uptoDelta = indexIn.readVInt();
if ((uptoDelta & 1) == 1) {
// same block
upto += uptoDelta >>> 1;
} else {
// new block
upto = uptoDelta >>> 1;
fp += indexIn.readVLong();
}
}
// TODO: we can't do this assert because non-causal
// int encoders can have upto over the buffer size
//assert upto < maxBlockSize: "upto=" + upto + " max=" + maxBlockSize;
}
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:VariableIntBlockIndexInput.java
示例8: skipOutput
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
@Override
public void skipOutput(DataInput in) throws IOException {
int bits = in.readByte() & 0xff;
int bit0 = bits & 1;
int bit1 = bits & 2;
int bit2 = bits & 4;
int bytesSize = (bits >>> 3);
if (bit1 > 0 && bytesSize == 0) { // determine extra length
bytesSize = in.readVInt();
}
if (bit0 > 0) { // not all-zero case
for (int pos = 0; pos < longsSize; pos++) {
in.readVLong();
}
}
if (bit1 > 0) { // bytes exists
in.skipBytes(bytesSize);
}
if (bit2 > 0) { // stats exist
int code = in.readVInt();
if (hasPos && (code & 1) == 0) {
in.readVLong();
}
}
}
开发者ID:europeana,项目名称:search,代码行数:26,代码来源:FSTTermOutputs.java
示例9: read
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
@Override
public Output read(DataInput in) throws IOException {
int len = in.readVInt();
BytesRef bytes;
if (len == 0) {
bytes = NO_BYTES;
} else {
bytes = new BytesRef(len);
in.readBytes(bytes.bytes, 0, len);
bytes.length = len;
}
long startOrd = in.readVLong();
long endOrd = in.readVLong();
Output result = newOutput(bytes, startOrd, endOrd);
return result;
}
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:FSTOrdsOutputs.java
示例10: readLine
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
public static void readLine(DataInput in, BytesRefBuilder scratch) throws IOException {
int upto = 0;
while(true) {
byte b = in.readByte();
scratch.grow(1+upto);
if (b == ESCAPE) {
scratch.setByteAt(upto++, in.readByte());
} else {
if (b == NEWLINE) {
break;
} else {
scratch.setByteAt(upto++, b);
}
}
}
scratch.setLength(upto);
}
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:SimpleTextUtil.java
示例11: deserialize
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
public static FuzzySet deserialize(DataInput in) throws IOException
{
int version=in.readInt();
if (version == VERSION_SPI) {
in.readString();
}
final HashFunction hashFunction = hashFunctionForVersion(version);
int bloomSize=in.readInt();
int numLongs=in.readInt();
long[]longs=new long[numLongs];
for (int i = 0; i < numLongs; i++) {
longs[i]=in.readLong();
}
FixedBitSet bits = new FixedBitSet(longs,bloomSize+1);
return new FuzzySet(bits,bloomSize,hashFunction);
}
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:FuzzySet.java
示例12: load
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
@Override
public boolean load(DataInput input) throws IOException {
CodecUtil.checkHeader(input, CODEC_NAME, VERSION_START, VERSION_START);
count = input.readVLong();
byte separatorOrig = input.readByte();
if (separatorOrig != separator) {
throw new IllegalStateException("separator=" + separator + " is incorrect: original model was built with separator=" + separatorOrig);
}
int gramsOrig = input.readVInt();
if (gramsOrig != grams) {
throw new IllegalStateException("grams=" + grams + " is incorrect: original model was built with grams=" + gramsOrig);
}
totTokens = input.readVLong();
fst = new FST<>(input, PositiveIntOutputs.getSingleton());
return true;
}
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:FreeTextSuggester.java
示例13: readRecursively
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
private void readRecursively(DataInput in, TernaryTreeNode node) throws IOException {
node.splitchar = in.readString().charAt(0);
byte mask = in.readByte();
if ((mask & HAS_TOKEN) != 0) {
node.token = in.readString();
}
if ((mask & HAS_VALUE) != 0) {
node.val = Long.valueOf(in.readLong());
}
if ((mask & LO_KID) != 0) {
node.loKid = new TernaryTreeNode();
readRecursively(in, node.loKid);
}
if ((mask & EQ_KID) != 0) {
node.eqKid = new TernaryTreeNode();
readRecursively(in, node.eqKid);
}
if ((mask & HI_KID) != 0) {
node.hiKid = new TernaryTreeNode();
readRecursively(in, node.hiKid);
}
}
开发者ID:europeana,项目名称:search,代码行数:23,代码来源:TSTLookup.java
示例14: read
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
@Override
public Object read(DataInput in) throws IOException {
final long code = in.readVLong();
if ((code & 1) == 0) {
// single long
final long v = code >>> 1;
if (v == 0) {
return NO_OUTPUT;
} else {
return Long.valueOf(v);
}
} else {
// two longs
final long first = code >>> 1;
final long second = in.readVLong();
return new TwoLongs(first, second);
}
}
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:UpToTwoPositiveIntOutputs.java
示例15: CharacterDefinition
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
private CharacterDefinition() throws IOException {
InputStream is = null;
boolean success = false;
try {
is = BinaryDictionary.getClassResource(getClass(), FILENAME_SUFFIX);
is = new BufferedInputStream(is);
final DataInput in = new InputStreamDataInput(is);
CodecUtil.checkHeader(in, HEADER, VERSION, VERSION);
in.readBytes(characterCategoryMap, 0, characterCategoryMap.length);
for (int i = 0; i < CLASS_COUNT; i++) {
final byte b = in.readByte();
invokeMap[i] = (b & 0x01) != 0;
groupMap[i] = (b & 0x02) != 0;
}
success = true;
} finally {
if (success) {
IOUtils.close(is);
} else {
IOUtils.closeWhileHandlingException(is);
}
}
}
开发者ID:europeana,项目名称:search,代码行数:24,代码来源:CharacterDefinition.java
示例16: readLine
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
public static void readLine(DataInput in, BytesRef scratch) throws IOException {
int upto = 0;
while(true) {
byte b = in.readByte();
if (scratch.bytes.length == upto) {
scratch.grow(1+upto);
}
if (b == ESCAPE) {
scratch.bytes[upto++] = in.readByte();
} else {
if (b == NEWLINE) {
break;
} else {
scratch.bytes[upto++] = b;
}
}
}
scratch.offset = 0;
scratch.length = upto;
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:21,代码来源:SimpleTextUtil.java
示例17: skipField
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
private static void skipField(DataInput in, int bits) throws IOException {
switch (bits & TYPE_MASK) {
case BYTE_ARR:
case STRING:
final int length = in.readVInt();
skipBytes(in, length);
break;
case NUMERIC_INT:
case NUMERIC_FLOAT:
in.readInt();
break;
case NUMERIC_LONG:
case NUMERIC_DOUBLE:
in.readLong();
break;
default:
throw new AssertionError("Unknown type flag: " + Integer.toHexString(bits));
}
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:20,代码来源:CompressingStoredFieldsReader.java
示例18: load
import org.apache.lucene.store.DataInput; //导入依赖的package包/类
@Override
public boolean load(DataInput input) throws IOException {
CodecUtil.checkHeader(input, CODEC_NAME, VERSION_START, VERSION_START);
count = input.readVLong();
byte separatorOrig = input.readByte();
if (separatorOrig != separator) {
throw new IllegalStateException("separator=" + separator + " is incorrect: original model was built with separator=" + separatorOrig);
}
int gramsOrig = input.readVInt();
if (gramsOrig != grams) {
throw new IllegalStateException("grams=" + grams + " is incorrect: original model was built with grams=" + gramsOrig);
}
totTokens = input.readVLong();
fst = new FST<Long>(input, PositiveIntOutputs.getSingleton());
return true;
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:19,代码来源:FreeTextSuggester.java
注:本文中的org.apache.lucene.store.DataInput类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论