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


Java IndexInput.seek方法代码示例

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


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

示例1: getVariableBinary

import org.apache.lucene.store.IndexInput; //导入方法依赖的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);
      }
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Lucene45DocValuesProducer.java

示例2: getMissingBits

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
private Bits getMissingBits(final long offset) throws IOException {
  if (offset == -1) {
    return new Bits.MatchAllBits(maxDoc);
  } else {
    final IndexInput in = data.clone();
    return new Bits() {

      @Override
      public boolean get(int index) {
        try {
          in.seek(offset + (index >> 3));
          return (in.readByte() & (1 << (index & 7))) != 0;
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      @Override
      public int length() {
        return maxDoc;
      }
    };
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Lucene45DocValuesProducer.java

示例3: getVariableBinary

import org.apache.lucene.store.IndexInput; //导入方法依赖的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);
      }
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Lucene49DocValuesProducer.java

示例4: getIntervalInstance

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
/** returns an address instance for prefix-compressed binary values. */
private MonotonicBlockPackedReader getIntervalInstance(IndexInput data, FieldInfo field, BinaryEntry bytes) throws IOException {
  final MonotonicBlockPackedReader addresses;
  final long interval = bytes.addressInterval;
  synchronized (addressInstances) {
    MonotonicBlockPackedReader addrInstance = addressInstances.get(field.number);
    if (addrInstance == null) {
      data.seek(bytes.addressesOffset);
      final long size;
      if (bytes.count % interval == 0) {
        size = bytes.count / interval;
      } else {
        size = 1L + bytes.count / interval;
      }
      addrInstance = MonotonicBlockPackedReader.of(data, bytes.packedIntsVersion, bytes.blockSize, size, false);
      addressInstances.put(field.number, addrInstance);
      ramBytesUsed.addAndGet(addrInstance.ramBytesUsed() + RamUsageEstimator.NUM_BYTES_INT);
    }
    addresses = addrInstance;
  }
  return addresses;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:Lucene49DocValuesProducer.java

示例5: 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

示例6: getVariableBinary

import org.apache.lucene.store.IndexInput; //导入方法依赖的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);
      }
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:Lucene410DocValuesProducer.java

示例7: 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

示例8: testVerifyingIndexInput

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
public void testVerifyingIndexInput() throws IOException {
    Directory dir = newDirectory();
    IndexOutput output = dir.createOutput("foo.bar", IOContext.DEFAULT);
    int iters = scaledRandomIntBetween(10, 100);
    for (int i = 0; i < iters; i++) {
        BytesRef bytesRef = new BytesRef(TestUtil.randomRealisticUnicodeString(random(), 10, 1024));
        output.writeBytes(bytesRef.bytes, bytesRef.offset, bytesRef.length);
    }
    CodecUtil.writeFooter(output);
    output.close();

    // Check file
    IndexInput indexInput = dir.openInput("foo.bar", IOContext.DEFAULT);
    long checksum = CodecUtil.retrieveChecksum(indexInput);
    indexInput.seek(0);
    IndexInput verifyingIndexInput = new Store.VerifyingIndexInput(dir.openInput("foo.bar", IOContext.DEFAULT));
    readIndexInputFullyWithRandomSeeks(verifyingIndexInput);
    Store.verify(verifyingIndexInput);
    assertThat(checksum, equalTo(((ChecksumIndexInput) verifyingIndexInput).getChecksum()));
    IOUtils.close(indexInput, verifyingIndexInput);

    // Corrupt file and check again
    corruptFile(dir, "foo.bar", "foo1.bar");
    verifyingIndexInput = new Store.VerifyingIndexInput(dir.openInput("foo1.bar", IOContext.DEFAULT));
    readIndexInputFullyWithRandomSeeks(verifyingIndexInput);
    try {
        Store.verify(verifyingIndexInput);
        fail("should be a corrupted index");
    } catch (CorruptIndexException | IndexFormatTooOldException | IndexFormatTooNewException ex) {
        // ok
    }
    IOUtils.close(verifyingIndexInput);
    IOUtils.close(dir);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:35,代码来源:StoreTests.java

示例9: getAddressInstance

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
/** returns an address instance for variable-length binary values.
 *  @lucene.internal */
protected MonotonicBlockPackedReader getAddressInstance(IndexInput data, FieldInfo field, BinaryEntry bytes) throws IOException {
  final MonotonicBlockPackedReader addresses;
  synchronized (addressInstances) {
    MonotonicBlockPackedReader addrInstance = addressInstances.get(field.number);
    if (addrInstance == null) {
      data.seek(bytes.addressesOffset);
      addrInstance = MonotonicBlockPackedReader.of(data, bytes.packedIntsVersion, bytes.blockSize, bytes.count, false);
      addressInstances.put(field.number, addrInstance);
      ramBytesUsed.addAndGet(addrInstance.ramBytesUsed() + RamUsageEstimator.NUM_BYTES_INT);
    }
    addresses = addrInstance;
  }
  return addresses;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:Lucene45DocValuesProducer.java

示例10: getOrdIndexInstance

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
/** returns an address instance for sortedset ordinal lists
 * @lucene.internal */
protected MonotonicBlockPackedReader getOrdIndexInstance(IndexInput data, FieldInfo field, NumericEntry entry) throws IOException {
  final MonotonicBlockPackedReader ordIndex;
  synchronized (ordIndexInstances) {
    MonotonicBlockPackedReader ordIndexInstance = ordIndexInstances.get(field.number);
    if (ordIndexInstance == null) {
      data.seek(entry.offset);
      ordIndexInstance = MonotonicBlockPackedReader.of(data, entry.packedIntsVersion, entry.blockSize, entry.count, false);
      ordIndexInstances.put(field.number, ordIndexInstance);
      ramBytesUsed.addAndGet(ordIndexInstance.ramBytesUsed() + RamUsageEstimator.NUM_BYTES_INT);
    }
    ordIndex = ordIndexInstance;
  }
  return ordIndex;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:Lucene45DocValuesProducer.java

示例11: getAddressInstance

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
/** returns an address instance for variable-length binary values. */
private MonotonicBlockPackedReader getAddressInstance(IndexInput data, FieldInfo field, BinaryEntry bytes) throws IOException {
  final MonotonicBlockPackedReader addresses;
  synchronized (addressInstances) {
    MonotonicBlockPackedReader addrInstance = addressInstances.get(field.number);
    if (addrInstance == null) {
      data.seek(bytes.addressesOffset);
      addrInstance = MonotonicBlockPackedReader.of(data, bytes.packedIntsVersion, bytes.blockSize, bytes.count+1, false);
      addressInstances.put(field.number, addrInstance);
      ramBytesUsed.addAndGet(addrInstance.ramBytesUsed() + RamUsageEstimator.NUM_BYTES_INT);
    }
    addresses = addrInstance;
  }
  return addresses;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:Lucene49DocValuesProducer.java

示例12: getOrdIndexInstance

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
/** returns an address instance for sortedset ordinal lists */
private MonotonicBlockPackedReader getOrdIndexInstance(IndexInput data, FieldInfo field, NumericEntry entry) throws IOException {
  final MonotonicBlockPackedReader ordIndex;
  synchronized (ordIndexInstances) {
    MonotonicBlockPackedReader ordIndexInstance = ordIndexInstances.get(field.number);
    if (ordIndexInstance == null) {
      data.seek(entry.offset);
      ordIndexInstance = MonotonicBlockPackedReader.of(data, entry.packedIntsVersion, entry.blockSize, entry.count+1, false);
      ordIndexInstances.put(field.number, ordIndexInstance);
      ramBytesUsed.addAndGet(ordIndexInstance.ramBytesUsed() + RamUsageEstimator.NUM_BYTES_INT);
    }
    ordIndex = ordIndexInstance;
  }
  return ordIndex;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:Lucene49DocValuesProducer.java

示例13: seekDir

import org.apache.lucene.store.IndexInput; //导入方法依赖的package包/类
/** Seek {@code input} to the directory offset. */
protected void seekDir(IndexInput input, long dirOffset)
    throws IOException {
  if (version >= BlockTreeTermsWriter.VERSION_CHECKSUM) {
    input.seek(input.length() - CodecUtil.footerLength() - 8);
    dirOffset = input.readLong();
  } else if (version >= BlockTreeTermsWriter.VERSION_APPEND_ONLY) {
    input.seek(input.length() - 8);
    dirOffset = input.readLong();
  }
  input.seek(dirOffset);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:BlockTreeTermsReader.java

示例14: 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

示例15: 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


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