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


Java DataOutput.writeByte方法代码示例

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


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

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

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

示例5: encodeLen

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
private static void encodeLen(int l, DataOutput out) throws IOException {
  while (l >= 0xFF) {
    out.writeByte((byte) 0xFF);
    l -= 0xFF;
  }
  out.writeByte((byte) l);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:LZ4.java

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

示例7: writeVLong

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
static void writeVLong(DataOutput out, long i) throws IOException {
  int k = 0;
  while ((i & ~0x7FL) != 0L && k++ < 8) {
    out.writeByte((byte)((i & 0x7FL) | 0x80L));
    i >>>= 7;
  }
  out.writeByte((byte) i);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:AbstractBlockPackedWriter.java

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

示例9: write

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
public static void write(DataOutput out, BytesRef b) throws IOException {
  for(int i=0;i<b.length;i++) {
    final byte bx = b.bytes[b.offset+i];
    if (bx == NEWLINE || bx == ESCAPE) {
      out.writeByte(ESCAPE);
    }
    out.writeByte(bx);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:SimpleTextUtil.java

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

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

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

示例13: writeNewline

import org.apache.lucene.store.DataOutput; //导入方法依赖的package包/类
public static void writeNewline(DataOutput out) throws IOException {
  out.writeByte(NEWLINE);
}
 
开发者ID:europeana,项目名称:search,代码行数:4,代码来源:SimpleTextUtil.java


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