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


Java ArrayUtil.oversize方法代码示例

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


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

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

示例2: replace_s

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
protected int replace_s(int c_bra, int c_ket, CharSequence s) {
  final int adjustment = s.length() - (c_ket - c_bra);
  final int newLength = limit + adjustment;
  //resize if necessary
  if (newLength > current.length) {
    char newBuffer[] = new char[ArrayUtil.oversize(newLength, RamUsageEstimator.NUM_BYTES_CHAR)];
    System.arraycopy(current, 0, newBuffer, 0, limit);
    current = newBuffer;
  }
  // if the substring being replaced is longer or shorter than the
  // replacement, need to shift things around
  if (adjustment != 0 && c_ket < limit) {
    System.arraycopy(current, c_ket, current, c_bra + s.length(),
        limit - c_ket);
  }
  // insert the replacement text
  // Note, faster is s.getChars(0, s.length(), current, c_bra);
  // but would have to duplicate this method for both String and StringBuilder
  for (int i = 0; i < s.length(); i++)
    current[c_bra + i] = s.charAt(i);

  limit += adjustment;
  if (cursor >= c_ket) cursor += adjustment;
  else if (cursor > c_bra) cursor = c_bra;
  return adjustment;
}
 
开发者ID:gncloud,项目名称:fastcatsearch3,代码行数:27,代码来源:SnowballProgram.java

示例3: 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:europeana,项目名称:search,代码行数:25,代码来源:CompressingTermVectorsWriter.java

