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


Java PackedInts.Mutable方法代码示例

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


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

示例1: save

import org.apache.lucene.util.packed.PackedInts; //导入方法依赖的package包/类
public void save(DataOutput out) throws IOException {
  if (startNode == -1) {
    throw new IllegalStateException("call finish first");
  }
  if (nodeAddress != null) {
    throw new IllegalStateException("cannot save an FST pre-packed FST; it must first be packed");
  }
  if (packed && !(nodeRefToAddress instanceof PackedInts.Mutable)) {
    throw new IllegalStateException("cannot save a FST which has been loaded from disk ");
  }
  CodecUtil.writeHeader(out, FILE_FORMAT_NAME, VERSION_CURRENT);
  if (packed) {
    out.writeByte((byte) 1);
  } else {
    out.writeByte((byte) 0);
  }
  // TODO: really we should encode this as an arc, arriving
  // to the root node, instead of special casing here:
  if (emptyOutput != null) {
    // Accepts empty string
    out.writeByte((byte) 1);

    // Serialize empty-string output:
    RAMOutputStream ros = new RAMOutputStream();
    outputs.writeFinalOutput(emptyOutput, ros);
    
    byte[] emptyOutputBytes = new byte[(int) ros.getFilePointer()];
    ros.writeTo(emptyOutputBytes, 0);

    if (!packed) {
      // reverse
      final int stopAt = emptyOutputBytes.length/2;
      int upto = 0;
      while(upto < stopAt) {
        final byte b = emptyOutputBytes[upto];
        emptyOutputBytes[upto] = emptyOutputBytes[emptyOutputBytes.length-upto-1];
        emptyOutputBytes[emptyOutputBytes.length-upto-1] = b;
        upto++;
      }
    }
    out.writeVInt(emptyOutputBytes.length);
    out.writeBytes(emptyOutputBytes, 0, emptyOutputBytes.length);
  } else {
    out.writeByte((byte) 0);
  }
  final byte t;
  if (inputType == INPUT_TYPE.BYTE1) {
    t = 0;
  } else if (inputType == INPUT_TYPE.BYTE2) {
    t = 1;
  } else {
    t = 2;
  }
  out.writeByte(t);
  if (packed) {
    ((PackedInts.Mutable) nodeRefToAddress).save(out);
  }
  out.writeVLong(startNode);
  out.writeVLong(nodeCount);
  out.writeVLong(arcCount);
  out.writeVLong(arcWithOutputCount);
  long numBytes = bytes.getPosition();
  out.writeVLong(numBytes);
  bytes.writeTo(out);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:66,代码来源:FST.java


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