Java 类io.netty.buffer.DrillBuf 实例源码

项目:QDrill    文件:TestValueVector.java   
@Test
public void testVectorCanLoadEmptyBuffer() throws Exception {
  final DrillBuf empty = allocator.getEmpty();

  testVectors(new VectorVerifier() {

    @Override
    public void verify(ValueVector vector) {
      final String hint = String.format("%s failed the test case", vector.getClass().getSimpleName());
      final UserBitShared.SerializedField metadata = vector.getMetadata();
      assertEquals(hint, 0, metadata.getBufferLength());
      assertEquals(hint, 0, metadata.getValueCount());

      vector.load(metadata, empty);

      assertEquals(hint, 0, vector.getValueCapacity());
      assertEquals(hint, 0, vector.getAccessor().getValueCount());

      vector.clear();
    }
  });
}
项目:QDrill    文件:BaseDataValueVector.java   
@Override
public DrillBuf[] getBuffers(boolean clear) {
  DrillBuf[] out;
  if (getBufferSize() == 0) {
    out = new DrillBuf[0];
  } else {
    out = new DrillBuf[]{data};
    if (clear) {
      data.readerIndex(0);
      data.retain(1);
    }
  }
  if (clear) {
    clear();
  }
  return out;
}
项目:QDrill    文件:RepeatedMapVector.java   
@Override
public void load(SerializedField metadata, DrillBuf buffer) {
  final List<SerializedField> children = metadata.getChildList();

  final SerializedField offsetField = children.get(0);
  offsets.load(offsetField, buffer);
  int bufOffset = offsetField.getBufferLength();

  for (int i = 1; i < children.size(); i++) {
    final SerializedField child = children.get(i);
    final MaterializedField fieldDef = MaterializedField.create(child);
    ValueVector vector = getChild(fieldDef.getLastName());
    if (vector == null) {
      // if we arrive here, we didn't have a matching vector.
      vector = TypeHelper.getNewVector(fieldDef, allocator);
      putChild(fieldDef.getLastName(), vector);
    }
    final int vectorLength = child.getBufferLength();
    vector.load(child, buffer.slice(bufOffset, vectorLength));
    bufOffset += vectorLength;
  }

  assert bufOffset == buffer.capacity();
}
项目:QDrill    文件:MapVector.java   
@Override
public void load(SerializedField metadata, DrillBuf buf) {
  final List<SerializedField> fields = metadata.getChildList();
  valueCount = metadata.getValueCount();

  int bufOffset = 0;
  for (final SerializedField child : fields) {
    final MaterializedField fieldDef = MaterializedField.create(child);

    ValueVector vector = getChild(fieldDef.getLastName());
    if (vector == null) {
      // if we arrive here, we didn't have a matching vector.
      vector = TypeHelper.getNewVector(fieldDef, allocator);
      putChild(fieldDef.getLastName(), vector);
    }
    if (child.getValueCount() == 0) {
      vector.clear();
    } else {
      vector.load(child, buf.slice(bufOffset, child.getBufferLength()));
    }
    bufOffset += child.getBufferLength();
  }

  assert bufOffset == buf.capacity();
}
项目:QDrill    文件:AbstractMapVector.java   
@Override
public DrillBuf[] getBuffers(boolean clear) {
  List<DrillBuf> buffers = Lists.newArrayList();

  for (ValueVector vector : vectors.values()) {
    for (DrillBuf buf : vector.getBuffers(false)) {
      buffers.add(buf);
      if (clear) {
        buf.retain();
      }
    }
    if (clear) {
      vector.clear();
    }
  }

  return buffers.toArray(new DrillBuf[buffers.size()]);
}
项目:QDrill    文件:VarLengthColumnReaders.java   
@Override
public boolean setSafe(int index, DrillBuf bytebuf, int start, int length) {
  if (index >= varCharVector.getValueCapacity()) {
    return false;
  }

  if (usingDictionary) {
    currDictValToWrite = pageReader.dictionaryValueReader.readBytes();
    mutator.setSafe(index, currDictValToWrite.toByteBuffer(), 0, currDictValToWrite.length());
  } else {
    mutator.setSafe(index, start, start + length, bytebuf);
  }
  return true;
}
项目:QDrill    文件:Accountor.java   
private boolean transfer(Accountor target, DrillBuf buf, long size, boolean release) {
  boolean withinLimit = target.forceAdditionalReservation(size);
  if(release){
    release(buf, size);
  }

  if (ENABLE_ACCOUNTING) {
    target.buffers.put(buf, new DebugStackTrace(buf.capacity(), Thread.currentThread().getStackTrace()));
  }
  return withinLimit;
}
项目:QDrill    文件:Accountor.java   
public void releasePartial(DrillBuf buf, long size) {
  remainder.returnAllocation(size);
  if (ENABLE_ACCOUNTING) {
    if (buf != null) {
      DebugStackTrace dst = buffers.get(buf);
      if (dst == null) {
        throw new IllegalStateException("Partially releasing a buffer that has already been released. Buffer: " + buf);
      }
      dst.size -= size;
      if (dst.size < 0) {
        throw new IllegalStateException("Partially releasing a buffer that has already been released. Buffer: " + buf);
      }
    }
  }
}
项目:QDrill    文件:Accountor.java   
public void release(DrillBuf buf, long size) {
  remainder.returnAllocation(size);
  if (ENABLE_ACCOUNTING) {
    if (buf != null && buffers.remove(buf) == null) {
      throw new IllegalStateException("Releasing a buffer that has already been released. Buffer: " + buf);
    }
  }
}
项目:QDrill    文件:DecimalUtility.java   
public static int compareSparseSamePrecScale(DrillBuf left, int lStart, byte[] right, int length) {
  // check the sign first
  boolean lSign = (left.getInt(lStart) & 0x80000000) != 0;
  boolean rSign = ByteFunctionHelpers.getSign(right);
  int cmp = 0;

  if (lSign != rSign) {
    return (lSign == false) ? 1 : -1;
  }

  // invert the comparison if we are comparing negative numbers
  int invert = (lSign == true) ? -1 : 1;

  // compare byte by byte
  int n = 0;
  int lPos = lStart;
  int rPos = 0;
  while (n < length/4) {
    int leftInt = Decimal38SparseHolder.getInteger(n, lStart, left);
    int rightInt = ByteFunctionHelpers.getInteger(right, n);
    if (leftInt != rightInt) {
      cmp =  (leftInt - rightInt ) > 0 ? 1 : -1;
      break;
    }
    n++;
  }
  return cmp * invert;
}
项目:QDrill    文件:ColumnDataReader.java   
public void loadPage(DrillBuf target, int pageLength) throws IOException {
  target.clear();
  ByteBuffer directBuffer = target.nioBuffer(0, pageLength);
  while (directBuffer.remaining() > 0) {
    CompatibilityUtil.getBuf(input, directBuffer, directBuffer.remaining());
  }
  target.writerIndex(pageLength);
}
项目:QDrill    文件:DecimalUtility.java   
public static int compareDenseBytes(DrillBuf left, int leftStart, boolean leftSign, DrillBuf right, int rightStart, boolean rightSign, int width) {

      int invert = 1;

      /* If signs are different then simply look at the
       * sign of the two inputs and determine which is greater
       */
      if (leftSign != rightSign) {

        return((leftSign == true) ? -1 : 1);
      } else if(leftSign == true) {
        /* Both inputs are negative, at the end we will
         * have to invert the comparison
         */
        invert = -1;
      }

      int cmp = 0;

      for (int i = 0; i < width; i++) {
        byte leftByte  = left.getByte(leftStart + i);
        byte rightByte = right.getByte(rightStart + i);
        // Unsigned byte comparison
        if ((leftByte & 0xFF) > (rightByte & 0xFF)) {
          cmp = 1;
          break;
        } else if ((leftByte & 0xFF) < (rightByte & 0xFF)) {
          cmp = -1;
          break;
        }
      }
      cmp *= invert; // invert the comparison if both were negative values

      return cmp;
    }
