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


Java RAMOutputStream类代码示例

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


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

示例1: flushTermsDictBlock

import org.apache.lucene.store.RAMOutputStream; //导入依赖的package包/类
private void flushTermsDictBlock(RAMOutputStream headerBuffer, RAMOutputStream bytesBuffer, int suffixDeltas[]) throws IOException {
  boolean twoByte = false;
  for (int i = 1; i < suffixDeltas.length; i++) {
    if (suffixDeltas[i] > 254) {
      twoByte = true;
    }
  }
  if (twoByte) {
    headerBuffer.writeByte((byte)255);
    for (int i = 1; i < suffixDeltas.length; i++) {
      headerBuffer.writeShort((short) suffixDeltas[i]);
    }
  } else {
    for (int i = 1; i < suffixDeltas.length; i++) {
      headerBuffer.writeByte((byte) suffixDeltas[i]);
    }
  }
  headerBuffer.writeTo(data);
  headerBuffer.reset();
  bytesBuffer.writeTo(data);
  bytesBuffer.reset();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:Lucene410DocValuesConsumer.java

示例2: buildScrollId

import org.apache.lucene.store.RAMOutputStream; //导入依赖的package包/类
static String buildScrollId(AtomicArray<? extends SearchPhaseResult> searchPhaseResults) throws IOException {
    try (RAMOutputStream out = new RAMOutputStream()) {
        out.writeString(searchPhaseResults.length() == 1 ? ParsedScrollId.QUERY_AND_FETCH_TYPE : ParsedScrollId.QUERY_THEN_FETCH_TYPE);
        out.writeVInt(searchPhaseResults.asList().size());
        for (AtomicArray.Entry<? extends SearchPhaseResult> entry : searchPhaseResults.asList()) {
            SearchPhaseResult searchPhaseResult = entry.value;
            out.writeLong(searchPhaseResult.id());
            out.writeString(searchPhaseResult.shardTarget().getNodeId());
        }
        byte[] bytes = new byte[(int) out.getFilePointer()];
        out.writeTo(bytes, 0);
        return Base64.getUrlEncoder().encodeToString(bytes);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:TransportSearchHelper.java

示例3: init

import org.apache.lucene.store.RAMOutputStream; //导入依赖的package包/类
/** Allocates internal skip buffers. */
protected void init() {
  skipBuffer = new RAMOutputStream[numberOfSkipLevels];
  for (int i = 0; i < numberOfSkipLevels; i++) {
    skipBuffer[i] = new RAMOutputStream();
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:MultiLevelSkipListWriter.java

示例4: compileIndex

import org.apache.lucene.store.RAMOutputStream; //导入依赖的package包/类
public void compileIndex(List<PendingBlock> blocks, RAMOutputStream scratchBytes, IntsRefBuilder scratchIntsRef) throws IOException {

      assert (isFloor && blocks.size() > 1) || (isFloor == false && blocks.size() == 1): "isFloor=" + isFloor + " blocks=" + blocks;
      assert this == blocks.get(0);

      assert scratchBytes.getFilePointer() == 0;

      // TODO: try writing the leading vLong in MSB order
      // (opposite of what Lucene does today), for better
      // outputs sharing in the FST
      scratchBytes.writeVLong(encodeOutput(fp, hasTerms, isFloor));
      if (isFloor) {
        scratchBytes.writeVInt(blocks.size()-1);
        for (int i=1;i<blocks.size();i++) {
          PendingBlock sub = blocks.get(i);
          assert sub.floorLeadByte != -1;
          //if (DEBUG) {
          //  System.out.println("    write floorLeadByte=" + Integer.toHexString(sub.floorLeadByte&0xff));
          //}
          scratchBytes.writeByte((byte) sub.floorLeadByte);
          assert sub.fp > fp;
          scratchBytes.writeVLong((sub.fp - fp) << 1 | (sub.hasTerms ? 1 : 0));
        }
      }

      final ByteSequenceOutputs outputs = ByteSequenceOutputs.getSingleton();
      final Builder<BytesRef> indexBuilder = new Builder<>(FST.INPUT_TYPE.BYTE1,
                                                           0, 0, true, false, Integer.MAX_VALUE,
                                                           outputs, false,
                                                           PackedInts.COMPACT, true, 15);
      //if (DEBUG) {
      //  System.out.println("  compile index for prefix=" + prefix);
      //}
      //indexBuilder.DEBUG = false;
      final byte[] bytes = new byte[(int) scratchBytes.getFilePointer()];
      assert bytes.length > 0;
      scratchBytes.writeTo(bytes, 0);
      indexBuilder.add(Util.toIntsRef(prefix, scratchIntsRef), new BytesRef(bytes, 0, bytes.length));
      scratchBytes.reset();

      // Copy over index for all sub-blocks
      for(PendingBlock block : blocks) {
        if (block.subIndices != null) {
          for(FST<BytesRef> subIndex : block.subIndices) {
            append(indexBuilder, subIndex, scratchIntsRef);
          }
          block.subIndices = null;
        }
      }

      index = indexBuilder.finish();

      assert subIndices == null;

      /*
      Writer w = new OutputStreamWriter(new FileOutputStream("out.dot"));
      Util.toDot(index, w, false, false);
      System.out.println("SAVED to out.dot");
      w.close();
      */
    }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:62,代码来源:BlockTreeTermsWriter.java

示例5: save

import org.apache.lucene.store.RAMOutputStream; //导入依赖的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

示例6: compileIndex

import org.apache.lucene.store.RAMOutputStream; //导入依赖的package包/类
public void compileIndex(List<PendingBlock> blocks, RAMOutputStream scratchBytes, IntsRefBuilder scratchIntsRef) throws IOException {

      assert (isFloor && blocks.size() > 1) || (isFloor == false && blocks.size() == 1): "isFloor=" + isFloor + " blocks=" + blocks;
      assert this == blocks.get(0);

      assert scratchBytes.getFilePointer() == 0;

      // TODO: try writing the leading vLong in MSB order
      // (opposite of what Lucene does today), for better
      // outputs sharing in the FST
      long lastSumTotalTermCount = 0;
      long sumTotalTermCount = totalTermCount;
      scratchBytes.writeVLong(encodeOutput(fp, hasTerms, isFloor));
      if (isFloor) {
        scratchBytes.writeVInt(blocks.size()-1);
        for (int i=1;i<blocks.size();i++) {
          PendingBlock sub = blocks.get(i);
          assert sub.floorLeadByte != -1;
          //if (DEBUG) {
          //  System.out.println("    write floorLeadByte=" + Integer.toHexString(sub.floorLeadByte&0xff));
          //}
          scratchBytes.writeByte((byte) sub.floorLeadByte);
          // System.out.println("  write floor byte=" + (byte) sub.floorLeadByte + " ordShift=" + sumTotalTermCount);
          scratchBytes.writeVLong(sumTotalTermCount - lastSumTotalTermCount);
          lastSumTotalTermCount = sumTotalTermCount;
          sumTotalTermCount += sub.totalTermCount;
          assert sub.fp > fp;
          scratchBytes.writeVLong((sub.fp - fp) << 1 | (sub.hasTerms ? 1 : 0));
        }
      }

      final Builder<Output> indexBuilder = new Builder<>(FST.INPUT_TYPE.BYTE1,
                                                         0, 0, true, false, Integer.MAX_VALUE,
                                                         FST_OUTPUTS, false,
                                                         PackedInts.COMPACT, true, 15);
      //if (DEBUG) {
      //  System.out.println("  compile index for prefix=" + prefix);
      //}
      //indexBuilder.DEBUG = false;
      final byte[] bytes = new byte[(int) scratchBytes.getFilePointer()];
      assert bytes.length > 0;
      // System.out.println("  bytes=" + bytes.length);
      scratchBytes.writeTo(bytes, 0);
      indexBuilder.add(Util.toIntsRef(prefix, scratchIntsRef),
                       FST_OUTPUTS.newOutput(new BytesRef(bytes, 0, bytes.length),
                                             0, Long.MAX_VALUE-(sumTotalTermCount-1)));
      scratchBytes.reset();

      // Copy over index for all sub-blocks

      long termOrdOffset = 0;
      for(PendingBlock block : blocks) {
        if (block.subIndices != null) {
          for(SubIndex subIndex : block.subIndices) {
            append(indexBuilder, subIndex.index, termOrdOffset + subIndex.termOrdStart, scratchIntsRef);
          }
          block.subIndices = null;
        }
        termOrdOffset += block.totalTermCount;
      }
      totFloorTermCount = termOrdOffset;

      assert sumTotalTermCount == totFloorTermCount;

      index = indexBuilder.finish();
      assert subIndices == null;

      /*
      Writer w = new OutputStreamWriter(new FileOutputStream("out.dot"));
      Util.toDot(index, w, false, false);
      System.out.println("SAVED to out.dot");
      w.close();
      */
    }
 
开发者ID:europeana,项目名称:search,代码行数:75,代码来源:OrdsBlockTreeTermsWriter.java

示例7: compileIndex

import org.apache.lucene.store.RAMOutputStream; //导入依赖的package包/类
public void compileIndex(List<PendingBlock> blocks, RAMOutputStream scratchBytes, IntsRefBuilder scratchIntsRef) throws IOException {

      assert (isFloor && blocks.size() > 1) || (isFloor == false && blocks.size() == 1): "isFloor=" + isFloor + " blocks=" + blocks;
      assert this == blocks.get(0);

      assert scratchBytes.getFilePointer() == 0;

      long maxVersionIndex = maxVersion;

      // TODO: try writing the leading vLong in MSB order
      // (opposite of what Lucene does today), for better
      // outputs sharing in the FST
      scratchBytes.writeVLong(encodeOutput(fp, hasTerms, isFloor));
      if (isFloor) {
        scratchBytes.writeVInt(blocks.size()-1);
        for (int i=1;i<blocks.size();i++) {
          PendingBlock sub = blocks.get(i);
          maxVersionIndex = Math.max(maxVersionIndex, sub.maxVersion);
          //if (DEBUG) {
          //  System.out.println("    write floorLeadByte=" + Integer.toHexString(sub.floorLeadByte&0xff));
          //}
          scratchBytes.writeByte((byte) sub.floorLeadByte);
          assert sub.fp > fp;
          scratchBytes.writeVLong((sub.fp - fp) << 1 | (sub.hasTerms ? 1 : 0));
        }
      }

      final Builder<Pair<BytesRef,Long>> indexBuilder = new Builder<>(FST.INPUT_TYPE.BYTE1,
                                                                      0, 0, true, false, Integer.MAX_VALUE,
                                                                      FST_OUTPUTS, false,
                                                                      PackedInts.COMPACT, true, 15);
      //if (DEBUG) {
      //  System.out.println("  compile index for prefix=" + prefix);
      //}
      //indexBuilder.DEBUG = false;
      final byte[] bytes = new byte[(int) scratchBytes.getFilePointer()];
      assert bytes.length > 0;
      scratchBytes.writeTo(bytes, 0);
      indexBuilder.add(Util.toIntsRef(prefix, scratchIntsRef), FST_OUTPUTS.newPair(new BytesRef(bytes, 0, bytes.length), Long.MAX_VALUE - maxVersionIndex));
      scratchBytes.reset();

      // Copy over index for all sub-blocks
      for(PendingBlock block : blocks) {
        if (block.subIndices != null) {
          for(FST<Pair<BytesRef,Long>> subIndex : block.subIndices) {
            append(indexBuilder, subIndex, scratchIntsRef);
          }
          block.subIndices = null;
        }
      }

      index = indexBuilder.finish();

      assert subIndices == null;

      /*
      Writer w = new OutputStreamWriter(new FileOutputStream("out.dot"));
      Util.toDot(index, w, false, false);
      System.out.println("SAVED to out.dot");
      w.close();
      */
    }
 
开发者ID:europeana,项目名称:search,代码行数:63,代码来源:VersionBlockTreeTermsWriter.java

示例8: compileIndex

import org.apache.lucene.store.RAMOutputStream; //导入依赖的package包/类
public void compileIndex(List<PendingBlock> floorBlocks, RAMOutputStream scratchBytes) throws IOException {

      assert (isFloor && floorBlocks != null && floorBlocks.size() != 0) || (!isFloor && floorBlocks == null): "isFloor=" + isFloor + " floorBlocks=" + floorBlocks;

      assert scratchBytes.getFilePointer() == 0;

      // TODO: try writing the leading vLong in MSB order
      // (opposite of what Lucene does today), for better
      // outputs sharing in the FST
      scratchBytes.writeVLong(encodeOutput(fp, hasTerms, isFloor));
      if (isFloor) {
        scratchBytes.writeVInt(floorBlocks.size());
        for (PendingBlock sub : floorBlocks) {
          assert sub.floorLeadByte != -1;
          //if (DEBUG) {
          //  System.out.println("    write floorLeadByte=" + Integer.toHexString(sub.floorLeadByte&0xff));
          //}
          scratchBytes.writeByte((byte) sub.floorLeadByte);
          assert sub.fp > fp;
          scratchBytes.writeVLong((sub.fp - fp) << 1 | (sub.hasTerms ? 1 : 0));
        }
      }

      final ByteSequenceOutputs outputs = ByteSequenceOutputs.getSingleton();
      final Builder<BytesRef> indexBuilder = new Builder<BytesRef>(FST.INPUT_TYPE.BYTE1,
                                                                   0, 0, true, false, Integer.MAX_VALUE,
                                                                   outputs, null, false,
                                                                   PackedInts.COMPACT, true, 15);
      //if (DEBUG) {
      //  System.out.println("  compile index for prefix=" + prefix);
      //}
      //indexBuilder.DEBUG = false;
      final byte[] bytes = new byte[(int) scratchBytes.getFilePointer()];
      assert bytes.length > 0;
      scratchBytes.writeTo(bytes, 0);
      indexBuilder.add(Util.toIntsRef(prefix, scratchIntsRef), new BytesRef(bytes, 0, bytes.length));
      scratchBytes.reset();

      // Copy over index for all sub-blocks

      if (subIndices != null) {
        for(FST<BytesRef> subIndex : subIndices) {
          append(indexBuilder, subIndex);
        }
      }

      if (floorBlocks != null) {
        for (PendingBlock sub : floorBlocks) {
          if (sub.subIndices != null) {
            for(FST<BytesRef> subIndex : sub.subIndices) {
              append(indexBuilder, subIndex);
            }
          }
          sub.subIndices = null;
        }
      }

      index = indexBuilder.finish();
      subIndices = null;

      /*
      Writer w = new OutputStreamWriter(new FileOutputStream("out.dot"));
      Util.toDot(index, w, false, false);
      System.out.println("SAVED to out.dot");
      w.close();
      */
    }
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:68,代码来源:BlockTreeTermsWriter.java


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