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


Java PagedBytesDataOutput.writeVInt方法代码示例

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


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

示例1: TermInfosReaderIndex

import org.apache.lucene.util.PagedBytes.PagedBytesDataOutput; //导入方法依赖的package包/类
/**
 * Loads the segment information at segment load time.
 * 
 * @param indexEnum
 *          the term enum.
 * @param indexDivisor
 *          the index divisor.
 * @param tiiFileLength
 *          the size of the tii file, used to approximate the size of the
 *          buffer.
 * @param totalIndexInterval
 *          the total index interval.
 */
TermInfosReaderIndex(SegmentTermEnum indexEnum, int indexDivisor, long tiiFileLength, int totalIndexInterval) throws IOException {
  this.totalIndexInterval = totalIndexInterval;
  indexSize = 1 + ((int) indexEnum.size - 1) / indexDivisor;
  skipInterval = indexEnum.skipInterval;
  // this is only an inital size, it will be GCed once the build is complete
  long initialSize = (long) (tiiFileLength * 1.5) / indexDivisor;
  PagedBytes dataPagedBytes = new PagedBytes(estimatePageBits(initialSize));
  PagedBytesDataOutput dataOutput = dataPagedBytes.getDataOutput();

  final int bitEstimate = 1+MathUtil.log(tiiFileLength, 2);
  GrowableWriter indexToTerms = new GrowableWriter(bitEstimate, indexSize, PackedInts.DEFAULT);

  String currentField = null;
  List<String> fieldStrs = new ArrayList<>();
  int fieldCounter = -1;
  for (int i = 0; indexEnum.next(); i++) {
    Term term = indexEnum.term();
    if (currentField == null || !currentField.equals(term.field())) {
      currentField = term.field();
      fieldStrs.add(currentField);
      fieldCounter++;
    }
    TermInfo termInfo = indexEnum.termInfo();
    indexToTerms.set(i, dataOutput.getPosition());
    dataOutput.writeVInt(fieldCounter);
    dataOutput.writeString(term.text());
    dataOutput.writeVInt(termInfo.docFreq);
    if (termInfo.docFreq >= skipInterval) {
      dataOutput.writeVInt(termInfo.skipOffset);
    }
    dataOutput.writeVLong(termInfo.freqPointer);
    dataOutput.writeVLong(termInfo.proxPointer);
    dataOutput.writeVLong(indexEnum.indexPointer);
    for (int j = 1; j < indexDivisor; j++) {
      if (!indexEnum.next()) {
        break;
      }
    }
  }

  fields = new Term[fieldStrs.size()];
  for (int i = 0; i < fields.length; i++) {
    fields[i] = new Term(fieldStrs.get(i));
  }
  
  dataPagedBytes.freeze(true);
  dataInput = dataPagedBytes.getDataInput();
  indexToDataOffset = indexToTerms.getMutable();

  long ramBytesUsed = RamUsageEstimator.shallowSizeOf(fields);
  ramBytesUsed += RamUsageEstimator.shallowSizeOf(dataInput);
  ramBytesUsed += fields.length * RamUsageEstimator.shallowSizeOfInstance(Term.class);
  ramBytesUsed += dataPagedBytes.ramBytesUsed();
  ramBytesUsed += indexToDataOffset.ramBytesUsed();
  this.ramBytesUsed = ramBytesUsed;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:70,代码来源:TermInfosReaderIndex.java

示例2: TermInfosReaderIndex

import org.apache.lucene.util.PagedBytes.PagedBytesDataOutput; //导入方法依赖的package包/类
/**
 * Loads the segment information at segment load time.
 * 
 * @param indexEnum
 *          the term enum.
 * @param indexDivisor
 *          the index divisor.
 * @param tiiFileLength
 *          the size of the tii file, used to approximate the size of the
 *          buffer.
 * @param totalIndexInterval
 *          the total index interval.
 */
TermInfosReaderIndex(SegmentTermEnum indexEnum, int indexDivisor, long tiiFileLength, int totalIndexInterval) throws IOException {
  this.totalIndexInterval = totalIndexInterval;
  indexSize = 1 + ((int) indexEnum.size - 1) / indexDivisor;
  skipInterval = indexEnum.skipInterval;
  // this is only an inital size, it will be GCed once the build is complete
  long initialSize = (long) (tiiFileLength * 1.5) / indexDivisor;
  PagedBytes dataPagedBytes = new PagedBytes(estimatePageBits(initialSize));
  PagedBytesDataOutput dataOutput = dataPagedBytes.getDataOutput();

  final int bitEstimate = 1+MathUtil.log(tiiFileLength, 2);
  GrowableWriter indexToTerms = new GrowableWriter(bitEstimate, indexSize, PackedInts.DEFAULT);

  String currentField = null;
  List<String> fieldStrs = new ArrayList<String>();
  int fieldCounter = -1;
  for (int i = 0; indexEnum.next(); i++) {
    Term term = indexEnum.term();
    if (currentField == null || !currentField.equals(term.field())) {
      currentField = term.field();
      fieldStrs.add(currentField);
      fieldCounter++;
    }
    TermInfo termInfo = indexEnum.termInfo();
    indexToTerms.set(i, dataOutput.getPosition());
    dataOutput.writeVInt(fieldCounter);
    dataOutput.writeString(term.text());
    dataOutput.writeVInt(termInfo.docFreq);
    if (termInfo.docFreq >= skipInterval) {
      dataOutput.writeVInt(termInfo.skipOffset);
    }
    dataOutput.writeVLong(termInfo.freqPointer);
    dataOutput.writeVLong(termInfo.proxPointer);
    dataOutput.writeVLong(indexEnum.indexPointer);
    for (int j = 1; j < indexDivisor; j++) {
      if (!indexEnum.next()) {
        break;
      }
    }
  }

  fields = new Term[fieldStrs.size()];
  for (int i = 0; i < fields.length; i++) {
    fields[i] = new Term(fieldStrs.get(i));
  }
  
  dataPagedBytes.freeze(true);
  dataInput = dataPagedBytes.getDataInput();
  indexToDataOffset = indexToTerms.getMutable();
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:63,代码来源:TermInfosReaderIndex.java

示例3: TermInfosReaderIndex

import org.apache.lucene.util.PagedBytes.PagedBytesDataOutput; //导入方法依赖的package包/类
/**
 * Loads the segment information at segment load time.
 * 
 * @param indexEnum
 *          the term enum.
 * @param indexDivisor
 *          the index divisor.
 * @param tiiFileLength
 *          the size of the tii file, used to approximate the size of the
 *          buffer.
 * @param totalIndexInterval
 *          the total index interval.
 */
TermInfosReaderIndex(SegmentTermEnum indexEnum, int indexDivisor, long tiiFileLength, int totalIndexInterval) throws IOException {
  this.totalIndexInterval = totalIndexInterval;
  indexSize = 1 + ((int) indexEnum.size - 1) / indexDivisor;
  skipInterval = indexEnum.skipInterval;
  // this is only an inital size, it will be GCed once the build is complete
  long initialSize = (long) (tiiFileLength * 1.5) / indexDivisor;
  PagedBytes dataPagedBytes = new PagedBytes(estimatePageBits(initialSize));
  PagedBytesDataOutput dataOutput = dataPagedBytes.getDataOutput();

  final int bitEstimate = 1+MathUtil.log(tiiFileLength, 2);
  GrowableWriter indexToTerms = new GrowableWriter(bitEstimate, indexSize, PackedInts.DEFAULT);

  String currentField = null;
  List<String> fieldStrs = new ArrayList<String>();
  int fieldCounter = -1;
  for (int i = 0; indexEnum.next(); i++) {
    Term term = indexEnum.term();
    if (currentField == null || !currentField.equals(term.field())) {
      currentField = term.field();
      fieldStrs.add(currentField);
      fieldCounter++;
    }
    TermInfo termInfo = indexEnum.termInfo();
    indexToTerms.set(i, dataOutput.getPosition());
    dataOutput.writeVInt(fieldCounter);
    dataOutput.writeString(term.text());
    dataOutput.writeVInt(termInfo.docFreq);
    if (termInfo.docFreq >= skipInterval) {
      dataOutput.writeVInt(termInfo.skipOffset);
    }
    dataOutput.writeVLong(termInfo.freqPointer);
    dataOutput.writeVLong(termInfo.proxPointer);
    dataOutput.writeVLong(indexEnum.indexPointer);
    for (int j = 1; j < indexDivisor; j++) {
      if (!indexEnum.next()) {
        break;
      }
    }
  }

  fields = new Term[fieldStrs.size()];
  for (int i = 0; i < fields.length; i++) {
    fields[i] = new Term(fieldStrs.get(i));
  }
  
  dataPagedBytes.freeze(true);
  dataInput = dataPagedBytes.getDataInput();
  indexToDataOffset = indexToTerms.getMutable();

  ramBytesUsed = fields.length * (RamUsageEstimator.NUM_BYTES_OBJECT_REF + RamUsageEstimator.shallowSizeOfInstance(Term.class))
      + dataPagedBytes.ramBytesUsed() + indexToDataOffset.ramBytesUsed();
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:66,代码来源:TermInfosReaderIndex.java


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