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


Java ArrayUtil类代码示例

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


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

示例1: finishTerm

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
public void finishTerm(long defaultWeight) throws IOException {
    ArrayUtil.timSort(surfaceFormsAndPayload, 0, count);
    int deduplicator = 0;
    analyzed.append((byte) 0);
    analyzed.setLength(analyzed.length() + 1);
    analyzed.grow(analyzed.length());
    for (int i = 0; i < count; i++) {
        analyzed.setByteAt(analyzed.length() - 1, (byte) deduplicator++);
        Util.toIntsRef(analyzed.get(), scratchInts);
        SurfaceFormAndPayload candiate = surfaceFormsAndPayload[i];
        long cost = candiate.weight == -1 ? encodeWeight(Math.min(Integer.MAX_VALUE, defaultWeight)) : candiate.weight;
        builder.add(scratchInts.get(), outputs.newPair(cost, candiate.payload));
    }
    seenSurfaceForms.clear();
    count = 0;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:XAnalyzingSuggester.java

示例2: resize

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
/** Change the size of this array. Content between indexes <code>0</code> and <code>min(size(), newSize)</code> will be preserved. */
@Override
public void resize(long newSize) {
    final int numPages = numPages(newSize);
    if (numPages > pages.length) {
        pages = Arrays.copyOf(pages, ArrayUtil.oversize(numPages, RamUsageEstimator.NUM_BYTES_OBJECT_REF));
    }
    for (int i = numPages - 1; i >= 0 && pages[i] == null; --i) {
        pages[i] = newBytePage(i);
    }
    for (int i = numPages; i < pages.length && pages[i] != null; ++i) {
        pages[i] = null;
        releasePage(i);
    }
    this.size = newSize;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:BigByteArray.java

示例3: resize

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
/** Change the size of this array. Content between indexes <code>0</code> and <code>min(size(), newSize)</code> will be preserved. */
@Override
public void resize(long newSize) {
    final int numPages = numPages(newSize);
    if (numPages > pages.length) {
        pages = Arrays.copyOf(pages, ArrayUtil.oversize(numPages, RamUsageEstimator.NUM_BYTES_OBJECT_REF));
    }
    for (int i = numPages - 1; i >= 0 && pages[i] == null; --i) {
        pages[i] = newObjectPage(i);
    }
    for (int i = numPages; i < pages.length && pages[i] != null; ++i) {
        pages[i] = null;
        releasePage(i);
    }
    this.size = newSize;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:BigObjectArray.java

示例4: resize

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
/** Change the size of this array. Content between indexes <code>0</code> and <code>min(size(), newSize)</code> will be preserved. */
@Override
public void resize(long newSize) {
    final int numPages = numPages(newSize);
    if (numPages > pages.length) {
        pages = Arrays.copyOf(pages, ArrayUtil.oversize(numPages, RamUsageEstimator.NUM_BYTES_OBJECT_REF));
    }
    for (int i = numPages - 1; i >= 0 && pages[i] == null; --i) {
        pages[i] = newIntPage(i);
    }
    for (int i = numPages; i < pages.length && pages[i] != null; ++i) {
        pages[i] = null;
        releasePage(i);
    }
    this.size = newSize;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:BigIntArray.java

示例5: resize

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
/** Change the size of this array. Content between indexes <code>0</code> and <code>min(size(), newSize)</code> will be preserved. */
@Override
public void resize(long newSize) {
    final int numPages = numPages(newSize);
    if (numPages > pages.length) {
        pages = Arrays.copyOf(pages, ArrayUtil.oversize(numPages, RamUsageEstimator.NUM_BYTES_OBJECT_REF));
    }
    for (int i = numPages - 1; i >= 0 && pages[i] == null; --i) {
        pages[i] = newLongPage(i);
    }
    for (int i = numPages; i < pages.length && pages[i] != null; ++i) {
        pages[i] = null;
        releasePage(i);
    }
    this.size = newSize;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:BigLongArray.java

示例6: startTerm

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
@Override
public void startTerm(BytesRef term, int freq) throws IOException {
  final int prefix = StringHelper.bytesDifference(lastTerm.get(), term);
  final int suffix = term.length - prefix;
  tvf.writeVInt(prefix);
  tvf.writeVInt(suffix);
  tvf.writeBytes(term.bytes, term.offset + prefix, suffix);
  tvf.writeVInt(freq);
  lastTerm.copyBytes(term);
  lastPosition = lastOffset = 0;
  
  if (offsets && positions) {
    // we might need to buffer if its a non-bulk merge
    offsetStartBuffer = ArrayUtil.grow(offsetStartBuffer, freq);
    offsetEndBuffer = ArrayUtil.grow(offsetEndBuffer, freq);
  }
  bufferedIndex = 0;
  bufferedFreq = freq;
  payloadData.clear();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:Lucene40TermVectorsWriter.java

示例7: startBlock

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
void startBlock(SegmentTermsEnumFrame frame, boolean isFloor) {
  totalBlockCount++;
  if (isFloor) {
    if (frame.fp == frame.fpOrig) {
      floorBlockCount++;
    }
    floorSubBlockCount++;
  } else {
    nonFloorBlockCount++;
  }

  if (blockCountByPrefixLen.length <= frame.prefix) {
    blockCountByPrefixLen = ArrayUtil.grow(blockCountByPrefixLen, 1+frame.prefix);
  }
  blockCountByPrefixLen[frame.prefix]++;
  startBlockCount++;
  totalBlockSuffixBytes += frame.suffixesReader.length();
  totalBlockStatsBytes += frame.statsReader.length();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:Stats.java

示例8: addPosition

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
void addPosition(int position, int startOffset, int length, int payloadLength) {
  if (hasPositions) {
    if (posStart + totalPositions == positionsBuf.length) {
      positionsBuf = ArrayUtil.grow(positionsBuf);
    }
    positionsBuf[posStart + totalPositions] = position;
  }
  if (hasOffsets) {
    if (offStart + totalPositions == startOffsetsBuf.length) {
      final int newLength = ArrayUtil.oversize(offStart + totalPositions, 4);
      startOffsetsBuf = Arrays.copyOf(startOffsetsBuf, newLength);
      lengthsBuf = Arrays.copyOf(lengthsBuf, newLength);
    }
    startOffsetsBuf[offStart + totalPositions] = startOffset;
    lengthsBuf[offStart + totalPositions] = length;
  }
  if (hasPayloads) {
    if (payStart + totalPositions == payloadLengthsBuf.length) {
      payloadLengthsBuf = ArrayUtil.grow(payloadLengthsBuf);
    }
    payloadLengthsBuf[payStart + totalPositions] = payloadLength;
  }
  ++totalPositions;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:CompressingTermVectorsWriter.java

示例9: decompress

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
/**
 * Decompress the chunk.
 */
void decompress() throws IOException {
  // decompress data
  final int chunkSize = chunkSize();
  if (version >= VERSION_BIG_CHUNKS && chunkSize >= 2 * CompressingStoredFieldsReader.this.chunkSize) {
    bytes.offset = bytes.length = 0;
    for (int decompressed = 0; decompressed < chunkSize; ) {
      final int toDecompress = Math.min(chunkSize - decompressed, CompressingStoredFieldsReader.this.chunkSize);
      decompressor.decompress(fieldsStream, toDecompress, 0, toDecompress, spare);
      bytes.bytes = ArrayUtil.grow(bytes.bytes, bytes.length + spare.length);
      System.arraycopy(spare.bytes, spare.offset, bytes.bytes, bytes.length, spare.length);
      bytes.length += spare.length;
      decompressed += toDecompress;
    }
  } else {
    decompressor.decompress(fieldsStream, chunkSize, 0, chunkSize, bytes);
  }
  if (bytes.length != chunkSize) {
    throw new CorruptIndexException("Corrupted: expected chunk size = " + chunkSize() + ", got " + bytes.length + " (resource=" + fieldsStream + ")");
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:CompressingStoredFieldsReader.java

示例10: ConjunctionScorer

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
ConjunctionScorer(Weight weight, Scorer[] scorers, float coord) {
  super(weight);
  this.coord = coord;
  this.docsAndFreqs = new DocsAndFreqs[scorers.length];
  for (int i = 0; i < scorers.length; i++) {
    docsAndFreqs[i] = new DocsAndFreqs(scorers[i]);
  }
  // Sort the array the first time to allow the least frequent DocsEnum to
  // lead the matching.
  ArrayUtil.timSort(docsAndFreqs, new Comparator<DocsAndFreqs>() {
    @Override
    public int compare(DocsAndFreqs o1, DocsAndFreqs o2) {
      return Long.compare(o1.cost, o2.cost);
    }
  });

  lead = docsAndFreqs[0]; // least frequent DocsEnum leads the intersection
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:ConjunctionScorer.java

示例11: addOneValue

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
private void addOneValue(BytesRef value) {
  int termID = hash.add(value);
  if (termID < 0) {
    termID = -termID-1;
  } else {
    // reserve additional space for each unique value:
    // 1. when indexing, when hash is 50% full, rehash() suddenly needs 2*size ints.
    //    TODO: can this same OOM happen in THPF?
    // 2. when flushing, we need 1 int per value (slot in the ordMap).
    iwBytesUsed.addAndGet(2 * RamUsageEstimator.NUM_BYTES_INT);
  }
  
  if (currentUpto == currentValues.length) {
    currentValues = ArrayUtil.grow(currentValues, currentValues.length+1);
    // reserve additional space for max # values per-doc
    // when flushing, we need an int[] to sort the mapped-ords within the doc
    iwBytesUsed.addAndGet((currentValues.length - currentUpto) * 2 * RamUsageEstimator.NUM_BYTES_INT);
  }
  
  currentValues[currentUpto] = termID;
  currentUpto++;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:SortedSetDocValuesWriter.java

示例12: saveState

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
/**
 * Saves the existing attribute states
 */
private void saveState() {
  // otherwise, we have delimiters, save state
  savedStartOffset = offsetAttribute.startOffset();
  savedEndOffset = offsetAttribute.endOffset();
  // if length by start + end offsets doesn't match the term text then assume this is a synonym and don't adjust the offsets.
  hasIllegalOffsets = (savedEndOffset - savedStartOffset != termAttribute.length());
  savedType = typeAttribute.type();

  if (savedBuffer.length < termAttribute.length()) {
    savedBuffer = new char[ArrayUtil.oversize(termAttribute.length(), RamUsageEstimator.NUM_BYTES_CHAR)];
  }

  System.arraycopy(termAttribute.buffer(), 0, savedBuffer, 0, termAttribute.length());
  iterator.text = savedBuffer;

  hasSavedState = true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:WordDelimiterFilter.java

示例13: build

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
/**
 * Build a minimal, deterministic automaton from a sorted list of {@link BytesRef} representing
 * strings in UTF-8. These strings must be binary-sorted.
 */
public static Automaton build(Collection<BytesRef> input) {
  final DaciukMihovAutomatonBuilder builder = new DaciukMihovAutomatonBuilder();
  
  char[] chars = new char[0];
  CharsRef ref = new CharsRef();
  for (BytesRef b : input) {
    chars = ArrayUtil.grow(chars, b.length);
    final int len = UnicodeUtil.UTF8toUTF16(b, chars);
    ref.chars = chars;
    ref.length = len;
    builder.add(ref);
  }
  
  Automaton.Builder a = new Automaton.Builder();
  convert(a,
      builder.complete(), 
      new IdentityHashMap<State,Integer>());

  return a.finish();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:DaciukMihovAutomatonBuilder.java

示例14: incr

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
private void incr() {
  upto++;
  grow();
  if (arcs.length <= upto) {
    @SuppressWarnings({"rawtypes","unchecked"}) final FST.Arc<T>[] newArcs =
      new FST.Arc[ArrayUtil.oversize(1+upto, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
    System.arraycopy(arcs, 0, newArcs, 0, arcs.length);
    arcs = newArcs;
  }
  if (output.length <= upto) {
    @SuppressWarnings({"rawtypes","unchecked"}) final T[] newOutput =
      (T[]) new Object[ArrayUtil.oversize(1+upto, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
    System.arraycopy(output, 0, newOutput, 0, output.length);
    output = newOutput;
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:FSTEnum.java

示例15: add

import org.apache.lucene.util.ArrayUtil; //导入依赖的package包/类
/** Add a new element to this builder. */
public Builder add(long l) {
  if (pending == null) {
    throw new IllegalStateException("Cannot be reused after build()");
  }
  if (pendingOff == pending.length) {
    // check size
    if (values.length == valuesOff) {
      final int newLength = ArrayUtil.oversize(valuesOff + 1, 8);
      grow(newLength);
    }
    pack();
  }
  pending[pendingOff++] = l;
  size += 1;
  return this;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:PackedLongValues.java


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