项目:QDrill    文件:DecimalUtility.java   
public static int getIntegerFromSparseBuffer(DrillBuf buffer, int start, int index) {
  int value = buffer.getInt(start + (index * 4));

  if (index == 0) {
    /* the first byte contains sign bit, return value without it */
    value = (value & 0x7FFFFFFF);
  }
  return value;
}
项目:QDrill    文件:QueryDataBatch.java   
public QueryDataBatch(QueryData header, DrillBuf data) {
  // logger.debug("New Result Batch with header {} and data {}", header, data);
  this.header = header;
  this.data = data;
  if (this.data != null) {
    data.retain(1);
  }
}
项目:QDrill    文件:StringFunctionHelpers.java   
public static void initCap(int start, int end, DrillBuf inBuf, DrillBuf outBuf) {
  boolean capNext = true;
  int out = 0;
  for (int id = start; id < end; id++, out++) {
    byte currentByte = inBuf.getByte(id);

    // 'A - Z' : 0x41 - 0x5A
    // 'a - z' : 0x61 - 0x7A
    // '0-9' : 0x30 - 0x39
    if (capNext) { // curCh is whitespace or first character of word.
      if (currentByte >= 0x30 && currentByte <= 0x39) { // 0-9
        capNext = false;
      } else if (currentByte >= 0x41 && currentByte <= 0x5A) { // A-Z
        capNext = false;
      } else if (currentByte >= 0x61 && currentByte <= 0x7A) { // a-z
        capNext = false;
        currentByte -= 0x20; // Uppercase this character
      }
      // else {} whitespace
    } else { // Inside of a word or white space after end of word.
      if (currentByte >= 0x30 && currentByte <= 0x39) { // 0-9
        // noop
      } else if (currentByte >= 0x41 && currentByte <= 0x5A) { // A-Z
        currentByte -= 0x20; // Lowercase this character
      } else if (currentByte >= 0x61 && currentByte <= 0x7A) { // a-z
        // noop
      } else { // whitespace
        capNext = true;
      }
    }

    outBuf.setByte(out, currentByte);
  } // end of for_loop
}
项目:QDrill    文件:DirectCodecFactory.java   
@Override
public void decompress(DrillBuf input, int compressedSize, DrillBuf output, int uncompressedSize)
    throws IOException {
  BytesInput uncompressed = decompress(new ByteBufBytesInput(input), uncompressedSize);
  output.clear();
  output.setBytes(0, uncompressed.toByteArray());
  output.writerIndex((int) uncompressed.size());
}
项目:QDrill    文件:ExternalSortBatch.java   
private long getBufferSize(VectorAccessible batch) {
  long size = 0;
  for (VectorWrapper<?> w : batch) {
    DrillBuf[] bufs = w.getValueVector().getBuffers(false);
    for (DrillBuf buf : bufs) {
      if (buf.isRootBuffer()) {
        size += buf.capacity();
      }
    }
  }
  return size;
}
项目:QDrill    文件:OperatorContextImpl.java   
@Override
public void close() {
  if (closed) {
    logger.debug("Attempted to close Operator context for {}, but context is already closed", popConfig != null ? popConfig.getClass().getName() : null);
    return;
  }
  logger.debug("Closing context for {}", popConfig != null ? popConfig.getClass().getName() : null);

  // release managed buffers.
  Object[] buffers = ((LongObjectOpenHashMap<Object>)(Object)managedBuffers).values;
  for (int i =0; i < buffers.length; i++) {
    if (managedBuffers.allocated[i]) {
      ((DrillBuf)buffers[i]).release();
    }
  }

  if (allocator != null) {
    allocator.close();
  }

  if (fs != null) {
    try {
      fs.close();
    } catch (IOException e) {
      throw new DrillRuntimeException(e);
    }
  }
  closed = true;
}
项目:QDrill    文件:BufferManager.java   
@Override
public void close() throws Exception {
  final Object[] mbuffers = ((LongObjectOpenHashMap<Object>) (Object) managedBuffers).values;
  for (int i = 0; i < mbuffers.length; i++) {
    if (managedBuffers.allocated[i]) {
      ((DrillBuf) mbuffers[i]).release(1);
    }
  }
  managedBuffers.clear();
}
项目:QDrill    文件:BufferManager.java   
public DrillBuf replace(DrillBuf old, int newSize) {
  if (managedBuffers.remove(old.memoryAddress()) == null) {
    throw new IllegalStateException("Tried to remove unmanaged buffer.");
  }
  old.release(1);
  return getManagedBuffer(newSize);
}
项目:QDrill    文件:BufferManager.java   
public DrillBuf getManagedBuffer(int size) {
  DrillBuf newBuf = allocator.buffer(size);
  managedBuffers.put(newBuf.memoryAddress(), newBuf);
  newBuf.setFragmentContext(fragmentContext);
  newBuf.setBufferManager(this);
  return newBuf;
}
项目:QDrill    文件:ValueHolderHelper.java   
public static VarCharHolder getVarCharHolder(DrillBuf buf, String s){
  VarCharHolder vch = new VarCharHolder();

  byte[] b = s.getBytes(Charsets.UTF_8);
  vch.start = 0;
  vch.end = b.length;
  vch.buffer = buf.reallocIfNeeded(b.length);
  vch.buffer.setBytes(0, b);
  return vch;
}
项目:QDrill    文件:ValueHolderHelper.java   
public static Decimal28SparseHolder getDecimal28Holder(DrillBuf buf, String decimal) {

    Decimal28SparseHolder dch = new Decimal28SparseHolder();

    BigDecimal bigDecimal = new BigDecimal(decimal);

    dch.scale = bigDecimal.scale();
    dch.precision = bigDecimal.precision();
    Decimal28SparseHolder.setSign(bigDecimal.signum() == -1, dch.start, dch.buffer);
    dch.start = 0;
    dch.buffer = buf.reallocIfNeeded(5 * DecimalUtility.integerSize);
    DecimalUtility.getSparseFromBigDecimal(bigDecimal, dch.buffer, dch.start, dch.scale, dch.precision, dch.nDecimalDigits);

    return dch;
  }
