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


Java DataOutput.writeVInt方法代码示例

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


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

示例1: store

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
@Override
public boolean store(OutputStream output) throws IOException {
  DataOutput dataOut = new OutputStreamDataOutput(output);
  try {
    if (fst == null) {
      return false;
    }

    fst.save(dataOut);
    dataOut.writeVInt(maxAnalyzedPathsForOneInput);
    dataOut.writeByte((byte) (hasPayloads ? 1 : 0));
  } finally {
    IOUtils.close(output);
  }
  return true;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:XAnalyzingSuggester.java

示例2: encodeTerm

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
@Override
public void encodeTerm(long[] longs, DataOutput out, FieldInfo fieldInfo, BlockTermState _state, boolean absolute) throws IOException {
  IntBlockTermState state = (IntBlockTermState)_state;
  if (absolute) {
    lastState = emptyState;
  }
  longs[0] = state.docStartFP - lastState.docStartFP;
  if (fieldHasPositions) {
    longs[1] = state.posStartFP - lastState.posStartFP;
    if (fieldHasPayloads || fieldHasOffsets) {
      longs[2] = state.payStartFP - lastState.payStartFP;
    }
  }
  if (state.singletonDocID != -1) {
    out.writeVInt(state.singletonDocID);
  }
  if (fieldHasPositions) {
    if (state.lastPosBlockOffset != -1) {
      out.writeVLong(state.lastPosBlockOffset);
    }
  }
  if (state.skipOffset != -1) {
    out.writeVLong(state.skipOffset);
  }
  lastState = state;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:Lucene41PostingsWriter.java

示例3: write

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
@Override
public void write(TermData data, DataOutput out) throws IOException {
  int bit0 = allZero(data.longs) ? 0 : 1;
  int bit1 = ((data.bytes == null || data.bytes.length == 0) ? 0 : 1) << 1;
  int bit2 = ((data.docFreq == 0)  ? 0 : 1) << 2;
  int bits = bit0 | bit1 | bit2;
  if (bit1 > 0) {  // determine extra length
    if (data.bytes.length < 32) {
      bits |= (data.bytes.length << 3);
      out.writeByte((byte)bits);
    } else {
      out.writeByte((byte)bits);
      out.writeVInt(data.bytes.length);
    }
  } else {
    out.writeByte((byte)bits);
  }
  if (bit0 > 0) {  // not all-zero case
    for (int pos = 0; pos < longsSize; pos++) {
      out.writeVLong(data.longs[pos]);
    }
  }
  if (bit1 > 0) {  // bytes exists
    out.writeBytes(data.bytes, 0, data.bytes.length);
  }
  if (bit2 > 0) {  // stats exist
    if (hasPos) {
      if (data.docFreq == data.totalTermFreq) {
        out.writeVInt((data.docFreq << 1) | 1);
      } else {
        out.writeVInt((data.docFreq << 1));
        out.writeVLong(data.totalTermFreq - data.docFreq);
      }
    } else {
      out.writeVInt(data.docFreq);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:39,代码来源:FSTTermOutputs.java

示例4: write

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
@Override
public void write(Output prefix, DataOutput out) throws IOException {
  out.writeVInt(prefix.bytes.length);
  out.writeBytes(prefix.bytes.bytes, prefix.bytes.offset, prefix.bytes.length);
  out.writeVLong(prefix.startOrd);
  out.writeVLong(prefix.endOrd);
}
 
开发者ID:europeana,项目名称:search,代码行数:8,代码来源:FSTOrdsOutputs.java

示例5: store

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
@Override
public boolean store(DataOutput output) throws IOException {
  CodecUtil.writeHeader(output, CODEC_NAME, VERSION_CURRENT);
  output.writeVLong(count);
  output.writeByte(separator);
  output.writeVInt(grams);
  output.writeVLong(totTokens);
  fst.save(output);
  return true;
}
 
开发者ID:europeana,项目名称:search,代码行数:11,代码来源:FreeTextSuggester.java

示例6: store

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
@Override
public boolean store(DataOutput output) throws IOException {
  output.writeVLong(count);
  if (fst == null) {
    return false;
  }

  fst.save(output);
  output.writeVInt(maxAnalyzedPathsForOneInput);
  output.writeByte((byte) (hasPayloads ? 1 : 0));
  return true;
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:AnalyzingSuggester.java

示例7: writeFinalOutput

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
@Override
public void writeFinalOutput(Object output, DataOutput out) throws IOException {
  if (!(output instanceof List)) {
    out.writeVInt(1);
    outputs.write((T) output, out);
  } else {
    List<T> outputList = (List<T>) output;
    out.writeVInt(outputList.size());
    for(T eachOutput : outputList) {
      outputs.write(eachOutput, out);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:ListOfOutputs.java

示例8: encodeTerm

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
@Override
public void encodeTerm(long[] longs, DataOutput out, FieldInfo fieldInfo, BlockTermState _state, boolean absolute) throws IOException {
  IDVersionTermState state = (IDVersionTermState) _state;
  out.writeVInt(state.docID);
  if (absolute) {
    out.writeVLong(state.idVersion);
  } else {
    long delta = state.idVersion - lastEncodedVersion;
    out.writeZLong(delta);
  }
  lastEncodedVersion = state.idVersion;
}
 
开发者ID:europeana,项目名称:search,代码行数:13,代码来源:IDVersionPostingsWriter.java

示例9: store

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
@Override
public boolean store(OutputStream output) throws IOException {
  DataOutput dataOut = new OutputStreamDataOutput(output);
  try {
    if (fst == null) {
      return false;
    }

    fst.save(dataOut);
    dataOut.writeVInt(maxAnalyzedPathsForOneInput);
  } finally {
    IOUtils.close(output);
  }
  return true;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:16,代码来源:AnalyzingSuggester.java

示例10: save

import org.apache.lucene.store.DataOutput; //导入方法依赖的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.store.DataOutput.writeVInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。