Package org.apache.blur.lucene.fst

Examples of org.apache.blur.lucene.fst.ByteArray


    this.blockSize = blockSize;
    this.blockMask = blockSize - 1;
    long left = numBytes;
    while (left > 0) {
      final int chunk = (int) Math.min(blockSize, left);
      ByteArray block = factory.newByteArray(chunk);
      block.readBytes(in, 0, block.length());
      blocks.add(block);
      left -= chunk;
    }

    // So .getPosition still works
View Full Code Here


  /**
   * Absolute write byte; you must ensure dest is < max position written so far.
   */
  public void writeByte(int dest, byte b) {
    int blockIndex = dest >> blockBits;
    ByteArray block = blocks.get(blockIndex);
    block.put(dest & blockMask, b);
  }
View Full Code Here

  int getBlockBits() {
    return blockBits;
  }

  void writeBytes(long dest, byte[] b, int offset, int len) {
    ByteArray byteArray = factory.newByteArray(len);
    byteArray.put(0, b, offset, len);
    writeBytes(dest, byteArray, 0, len);
  }
View Full Code Here

    int downTo = (int) (end & blockMask);
    if (downTo == 0) {
      blockIndex--;
      downTo = blockSize;
    }
    ByteArray block = blocks.get(blockIndex);

    while (len > 0) {
      // System.out.println("    cycle downTo=" + downTo + " len=" + len);
      if (len <= downTo) {
        // System.out.println("      final: offset=" + offset + " len=" + len +
View Full Code Here

    int downTo = (int) (end & blockMask);
    if (downTo == 0) {
      blockIndex--;
      downTo = blockSize;
    }
    ByteArray block = blocks.get(blockIndex);

    while (len > 0) {
      // System.out.println("  cycle downTo=" + downTo);
      if (len <= downTo) {
        // System.out.println("    finish");
View Full Code Here

   * pointer.
   */
  public void writeInt(long pos, int value) {
    int blockIndex = (int) (pos >> blockBits);
    int upto = (int) (pos & blockMask);
    ByteArray block = blocks.get(blockIndex);
    int shift = 24;
    for (int i = 0; i < 4; i++) {
      block.put(upto++, (byte) (value >> shift));
      shift -= 8;
      if (upto == blockSize) {
        upto = 0;
        blockIndex++;
        block = blocks.get(blockIndex);
View Full Code Here

    assert destPos < getPosition();
    // System.out.println("reverse src=" + srcPos + " dest=" + destPos);

    int srcBlockIndex = (int) (srcPos >> blockBits);
    int src = (int) (srcPos & blockMask);
    ByteArray srcBlock = blocks.get(srcBlockIndex);

    int destBlockIndex = (int) (destPos >> blockBits);
    int dest = (int) (destPos & blockMask);
    ByteArray destBlock = blocks.get(destBlockIndex);
    // System.out.println("  srcBlock=" + srcBlockIndex + " destBlock=" +
    // destBlockIndex);

    int limit = (int) (destPos - srcPos + 1) / 2;
    for (int i = 0; i < limit; i++) {
      // System.out.println("  cycle src=" + src + " dest=" + dest);
      byte b = srcBlock.get(src);
      srcBlock.put(src, destBlock.get(dest));
      destBlock.put(dest, b);
      src++;
      if (src == blockSize) {
        srcBlockIndex++;
        srcBlock = blocks.get(srcBlockIndex);
        // System.out.println("  set destBlock=" + destBlock + " srcBlock=" +
View Full Code Here

    assert newLen == getPosition();
  }

  public void finish() {
    if (current != null) {
      ByteArray lastBuffer = factory.newByteArray(nextWrite);
      arraycopy(current, 0, lastBuffer, 0, nextWrite);
      blocks.set(blocks.size() - 1, lastBuffer);
      current = null;
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.blur.lucene.fst.ByteArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.