项目:QDrill    文件:ValueHolderHelper.java   
public static Decimal38SparseHolder getDecimal38Holder(DrillBuf buf, String decimal) {

      Decimal38SparseHolder dch = new Decimal38SparseHolder();

      BigDecimal bigDecimal = new BigDecimal(decimal);

      dch.scale = bigDecimal.scale();
      dch.precision = bigDecimal.precision();
      Decimal38SparseHolder.setSign(bigDecimal.signum() == -1, dch.start, dch.buffer);
      dch.start = 0;
      dch.buffer = buf.reallocIfNeeded(dch.maxPrecision * DecimalUtility.integerSize);
      DecimalUtility.getSparseFromBigDecimal(bigDecimal, dch.buffer, dch.start, dch.scale, dch.precision, dch.nDecimalDigits);

      return dch;
  }
项目:QDrill    文件:DecimalUtility.java   
public static BigDecimal getBigDecimalFromDrillBuf(DrillBuf data, int startIndex, int nDecimalDigits, int scale, boolean truncateScale) {

        // For sparse decimal type we have padded zeroes at the end, strip them while converting to BigDecimal.
        int actualDigits;

        // Initialize the BigDecimal, first digit in the DrillBuf has the sign so mask it out
        BigInteger decimalDigits = BigInteger.valueOf((data.getInt(startIndex)) & 0x7FFFFFFF);

        BigInteger base = BigInteger.valueOf(DIGITS_BASE);

        for (int i = 1; i < nDecimalDigits; i++) {

            BigInteger temp = BigInteger.valueOf(data.getInt(startIndex + (i * integerSize)));
            decimalDigits = decimalDigits.multiply(base);
            decimalDigits = decimalDigits.add(temp);
        }

        // Truncate any additional padding we might have added
        if (truncateScale == true && scale > 0 && (actualDigits = scale % MAX_DIGITS) != 0) {
            BigInteger truncate = BigInteger.valueOf((int)Math.pow(10, (MAX_DIGITS - actualDigits)));
            decimalDigits = decimalDigits.divide(truncate);
        }

        // set the sign
        if ((data.getInt(startIndex) & 0x80000000) != 0) {
            decimalDigits = decimalDigits.negate();
        }

        BigDecimal decimal = new BigDecimal(decimalDigits, scale);

        return decimal;
    }
