當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。