当前位置: 首页>>代码示例>>Java>>正文


Java IndexInput.getFilePointer方法代码示例

本文整理汇总了Java中org.apache.lucene.store.IndexInput.getFilePointer方法的典型用法代码示例。如果您正苦于以下问题:Java IndexInput.getFilePointer方法的具体用法?Java IndexInput.getFilePointer怎么用?Java IndexInput.getFilePointer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.lucene.store.IndexInput的用法示例。


在下文中一共展示了IndexInput.getFilePointer方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: CompressedIndexInput

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
public CompressedIndexInput(IndexInput in) throws IOException {
    super("compressed(" + in.toString() + ")");
    this.in = in;
    readHeader(in);
    this.version = in.readInt();
    long metaDataPosition = in.readLong();
    long headerLength = in.getFilePointer();
    in.seek(metaDataPosition);
    this.totalUncompressedLength = in.readVLong();
    int size = in.readVInt();
    offsets = BigArrays.NON_RECYCLING_INSTANCE.newLongArray(size);
    for (int i = 0; i < size; i++) {
        offsets.set(i, in.readVLong());
    }
    this.currentOffsetIdx = -1;
    this.currentUncompressedChunkPointer = 0;
    in.seek(headerLength);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:19,代码来源:CompressedIndexInput.java

示例2: isCompressed

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
@Override
public boolean isCompressed(IndexInput in) throws IOException {
    long currentPointer = in.getFilePointer();
    // since we have some metdata before the first compressed header, we check on our specific header
    if (in.length() - currentPointer < (LUCENE_HEADER.length)) {
        return false;
    }
    for (int i = 0; i < LUCENE_HEADER.length; i++) {
        if (in.readByte() != LUCENE_HEADER[i]) {
            in.seek(currentPointer);
            return false;
        }
    }
    in.seek(currentPointer);
    return true;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:17,代码来源:LZFCompressor.java

示例3: InputStreamIndexInput

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
public InputStreamIndexInput(IndexInput indexInput, long limit) {
    this.indexInput = indexInput;
    this.limit = limit;
    if ((indexInput.length() - indexInput.getFilePointer()) > limit) {
        actualSizeToRead = limit;
    } else {
        actualSizeToRead = indexInput.length() - indexInput.getFilePointer();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:InputStreamIndexInput.java

示例4: checkEOF

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
/**
 * Checks that the stream is positioned at the end, and throws exception
 * if it is not. 
 * @deprecated Use {@link #checkFooter} instead, this should only used for files without checksums 
 */
@Deprecated
public static void checkEOF(IndexInput in) throws IOException {
  if (in.getFilePointer() != in.length()) {
    throw new CorruptIndexException("did not read all bytes from file: read " + in.getFilePointer() + " vs size " + in.length() + " (resource: " + in + ")");
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:CodecUtil.java

示例5: DirectPacked64SingleBlockReader

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
DirectPacked64SingleBlockReader(int bitsPerValue, int valueCount,
    IndexInput in) {
  super(valueCount);
  this.in = in;
  this.bitsPerValue = bitsPerValue;
  startPointer = in.getFilePointer();
  valuesPerBlock = 64 / bitsPerValue;
  mask = ~(~0L << bitsPerValue);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DirectPacked64SingleBlockReader.java

示例6: BlockPackedReader

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
/** Sole constructor. */
public BlockPackedReader(IndexInput in, int packedIntsVersion, int blockSize, long valueCount, boolean direct) throws IOException {
  this.valueCount = valueCount;
  blockShift = checkBlockSize(blockSize, MIN_BLOCK_SIZE, MAX_BLOCK_SIZE);
  blockMask = blockSize - 1;
  final int numBlocks = numBlocks(valueCount, blockSize);
  long[] minValues = null;
  subReaders = new PackedInts.Reader[numBlocks];
  for (int i = 0; i < numBlocks; ++i) {
    final int token = in.readByte() & 0xFF;
    final int bitsPerValue = token >>> BPV_SHIFT;
    if (bitsPerValue > 64) {
      throw new IOException("Corrupted");
    }
    if ((token & MIN_VALUE_EQUALS_0) == 0) {
      if (minValues == null) {
        minValues = new long[numBlocks];
      }
      minValues[i] = zigZagDecode(1L + readVLong(in));
    }
    if (bitsPerValue == 0) {
      subReaders[i] = new PackedInts.NullReader(blockSize);
    } else {
      final int size = (int) Math.min(blockSize, valueCount - (long) i * blockSize);
      if (direct) {
        final long pointer = in.getFilePointer();
        subReaders[i] = PackedInts.getDirectReaderNoHeader(in, PackedInts.Format.PACKED, packedIntsVersion, size, bitsPerValue);
        in.seek(pointer + PackedInts.Format.PACKED.byteCount(packedIntsVersion, size, bitsPerValue));
      } else {
        subReaders[i] = PackedInts.getReaderNoHeader(in, PackedInts.Format.PACKED, packedIntsVersion, size, bitsPerValue);
      }
    }
  }
  this.minValues = minValues;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:BlockPackedReader.java

示例7: MonotonicBlockPackedReader

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
private MonotonicBlockPackedReader(IndexInput in, int packedIntsVersion, int blockSize, long valueCount, boolean direct) throws IOException {
  this.valueCount = valueCount;
  blockShift = checkBlockSize(blockSize, MIN_BLOCK_SIZE, MAX_BLOCK_SIZE);
  blockMask = blockSize - 1;
  final int numBlocks = numBlocks(valueCount, blockSize);
  minValues = new long[numBlocks];
  averages = new float[numBlocks];
  subReaders = new PackedInts.Reader[numBlocks];
  for (int i = 0; i < numBlocks; ++i) {
    if (packedIntsVersion < PackedInts.VERSION_MONOTONIC_WITHOUT_ZIGZAG) {
      minValues[i] = in.readVLong();
    } else {
      minValues[i] = in.readZLong();
    }
    averages[i] = Float.intBitsToFloat(in.readInt());
    final int bitsPerValue = in.readVInt();
    if (bitsPerValue > 64) {
      throw new IOException("Corrupted");
    }
    if (bitsPerValue == 0) {
      subReaders[i] = new PackedInts.NullReader(blockSize);
    } else {
      final int size = (int) Math.min(blockSize, valueCount - (long) i * blockSize);
      if (direct) {
        final long pointer = in.getFilePointer();
        subReaders[i] = PackedInts.getDirectReaderNoHeader(in, PackedInts.Format.PACKED, packedIntsVersion, size, bitsPerValue);
        in.seek(pointer + PackedInts.Format.PACKED.byteCount(packedIntsVersion, size, bitsPerValue));
      } else {
        subReaders[i] = PackedInts.getReaderNoHeader(in, PackedInts.Format.PACKED, packedIntsVersion, size, bitsPerValue);
      }
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:MonotonicBlockPackedReader.java

示例8: DirectPackedReader

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
DirectPackedReader(int bitsPerValue, int valueCount, IndexInput in) {
  super(valueCount);
  this.in = in;
  this.bitsPerValue = bitsPerValue;

  startPointer = in.getFilePointer();
  if (bitsPerValue == 64) {
    valueMask = -1L;
  } else {
    valueMask = (1L << bitsPerValue) - 1;
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:DirectPackedReader.java

示例9: randomReadAndSlice

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
private byte[] randomReadAndSlice(IndexInput indexInput, int length) throws IOException {
    int readPos = (int) indexInput.getFilePointer();
    byte[] output = new byte[length];
    while (readPos < length) {
        switch (randomIntBetween(0, 3)) {
            case 0:
                // Read by one byte at a time
                output[readPos++] = indexInput.readByte();
                break;
            case 1:
                // Read several bytes into target
                int len = randomIntBetween(1, length - readPos);
                indexInput.readBytes(output, readPos, len);
                readPos += len;
                break;
            case 2:
                // Read several bytes into 0-offset target
                len = randomIntBetween(1, length - readPos);
                byte[] temp = new byte[len];
                indexInput.readBytes(temp, 0, len);
                System.arraycopy(temp, 0, output, readPos, len);
                readPos += len;
                break;
            case 3:
                // Read using slice
                len = randomIntBetween(1, length - readPos);
                IndexInput slice = indexInput.slice("slice (" + readPos + ", " + len + ") of " + indexInput.toString(), readPos, len);
                temp = randomReadAndSlice(slice, len);
                // assert that position in the original input didn't change
                assertEquals(readPos, indexInput.getFilePointer());
                System.arraycopy(temp, 0, output, readPos, len);
                readPos += len;
                indexInput.seek(readPos);
                assertEquals(readPos, indexInput.getFilePointer());
                break;
            default:
                fail();
        }
        assertEquals(readPos, indexInput.getFilePointer());
    }
    return output;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:43,代码来源:ByteArrayIndexInputTests.java

示例10: SkipBuffer

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
SkipBuffer(IndexInput input, int length) throws IOException {
  super("SkipBuffer on " + input);
  data = new byte[length];
  pointer = input.getFilePointer();
  input.readBytes(data, 0, length);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:MultiLevelSkipListReader.java

示例11: read

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
@Override
public FieldInfos read(Directory directory, String segmentName, String segmentSuffix, IOContext iocontext) throws IOException {
  final String fileName = IndexFileNames.segmentFileName(segmentName, "", FIELD_INFOS_EXTENSION);
  IndexInput input = directory.openInput(fileName, iocontext);
  
  boolean success = false;
  try {
    final int format = input.readVInt();

    if (format > FORMAT_MINIMUM) {
      throw new IndexFormatTooOldException(input, format, FORMAT_MINIMUM, FORMAT_CURRENT);
    }
    if (format < FORMAT_CURRENT) {
      throw new IndexFormatTooNewException(input, format, FORMAT_MINIMUM, FORMAT_CURRENT);
    }

    final int size = input.readVInt(); //read in the size
    FieldInfo infos[] = new FieldInfo[size];

    for (int i = 0; i < size; i++) {
      String name = input.readString();
      final int fieldNumber = i;
      byte bits = input.readByte();
      boolean isIndexed = (bits & IS_INDEXED) != 0;
      boolean storeTermVector = (bits & STORE_TERMVECTOR) != 0;
      boolean omitNorms = (bits & OMIT_NORMS) != 0;
      boolean storePayloads = (bits & STORE_PAYLOADS) != 0;
      final IndexOptions indexOptions;
      if (!isIndexed) {
        indexOptions = null;
      } else if ((bits & OMIT_TERM_FREQ_AND_POSITIONS) != 0) {
        indexOptions = IndexOptions.DOCS_ONLY;
      } else if ((bits & OMIT_POSITIONS) != 0) {
        if (format <= FORMAT_OMIT_POSITIONS) {
          indexOptions = IndexOptions.DOCS_AND_FREQS;
        } else {
          throw new CorruptIndexException("Corrupt fieldinfos, OMIT_POSITIONS set but format=" + format + " (resource: " + input + ")");
        }
      } else {
        indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
      }

      // LUCENE-3027: past indices were able to write
      // storePayloads=true when omitTFAP is also true,
      // which is invalid.  We correct that, here:
      if (indexOptions != IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) {
        storePayloads = false;
      }
      infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector, 
        omitNorms, storePayloads, indexOptions, null, isIndexed && !omitNorms? DocValuesType.NUMERIC : null, -1, Collections.<String,String>emptyMap());
    }

    if (input.getFilePointer() != input.length()) {
      throw new CorruptIndexException("did not read all bytes from file \"" + fileName + "\": read " + input.getFilePointer() + " vs size " + input.length() + " (resource: " + input + ")");
    }
    FieldInfos fieldInfos = new FieldInfos(infos);
    success = true;
    return fieldInfos;
  } finally {
    if (success) {
      input.close();
    } else {
      IOUtils.closeWhileHandlingException(input);
    }
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:67,代码来源:Lucene3xFieldInfosReader.java


注:本文中的org.apache.lucene.store.IndexInput.getFilePointer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。