项目:QDrill    文件:BitVector.java   
@Override
public void load(SerializedField metadata, DrillBuf buffer) {
  Preconditions.checkArgument(this.field.matches(metadata), "The field %s doesn't match the provided metadata %s.", this.field, metadata);
  final int valueCount = metadata.getValueCount();
  final int expectedLength = getSizeFromCount(valueCount);
  final int actualLength = metadata.getBufferLength();
  assert expectedLength == actualLength: "expected and actual buffer sizes do not match";

  clear();
  data = buffer.slice(0, actualLength);
  data.retain();
  this.valueCount = valueCount;
}
项目:QDrill    文件:DecimalUtility.java   
public static void getSparseFromBigDecimal(BigDecimal input, DrillBuf data, int startIndex, int scale, int precision, int nDecimalDigits) {

        // Initialize the buffer
        for (int i = 0; i < nDecimalDigits; i++) {
          data.setInt(startIndex + (i * integerSize), 0);
        }

        boolean sign = false;

        if (input.signum() == -1) {
            // negative input
            sign = true;
            input = input.abs();
        }

        // Truncate the input as per the scale provided
        input = input.setScale(scale, BigDecimal.ROUND_HALF_UP);

        // Separate out the integer part
        BigDecimal integerPart = input.setScale(0, BigDecimal.ROUND_DOWN);

        int destIndex = nDecimalDigits - roundUp(scale) - 1;

        // we use base 1 billion integer digits for out integernal representation
        BigDecimal base = new BigDecimal(DIGITS_BASE);

        while (integerPart.compareTo(BigDecimal.ZERO) == 1) {
            // store the modulo as the integer value
            data.setInt(startIndex + (destIndex * integerSize), (integerPart.remainder(base)).intValue());
            destIndex--;
            // Divide by base 1 billion
            integerPart = (integerPart.divide(base)).setScale(0, BigDecimal.ROUND_DOWN);
        }

        /* Sparse representation contains padding of additional zeroes
         * so each digit contains MAX_DIGITS for ease of arithmetic
         */
        int actualDigits;
        if ((actualDigits = (scale % MAX_DIGITS)) != 0) {
            // Pad additional zeroes
            scale = scale + (MAX_DIGITS - actualDigits);
            input = input.setScale(scale, BigDecimal.ROUND_DOWN);
        }

        //separate out the fractional part
        BigDecimal fractionalPart = input.remainder(BigDecimal.ONE).movePointRight(scale);

        destIndex = nDecimalDigits - 1;

        while (scale > 0) {
            // Get next set of MAX_DIGITS (9) store it in the DrillBuf
            fractionalPart = fractionalPart.movePointLeft(MAX_DIGITS);
            BigDecimal temp = fractionalPart.remainder(BigDecimal.ONE);

            data.setInt(startIndex + (destIndex * integerSize), (temp.unscaledValue().intValue()));
            destIndex--;

            fractionalPart = fractionalPart.setScale(0, BigDecimal.ROUND_DOWN);
            scale -= MAX_DIGITS;
        }

        // Set the negative sign
        if (sign == true) {
            data.setInt(startIndex, data.getInt(startIndex) | 0x80000000);
        }

    }