示例4: nextPosition

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
@Override
public int nextPosition() throws IOException {
  final int token = postingInput.readVInt();
  pos += token >>> 1;
  if (storeOffsets) {
    startOffset = endOffset + postingInput.readVInt();
    endOffset = startOffset + postingInput.readVInt();
  }
  if ((token & 1) != 0) {
    payload.offset = 0;
    payload.length = postingInput.readVInt();
    if (payload.length > payload.bytes.length) {
      payload.bytes = new byte[ArrayUtil.oversize(payload.length, 1)];
    }
    postingInput.readBytes(payload.bytes, 0, payload.length);
  } else {
    payload.length = 0;
  }
  return pos;
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:SortingAtomicReader.java

示例5: collect

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
@Override
public final void collect( int doc ) throws IOException
{
    docs.addDoc( doc );
    if ( keepScores )
    {
        if ( segmentHits >= scores.length )
        {
            float[] newScores = new float[ArrayUtil.oversize( segmentHits + 1, 4 )];
            System.arraycopy( scores, 0, newScores, 0, segmentHits );
            scores = newScores;
        }
        scores[segmentHits] = scorer.score();
    }
    segmentHits++;
    totalHits++;
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:18,代码来源:DocValuesCollector.java

示例6: grow

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
private static <T> T[] grow(T[] array, int minSize) {
    if (array.length < minSize) {
        final int newLen = ArrayUtil.oversize(minSize, RamUsageEstimator.NUM_BYTES_OBJECT_REF);
        array = Arrays.copyOf(array, newLen);
    }
    return array;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:AbstractBigArray.java

示例7: grow

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
/**
 * Make sure the {@link #values} array can store at least {@link #count} entries.
 */
protected final void grow() {
    if (values.length < count) {
        final int oldLen = values.length;
        final int newLen = ArrayUtil.oversize(count, RamUsageEstimator.NUM_BYTES_OBJECT_REF);
        values = Arrays.copyOf(values, newLen);
        for (int i = oldLen; i < newLen; ++i) {
            values[i] = new BytesRefBuilder();
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:SortingBinaryDocValues.java

示例8: next

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
private PointTransitions next(int point) {
  // 1st time we are seeing this point
  if (count == points.length) {
    final PointTransitions[] newArray = new PointTransitions[ArrayUtil.oversize(1+count, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
    System.arraycopy(points, 0, newArray, 0, count);
    points = newArray;
  }
  PointTransitions points0 = points[count];
  if (points0 == null) {
    points0 = points[count] = new PointTransitions();
  }
  points0.reset(point);
  count++;
  return points0;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:Operations.java

示例9: writeString

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
public void writeString(String str) throws IOException {
    final int charCount = str.length();
    final int bufferSize = Math.min(3 * charCount, 1024); // at most 3 bytes per character is needed here
    if (convertStringBuffer.length < bufferSize) { // we don't use ArrayUtils.grow since copying the bytes is unnecessary
        convertStringBuffer = new byte[ArrayUtil.oversize(bufferSize, Byte.BYTES)];
    }
    byte[] buffer = convertStringBuffer;
    int offset = 0;
    writeVInt(charCount);
    for (int i = 0; i < charCount; i++) {
        final int c = str.charAt(i);
        if (c <= 0x007F) {
            buffer[offset++] = ((byte) c);
        } else if (c > 0x07FF) {
            buffer[offset++] = ((byte) (0xE0 | c >> 12 & 0x0F));
            buffer[offset++] = ((byte) (0x80 | c >> 6 & 0x3F));
            buffer[offset++] = ((byte) (0x80 | c >> 0 & 0x3F));
        } else {
            buffer[offset++] = ((byte) (0xC0 | c >> 6 & 0x1F));
            buffer[offset++] = ((byte) (0x80 | c >> 0 & 0x3F));
        }
        // make sure any possible char can fit into the buffer in any possible iteration
        // we need at most 3 bytes so we flush the buffer once we have less than 3 bytes
        // left before we start another iteration
        if (offset > buffer.length - 3) {
            writeBytes(buffer, offset);
            offset = 0;
        }
    }
    writeBytes(buffer, offset);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:StreamOutput.java

示例10: buffer

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
private void buffer() {
  if (bufferedLen == buffered.length) {
    int newSize = ArrayUtil.oversize(bufferedLen+1, 8);
    buffered = Arrays.copyOf(buffered, newSize);
    startOff = Arrays.copyOf(startOff, newSize);
    posInc = Arrays.copyOf(posInc, newSize);
  }
  startOff[bufferedLen] = offsetAttribute.startOffset();
  posInc[bufferedLen] = posIncAttribute.getPositionIncrement();
  buffered[bufferedLen] = captureState();
  bufferedLen++;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:WordDelimiterFilter.java

示例11: testRandomBinaryRoundTrip

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
public void testRandomBinaryRoundTrip() {
  byte[] binary = new byte[MAX_RANDOM_BINARY_LENGTH];
  char[] encoded = new char[MAX_RANDOM_BINARY_LENGTH * 10];
  byte[] decoded = new byte[MAX_RANDOM_BINARY_LENGTH];
  for (int testNum = 0; testNum < NUM_RANDOM_TESTS; ++testNum) {
    int numBytes = random().nextInt(MAX_RANDOM_BINARY_LENGTH - 1) + 1; // Min == 1

    for (int byteNum = 0; byteNum < numBytes; ++byteNum) {
      binary[byteNum] = (byte) random().nextInt(0x100);
    }

    int encodedLen = IndexableBinaryStringTools.getEncodedLength(binary, 0,
        numBytes);
    if (encoded.length < encodedLen)
      encoded = new char[ArrayUtil.oversize(encodedLen, Character.BYTES)];
    IndexableBinaryStringTools.encode(binary, 0, numBytes, encoded, 0,
        encodedLen);

    int decodedLen = IndexableBinaryStringTools.getDecodedLength(encoded, 0,
        encodedLen);
    IndexableBinaryStringTools.decode(encoded, 0, encodedLen, decoded, 0,
        decodedLen);

    assertEquals("Test #" + (testNum + 1)
        + ": Round trip decode/decode returned different results:"
        + LINE_SEPARATOR + "  original: "
        + binaryDump(binary, numBytes) + LINE_SEPARATOR
        + "encodedBuf: " + charArrayDump(encoded, encodedLen)
        + LINE_SEPARATOR + "decodedBuf: "
        + binaryDump(decoded, decodedLen), binaryDump(binary, numBytes),
        binaryDump(decoded, decodedLen));
  }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:34,代码来源:IndexableBinaryStringToolsTests.java

示例12: stem

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
/**
 * Stem a word contained in a portion of a char[] array. Returns true if the
 * stemming process resulted in a word different from the input. You can
 * retrieve the result with getResultLength()/getResultBuffer() or
 * toString().
 */
public boolean stem(char[] wordBuffer, int offset, int wordLen) {
    reset();
    if (b.length < wordLen) {
        b = new char[ArrayUtil.oversize(wordLen, Character.BYTES)];
    }
    System.arraycopy(wordBuffer, offset, b, 0, wordLen);
    i = wordLen;
    return stem(0);
}
 
开发者ID:hualongdata,项目名称:hanlp-ext,代码行数:16,代码来源:PorterStemmer.java

示例13: setFloorData

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
public void setFloorData(ByteArrayDataInput in, BytesRef source) {
  final int numBytes = source.length - (in.getPosition() - source.offset);
  if (numBytes > floorData.length) {
    floorData = new byte[ArrayUtil.oversize(numBytes, 1)];
  }
  System.arraycopy(source.bytes, source.offset+in.getPosition(), floorData, 0, numBytes);
  floorDataReader.reset(floorData, 0, numBytes);
  numFollowFloorBlocks = floorDataReader.readVInt();
  nextFloorLabel = floorDataReader.readByte() & 0xff;
  //if (DEBUG) {
  //System.out.println("    setFloorData fpOrig=" + fpOrig + " bytes=" + new BytesRef(source.bytes, source.offset + in.getPosition(), numBytes) + " numFollowFloorBlocks=" + numFollowFloorBlocks + " nextFloorLabel=" + toHex(nextFloorLabel));
  //}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:SegmentTermsEnumFrame.java

示例14: getArc

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
private FST.Arc<BytesRef> getArc(int ord) {
  if (ord >= arcs.length) {
    @SuppressWarnings({"rawtypes","unchecked"}) final FST.Arc<BytesRef>[] next =
    new FST.Arc[ArrayUtil.oversize(1+ord, RamUsageEstimator.NUM_BYTES_OBJECT_REF)];
    System.arraycopy(arcs, 0, next, 0, arcs.length);
    for(int arcOrd=arcs.length;arcOrd<next.length;arcOrd++) {
      next[arcOrd] = new FST.Arc<>();
    }
    arcs = next;
  }
  return arcs[ord];
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:SegmentTermsEnum.java

示例15: copy

import org.apache.lucene.util.ArrayUtil; //导入方法依赖的package包/类
protected static void copy(BytesRef from, BytesRef to) {
    if (to.bytes.length < from.length) {
        to.bytes = new byte[ArrayUtil.oversize(from.length, RamUsageEstimator.NUM_BYTES_BYTE)];
    }
    to.offset = 0;
    to.length = from.length;
    System.arraycopy(from.bytes, from.offset, to.bytes, 0, from.length);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:9,代码来源:GlobalOrdinalsStringTermsAggregator.java


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