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


Java DataOutput.writeString方法代码示例

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


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

示例1: writeRecursively

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
private void writeRecursively(DataOutput out, TSTNode node) throws IOException {
  if (node == null) {
    return;
  }
  out.writeString(new String(new char[] {node.splitchar}, 0, 1));
  byte mask = 0;
  if (node.relatives[TSTNode.LOKID] != null) mask |= LO_KID;
  if (node.relatives[TSTNode.EQKID] != null) mask |= EQ_KID;
  if (node.relatives[TSTNode.HIKID] != null) mask |= HI_KID;
  if (node.data != null) mask |= HAS_VALUE;
  out.writeByte(mask);
  if (node.data != null) {
    out.writeLong(((Number)node.data).longValue());
  }
  writeRecursively(out, node.relatives[TSTNode.LOKID]);
  writeRecursively(out, node.relatives[TSTNode.EQKID]);
  writeRecursively(out, node.relatives[TSTNode.HIKID]);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:JaspellLookup.java

示例2: writeRecursively

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
private void writeRecursively(DataOutput out, TernaryTreeNode node) throws IOException {
  // write out the current node
  out.writeString(new String(new char[] {node.splitchar}, 0, 1));
  // prepare a mask of kids
  byte mask = 0;
  if (node.eqKid != null) mask |= EQ_KID;
  if (node.loKid != null) mask |= LO_KID;
  if (node.hiKid != null) mask |= HI_KID;
  if (node.token != null) mask |= HAS_TOKEN;
  if (node.val != null) mask |= HAS_VALUE;
  out.writeByte(mask);
  if (node.token != null) out.writeString(node.token);
  if (node.val != null) out.writeLong(((Number)node.val).longValue());
  // recurse and write kids
  if (node.loKid != null) {
    writeRecursively(out, node.loKid);
  }
  if (node.eqKid != null) {
    writeRecursively(out, node.eqKid);
  }
  if (node.hiKid != null) {
    writeRecursively(out, node.hiKid);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:25,代码来源:TSTLookup.java

示例3: writeHeader

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
/**
 * Writes a codec header, which records both a string to
 * identify the file and a version number. This header can
 * be parsed and validated with 
 * {@link #checkHeader(DataInput, String, int, int) checkHeader()}.
 * <p>
 * CodecHeader --&gt; Magic,CodecName,Version
 * <ul>
 *    <li>Magic --&gt; {@link DataOutput#writeInt Uint32}. This
 *        identifies the start of the header. It is always {@value #CODEC_MAGIC}.
 *    <li>CodecName --&gt; {@link DataOutput#writeString String}. This
 *        is a string to identify this file.
 *    <li>Version --&gt; {@link DataOutput#writeInt Uint32}. Records
 *        the version of the file.
 * </ul>
 * <p>
 * Note that the length of a codec header depends only upon the
 * name of the codec, so this length can be computed at any time
 * with {@link #headerLength(String)}.
 * 
 * @param out Output stream
 * @param codec String to identify this file. It should be simple ASCII, 
 *              less than 128 characters in length.
 * @param version Version number
 * @throws IOException If there is an I/O error writing to the underlying medium.
 */
public static void writeHeader(DataOutput out, String codec, int version)
  throws IOException {
  BytesRef bytes = new BytesRef(codec);
  if (bytes.length != codec.length() || bytes.length >= 128) {
    throw new IllegalArgumentException("codec must be simple ASCII, less than 128 characters in length [got " + codec + "]");
  }
  out.writeInt(CODEC_MAGIC);
  out.writeString(codec);
  out.writeInt(version);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:CodecUtil.java


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