项目:QDrill    文件:BaseRepeatedValueVector.java   
@Override
public DrillBuf[] getBuffers(boolean clear) {
  final DrillBuf[] buffers = ObjectArrays.concat(offsets.getBuffers(false), vector.getBuffers(false), DrillBuf.class);
  if (clear) {
    for (DrillBuf buffer:buffers) {
      buffer.retain();
    }
    clear();
  }
  return buffers;
}
项目:QDrill    文件:BaseRepeatedValueVector.java   
@Override
public void load(UserBitShared.SerializedField metadata, DrillBuf buffer) {
  final UserBitShared.SerializedField offsetMetadata = metadata.getChild(0);
  offsets.load(offsetMetadata, buffer);

  final UserBitShared.SerializedField vectorMetadata = metadata.getChild(1);
  if (getDataVector() == DEFAULT_DATA_VECTOR) {
    addOrGetVector(VectorDescriptor.create(vectorMetadata.getMajorType()));
  }

  final int offsetLength = offsetMetadata.getBufferLength();
  final int vectorLength = vectorMetadata.getBufferLength();
  vector.load(vectorMetadata, buffer.slice(offsetLength, vectorLength));
}
项目:QDrill    文件:JsonReader.java   
public JsonReader(DrillBuf managedBuf, List<SchemaPath> columns, boolean allTextMode, boolean skipOuterList, boolean readNumbersAsDouble) {
  super(managedBuf);
  assert Preconditions.checkNotNull(columns).size() > 0 : "json record reader requires at least a column";
  this.selection = FieldSelection.getFieldSelection(columns);
  this.workingBuffer = new WorkingBuffer(managedBuf);
  this.skipOuterList = skipOuterList;
  this.allTextMode = allTextMode;
  this.columns = columns;
  this.mapOutput = new MapVectorOutput(workingBuffer);
  this.listOutput = new ListVectorOutput(workingBuffer);
  this.currentFieldName="<none>";
  this.readNumbersAsDouble = readNumbersAsDouble;
}
项目:QDrill    文件:VarLengthColumnReaders.java   
@Override
public boolean setSafe(int index, DrillBuf value, int start, int length) {
  if (index >= varBinaryVector.getValueCapacity()) {
    return false;
  }

  if (usingDictionary) {
    currDictValToWrite = pageReader.dictionaryValueReader.readBytes();
    mutator.setSafe(index, currDictValToWrite.toByteBuffer(), 0, currDictValToWrite.length());
  } else {
    mutator.setSafe(index, start, start + length, value);
  }
  return true;
}
项目:QDrill    文件:VarLengthColumnReaders.java   
@Override
public boolean setSafe(int index, DrillBuf bytebuf, int start, int length) {
  int width = Decimal28SparseHolder.WIDTH;
  BigDecimal intermediate = DecimalUtility.getBigDecimalFromDrillBuf(bytebuf, start, length,
      schemaElement.getScale());
  if (index >= decimal28Vector.getValueCapacity()) {
    return false;
  }
  DecimalUtility.getSparseFromBigDecimal(intermediate, decimal28Vector.getBuffer(), index * width, schemaElement.getScale(),
          schemaElement.getPrecision(), Decimal28SparseHolder.nDecimalDigits);
  return true;
}
项目:QDrill    文件:VectorTrimmer.java   
public static void trim(ByteBuf data, int idx) {
  data.writerIndex(idx);
  if (data instanceof DrillBuf) {
    // data.capacity(idx);
    data.writerIndex(idx);
  }
}
项目:QDrill    文件:PrintingResultsListener.java   
@Override
public void dataArrived(QueryDataBatch result, ConnectionThrottle throttle) {
  final QueryData header = result.getHeader();
  final DrillBuf data = result.getData();

  if (data != null) {
    count.addAndGet(header.getRowCount());
    try {
      loader.load(header.getDef(), data);
      // TODO:  Clean:  DRILL-2933:  That load(...) no longer throws
      // SchemaChangeException, so check/clean catch clause below.
    } catch (SchemaChangeException e) {
      submissionFailed(UserException.systemError(e).build(logger));
    }

    switch(format) {
      case TABLE:
        VectorUtil.showVectorAccessibleContent(loader, columnWidth);
        break;
      case TSV:
        VectorUtil.showVectorAccessibleContent(loader, "\t");
        break;
      case CSV:
        VectorUtil.showVectorAccessibleContent(loader, ",");
        break;
    }
    loader.clear();
  }

  result.release();
}
项目:QDrill    文件:TestConvertFunctions.java   
@Test
public void testHadooopVInt() throws Exception {
  final int _0 = 0;
  final int _9 = 9;
  final DrillBuf buffer = getAllocator().buffer(_9);

  long longVal = 0;
  buffer.clear();
  HadoopWritables.writeVLong(buffer, _0, _9, 0);
  longVal = HadoopWritables.readVLong(buffer, _0, _9);
  assertEquals(longVal, 0);

  buffer.clear();
  HadoopWritables.writeVLong(buffer, _0, _9, Long.MAX_VALUE);
  longVal = HadoopWritables.readVLong(buffer, _0, _9);
  assertEquals(longVal, Long.MAX_VALUE);

  buffer.clear();
  HadoopWritables.writeVLong(buffer, _0, _9, Long.MIN_VALUE);
  longVal = HadoopWritables.readVLong(buffer, _0, _9);
  assertEquals(longVal, Long.MIN_VALUE);

  int intVal = 0;
  buffer.clear();
  HadoopWritables.writeVInt(buffer, _0, _9, 0);
  intVal = HadoopWritables.readVInt(buffer, _0, _9);
  assertEquals(intVal, 0);

  buffer.clear();
  HadoopWritables.writeVInt(buffer, _0, _9, Integer.MAX_VALUE);
  intVal = HadoopWritables.readVInt(buffer, _0, _9);
  assertEquals(intVal, Integer.MAX_VALUE);

  buffer.clear();
  HadoopWritables.writeVInt(buffer, _0, _9, Integer.MIN_VALUE);
  intVal = HadoopWritables.readVInt(buffer, _0, _9);
  assertEquals(intVal, Integer.MIN_VALUE);
  buffer.release();
}
项目:QDrill    文件:MergeJoinBatchBuilder.java   
@Override
public void close() {
  if (!svAllocatorUsed) {
    final DrillBuf drillBuf = svAllocator.getAllocation();
    if (drillBuf != null) {
      drillBuf.release();
    }
  }
}
项目:QDrill    文件:ByteBufUtil.java   
/**
 * Verifies that the the space provided in the buffer is of specified size.
 * @throws IllegalArgumentException if the specified boundaries do not describe the expected size.
 */
