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


Java DataOutput类代码示例

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


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

import org.apache.lucene.store.DataOutput; //导入依赖的package包/类
private static void encodeSequence(byte[] bytes, int anchor, int matchRef, int matchOff, int matchLen, DataOutput out) throws IOException {
  final int literalLen = matchOff - anchor;
  assert matchLen >= 4;
  // encode token
  final int token = (Math.min(literalLen, 0x0F) << 4) | Math.min(matchLen - 4, 0x0F);
  encodeLiterals(bytes, token, anchor, literalLen, out);

  // encode match dec
  final int matchDec = matchOff - matchRef;
  assert matchDec > 0 && matchDec < 1 << 16;
  out.writeByte((byte) matchDec);
  out.writeByte((byte) (matchDec >>> 8));

  // encode match len
  if (matchLen >= MIN_MATCH + 0x0F) {
    encodeLen(matchLen - 0x0F - MIN_MATCH, out);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:LZ4.java

示例4: ForUtil

import org.apache.lucene.store.DataOutput; //导入依赖的package包/类
/**
 * Create a new {@link ForUtil} instance and save state into <code>out</code>.
 */
ForUtil(float acceptableOverheadRatio, DataOutput out) throws IOException {
  out.writeVInt(PackedInts.VERSION_CURRENT);
  encodedSizes = new int[33];
  encoders = new PackedInts.Encoder[33];
  decoders = new PackedInts.Decoder[33];
  iterations = new int[33];

  for (int bpv = 1; bpv <= 32; ++bpv) {
    final FormatAndBits formatAndBits = PackedInts.fastestFormatAndBits(
        BLOCK_SIZE, bpv, acceptableOverheadRatio);
    assert formatAndBits.format.isSupported(formatAndBits.bitsPerValue);
    assert formatAndBits.bitsPerValue <= 32;
    encodedSizes[bpv] = encodedSize(formatAndBits.format, PackedInts.VERSION_CURRENT, formatAndBits.bitsPerValue);
    encoders[bpv] = PackedInts.getEncoder(
        formatAndBits.format, PackedInts.VERSION_CURRENT, formatAndBits.bitsPerValue);
    decoders[bpv] = PackedInts.getDecoder(
        formatAndBits.format, PackedInts.VERSION_CURRENT, formatAndBits.bitsPerValue);
    iterations[bpv] = computeIterations(decoders[bpv]);

    out.writeVInt(formatAndBits.format.getId() << 5 | (formatAndBits.bitsPerValue - 1));
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:ForUtil.java

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

示例6: writeTo

import org.apache.lucene.store.DataOutput; //导入依赖的package包/类
public long writeTo(DataOutput out) throws IOException {
  long size = 0;
  while(true) {
    if (limit + bufferOffset == endIndex) {
      assert endIndex - bufferOffset >= upto;
      out.writeBytes(buffer, upto, limit-upto);
      size += limit-upto;
      break;
    } else {
      out.writeBytes(buffer, upto, limit-upto);
      size += limit-upto;
      nextSlice();
    }
  }

  return size;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:ByteSliceReader.java

示例7: write

import org.apache.lucene.store.DataOutput; //导入依赖的package包/类
@Override
public void write(DataOutput indexOut, boolean absolute) throws IOException {
  assert upto >= 0;
  if (absolute) {
    indexOut.writeVInt(upto);
    indexOut.writeVLong(fp);
  } else if (fp == lastFP) {
    // same block
    assert upto >= lastUpto;
    int uptoDelta = upto - lastUpto;
    indexOut.writeVInt(uptoDelta << 1 | 1);
  } else {      
    // new block
    indexOut.writeVInt(upto << 1);
    indexOut.writeVLong(fp - lastFP);
  }
  lastUpto = upto;
  lastFP = fp;
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:VariableIntBlockIndexOutput.java

示例8: write

import org.apache.lucene.store.DataOutput; //导入依赖的package包/类
@Override
public void write(DataOutput indexOut, boolean absolute) throws IOException {
  if (absolute) {
    indexOut.writeVInt(upto);
    indexOut.writeVLong(fp);
  } else if (fp == lastFP) {
    // same block
    assert upto >= lastUpto;
    int uptoDelta = upto - lastUpto;
    indexOut.writeVInt(uptoDelta << 1 | 1);
  } else {      
    // new block
    indexOut.writeVInt(upto << 1);
    indexOut.writeVLong(fp - lastFP);
  }
  lastUpto = upto;
  lastFP = fp;
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:FixedIntBlockIndexOutput.java

示例9: encodeTerm

import org.apache.lucene.store.DataOutput; //导入依赖的package包/类
@Override
public void encodeTerm(long[] empty, DataOutput out, FieldInfo fieldInfo, BlockTermState _state, boolean absolute) throws IOException {
  PulsingTermState state = (PulsingTermState)_state;
  assert empty.length == 0;
  this.absolute = this.absolute || absolute;
  if (state.bytes == null) {
    wrappedPostingsWriter.encodeTerm(longs, buffer, fieldInfo, state.wrappedState, this.absolute);
    for (int i = 0; i < longsSize; i++) {
      out.writeVLong(longs[i]);
    }
    buffer.writeTo(out);
    buffer.reset();
    this.absolute = false;
  } else {
    out.writeVInt(state.bytes.length);
    out.writeBytes(state.bytes, 0, state.bytes.length);
    this.absolute = this.absolute || absolute;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:PulsingPostingsWriter.java

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

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

示例12: encodeTerm

import org.apache.lucene.store.DataOutput; //导入依赖的package包/类
@Override
public void encodeTerm(long[] empty, DataOutput out, FieldInfo fieldInfo, BlockTermState _state, boolean absolute) throws IOException {
  StandardTermState state = (StandardTermState)_state;
  if (absolute) {
    lastState = emptyState;
  }
  out.writeVLong(state.freqStart - lastState.freqStart);
  if (state.skipOffset != -1) {
    assert state.skipOffset > 0;
    out.writeVLong(state.skipOffset);
  }
  if (indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0) {
    out.writeVLong(state.proxStart - lastState.proxStart);
  }
  lastState = state;
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:Lucene40PostingsWriter.java

示例13: write

import org.apache.lucene.store.DataOutput; //导入依赖的package包/类
private void write(DataOutput out) throws IOException {
    out.writeLong(offset);
    out.writeInt(numOps);
    out.writeLong(generation);
    out.writeLong(minSeqNo);
    out.writeLong(maxSeqNo);
    out.writeLong(globalCheckpoint);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:Checkpoint.java

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

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


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