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


Java IndexOutput.writeLong方法代码示例

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


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

示例1: writeSegmentsGen

import org.apache.lucene.store.IndexOutput; //导入方法依赖的package包/类
/**
 * A utility for writing the {@link IndexFileNames#SEGMENTS_GEN} file to a
 * {@link Directory}.
 * 
 * <p>
 * <b>NOTE:</b> this is an internal utility which is kept public so that it's
 * accessible by code from other packages. You should avoid calling this
 * method unless you're absolutely sure what you're doing!
 * 
 * @lucene.internal
 */
public static void writeSegmentsGen(Directory dir, long generation) {
  try {
    IndexOutput genOutput = dir.createOutput(IndexFileNames.SEGMENTS_GEN, IOContext.READONCE);
    try {
      genOutput.writeInt(FORMAT_SEGMENTS_GEN_CURRENT);
      genOutput.writeLong(generation);
      genOutput.writeLong(generation);
      CodecUtil.writeFooter(genOutput);
    } finally {
      genOutput.close();
      dir.sync(Collections.singleton(IndexFileNames.SEGMENTS_GEN));
    }
  } catch (Throwable t) {
    // It's OK if we fail to write this file since it's
    // used only as one of the retry fallbacks.
    IOUtils.deleteFilesIgnoringExceptions(dir, IndexFileNames.SEGMENTS_GEN);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:SegmentInfos.java

示例2: writeToLuceneStream

import org.apache.lucene.store.IndexOutput; //导入方法依赖的package包/类
@Override
/**
 * Writes vector out to object output stream.  Converts to dense format if necessary.
 */
public void writeToLuceneStream(IndexOutput outputStream) {
  if (isSparse) {
    elementalToSemantic();
  }
  long[] bitArray = bitSet.getBits();

  for (int i = 0; i < bitArray.length; i++) {
    try {
      outputStream.writeLong(bitArray[i]);
    } catch (IOException e) {
      logger.severe("Couldn't write binary vector to lucene output stream.");
      e.printStackTrace();
    }
  }
}
 
开发者ID:semanticvectors,项目名称:semanticvectors,代码行数:20,代码来源:BinaryVector.java

示例3: insertData

import org.apache.lucene.store.IndexOutput; //导入方法依赖的package包/类
private void insertData() throws IOException {
    final byte[] test = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
    final IndexOutput indexOutput = jdbcDirectory.createOutput("value1", new IOContext());
    indexOutput.writeInt(-1);
    indexOutput.writeLong(10);
    indexOutput.writeInt(0);
    indexOutput.writeInt(0);
    indexOutput.writeBytes(test, 8);
    indexOutput.writeBytes(test, 5);
    indexOutput.writeByte((byte) 8);
    indexOutput.writeBytes(new byte[] { 1, 2 }, 2);
    indexOutput.close();
}
 
开发者ID:unkascrack,项目名称:lucene-jdbcdirectory,代码行数:14,代码来源:AbstractIndexInputOutputITest.java

示例4: writeTrailer

import org.apache.lucene.store.IndexOutput; //导入方法依赖的package包/类
/** Writes the terms file trailer. */
private void writeTrailer(IndexOutput out, long dirStart) throws IOException {
  out.writeLong(dirStart);    
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:BlockTreeTermsWriter.java

示例5: writeIndexTrailer

import org.apache.lucene.store.IndexOutput; //导入方法依赖的package包/类
/** Writes the index file trailer. */
private void writeIndexTrailer(IndexOutput indexOut, long dirStart) throws IOException {
  indexOut.writeLong(dirStart);    
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:BlockTreeTermsWriter.java

示例6: writeTrailer

import org.apache.lucene.store.IndexOutput; //导入方法依赖的package包/类
private void writeTrailer(IndexOutput out, long dirStart) throws IOException {
  out.writeLong(dirStart);
}
 
开发者ID:europeana,项目名称:search,代码行数:4,代码来源:FSTTermsWriter.java

示例7: testEndPointer

import org.apache.lucene.store.IndexOutput; //导入方法依赖的package包/类
public void testEndPointer() throws IOException {
  final Directory dir = newDirectory();
  final int valueCount = RandomInts.randomIntBetween(random(), 1, 1000);
  final IndexOutput out = dir.createOutput("tests.bin", newIOContext(random()));
  for (int i = 0; i < valueCount; ++i) {
    out.writeLong(0);
  }
  out.close();
  final IndexInput in = dir.openInput("tests.bin", newIOContext(random()));
  for (int version = PackedInts.VERSION_START; version <= PackedInts.VERSION_CURRENT; ++version) {
    for (int bpv = 1; bpv <= 64; ++bpv) {
      for (PackedInts.Format format : PackedInts.Format.values()) {
        if (!format.isSupported(bpv)) {
          continue;
        }
        final long byteCount = format.byteCount(version, valueCount, bpv);
        String msg = "format=" + format + ",version=" + version + ",valueCount=" + valueCount + ",bpv=" + bpv;

        // test iterator
        in.seek(0L);
        final PackedInts.ReaderIterator it = PackedInts.getReaderIteratorNoHeader(in, format, version, valueCount, bpv, RandomInts.randomIntBetween(random(), 1, 1<<16));
        for (int i = 0; i < valueCount; ++i) {
          it.next();
        }
        assertEquals(msg, byteCount, in.getFilePointer());

        // test direct reader
        in.seek(0L);
        final PackedInts.Reader directReader = PackedInts.getDirectReaderNoHeader(in, format, version, valueCount, bpv);
        directReader.get(valueCount - 1);
        assertEquals(msg, byteCount, in.getFilePointer());

        // test reader
        in.seek(0L);
        PackedInts.getReaderNoHeader(in, format, version, valueCount, bpv);
        assertEquals(msg, byteCount, in.getFilePointer());
       }
    }
  }
  in.close();
  dir.close();
}
 
开发者ID:europeana,项目名称:search,代码行数:43,代码来源:TestPackedInts.java

示例8: writeFooter

import org.apache.lucene.store.IndexOutput; //导入方法依赖的package包/类
/**
 * Writes a codec footer, which records both a checksum
 * algorithm ID and a checksum. This footer can
 * be parsed and validated with 
 * {@link #checkFooter(ChecksumIndexInput) checkFooter()}.
 * <p>
 * CodecFooter --&gt; Magic,AlgorithmID,Checksum
 * <ul>
 *    <li>Magic --&gt; {@link DataOutput#writeInt Uint32}. This
 *        identifies the start of the footer. It is always {@value #FOOTER_MAGIC}.
 *    <li>AlgorithmID --&gt; {@link DataOutput#writeInt Uint32}. This
 *        indicates the checksum algorithm used. Currently this is always 0,
 *        for zlib-crc32.
 *    <li>Checksum --&gt; {@link DataOutput#writeLong Uint64}. The
 *        actual checksum value for all previous bytes in the stream, including
 *        the bytes from Magic and AlgorithmID.
 * </ul>
 * 
 * @param out Output stream
 * @throws IOException If there is an I/O error writing to the underlying medium.
 */
public static void writeFooter(IndexOutput out) throws IOException {
  out.writeInt(FOOTER_MAGIC);
  out.writeInt(0);
  out.writeLong(out.getChecksum());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:CodecUtil.java


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