public static void checkBufferLength(DrillBuf buffer, int start, int end, int requiredLen) {
  int actualLen = (end - start);
  if (actualLen != requiredLen) {
    throw new IllegalArgumentException(String.format("Wrong length %d(%d-%d) in the buffer '%s', expected %d.",
        actualLen, end, start, DrillStringUtils.toBinaryString(buffer, start, end), requiredLen));
  }
}
项目:QDrill    文件:SelectionVector2.java   
public void setBuffer(DrillBuf bufferHandle) {
    /* clear the existing buffer */
    clear();

    this.buffer = bufferHandle;
    buffer.retain(1);
}
项目:QDrill    文件:VarLengthColumnReaders.java   
@Override
public boolean setSafe(int index, DrillBuf bytebuf, int start, int length) {
  int width = Decimal38SparseHolder.WIDTH;
  BigDecimal intermediate = DecimalUtility.getBigDecimalFromDrillBuf(bytebuf, start, length,
      schemaElement.getScale());
  if (index >= nullableDecimal38Vector.getValueCapacity()) {
    return false;
  }

  DecimalUtility.getSparseFromBigDecimal(intermediate, nullableDecimal38Vector.getBuffer(), index * width, schemaElement.getScale(),
          schemaElement.getPrecision(), Decimal38SparseHolder.nDecimalDigits);
  nullableDecimal38Vector.getMutator().setIndexDefined(index);
  return true;
}
项目:QDrill    文件:PriorityQueueTemplate.java   
@Override
public void generate() throws SchemaChangeException {
  Stopwatch watch = new Stopwatch();
  watch.start();
  final DrillBuf drillBuf = allocator.buffer(4 * queueSize);
  finalSv4 = new SelectionVector4(drillBuf, queueSize, 4000);
  for (int i = queueSize - 1; i >= 0; i--) {
    finalSv4.set(i, pop());
  }
  logger.debug("Took {} us to generate output of {}", watch.elapsed(TimeUnit.MICROSECONDS), finalSv4.getTotalCount());
}