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


Java DataOutput.writeBytes方法代码示例

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


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

示例1: write

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
public void write(String baseDir) throws IOException {
  String filename = baseDir + File.separator +
    CharacterDefinition.class.getName().replace('.', File.separatorChar) + CharacterDefinition.FILENAME_SUFFIX;
  new File(filename).getParentFile().mkdirs();
  OutputStream os = new FileOutputStream(filename);
  try {
    os = new BufferedOutputStream(os);
    final DataOutput out = new OutputStreamDataOutput(os);
    CodecUtil.writeHeader(out, CharacterDefinition.HEADER, CharacterDefinition.VERSION);
    out.writeBytes(characterCategoryMap, 0, characterCategoryMap.length);
    for (int i = 0; i < CharacterDefinition.CLASS_COUNT; i++) {
      final byte b = (byte) (
        (invokeMap[i] ? 0x01 : 0x00) | 
        (groupMap[i] ? 0x02 : 0x00)
      );
      out.writeByte(b);
    }
  } finally {
    os.close();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:CharacterDefinitionWriter.java

示例2: encodeLiterals

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
private static void encodeLiterals(byte[] bytes, int token, int anchor, int literalLen, DataOutput out) throws IOException {
  out.writeByte((byte) token);

  // encode literal length
  if (literalLen >= 0x0F) {
    encodeLen(literalLen - 0x0F, out);
  }

  // encode literals
  out.writeBytes(bytes, anchor, literalLen);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:LZ4.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: writeTo

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
/** Writes all of our bytes to the target {@link DataOutput}. */
public void writeTo(DataOutput out) throws IOException {
  for(byte[] block : blocks) {
    out.writeBytes(block, 0, block.length);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:BytesStore.java

示例6: 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

示例7: writeBytes

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
@Override
public void writeBytes(DataOutput out, int offset, int length) throws IOException {
  out.writeBytes(_bytes, offset, length);
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:5,代码来源:ByteArrayPrimitive.java


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