public void accumulate(final long memoryAddr, final int count) { final long maxAddr = memoryAddr + count * WIDTH_ORDINAL; FieldVector inputVector = getInput(); final long incomingBit = inputVector.getValidityBufferAddress(); final long incomingValue = inputVector.getDataBufferAddress(); final long[] valueAddresses = this.valueAddresses; final int scale = ((DecimalVector)inputVector).getScale(); int incomingIndex = 0; for(long ordinalAddr = memoryAddr; ordinalAddr < maxAddr; ordinalAddr += WIDTH_ORDINAL, incomingIndex++) { final int bitVal = (PlatformDependent.getByte(incomingBit + ((incomingIndex >>> 3))) >>> (incomingIndex & 7)) & 1; java.math.BigDecimal newVal = DecimalAccumulatorUtilsNoSpill.getBigDecimal(incomingValue + (incomingIndex * WIDTH_INPUT), valBuf, scale); final int tableIndex = PlatformDependent.getInt(ordinalAddr); final long sumAddr = valueAddresses[tableIndex >>> LBlockHashTableNoSpill.BITS_IN_CHUNK] + (tableIndex & LBlockHashTableNoSpill.CHUNK_OFFSET_MASK) * WIDTH_ACCUMULATOR; PlatformDependent.putLong(sumAddr, Double.doubleToLongBits(Double.longBitsToDouble(PlatformDependent.getLong(sumAddr)) + newVal.doubleValue() * bitVal)); } } }
public void accumulate(final long memoryAddr, final int count) { final long maxAddr = memoryAddr + count * WIDTH_ORDINAL; FieldVector inputVector = getInput(); final long incomingBit = inputVector.getValidityBufferAddress(); final long incomingValue = inputVector.getDataBufferAddress(); final long[] bitAddresses = this.bitAddresses; final long[] valueAddresses = this.valueAddresses; final int scale = ((DecimalVector)inputVector).getScale(); int incomingIndex = 0; for (long ordinalAddr = memoryAddr; ordinalAddr < maxAddr; ordinalAddr += WIDTH_ORDINAL, incomingIndex++) { final int bitVal = (PlatformDependent.getByte(incomingBit + ((incomingIndex >>> 3))) >>> (incomingIndex & 7)) & 1; java.math.BigDecimal newVal = DecimalAccumulatorUtilsNoSpill.getBigDecimal(incomingValue + (incomingIndex * WIDTH_INPUT), valBuf, scale); final int tableIndex = PlatformDependent.getInt(ordinalAddr); int chunkIndex = tableIndex >>> LBlockHashTableNoSpill.BITS_IN_CHUNK; int chunkOffset = tableIndex & LBlockHashTableNoSpill.CHUNK_OFFSET_MASK; final long sumAddr = valueAddresses[chunkIndex] + (chunkOffset) * WIDTH_ACCUMULATOR; final long bitUpdateAddr = bitAddresses[chunkIndex] + ((chunkOffset >>> 5) * 4); final int bitUpdateVal = bitVal << (chunkOffset & 31); PlatformDependent.putLong(sumAddr, Double.doubleToLongBits(Double.longBitsToDouble(PlatformDependent.getLong(sumAddr)) + newVal.doubleValue() * bitVal)); PlatformDependent.putInt(bitUpdateAddr, PlatformDependent.getInt(bitUpdateAddr) | bitUpdateVal); } } }
public void accumulate(final long memoryAddr, final int count) { final long maxAddr = memoryAddr + count * WIDTH_ORDINAL; FieldVector inputVector = getInput(); final long incomingBit = inputVector.getValidityBufferAddress(); final long incomingValue = inputVector.getDataBufferAddress(); final long[] bitAddresses = this.bitAddresses; final long[] valueAddresses = this.valueAddresses; final int scale = ((DecimalVector)inputVector).getScale(); int incomingIndex = 0; for (long ordinalAddr = memoryAddr; ordinalAddr < maxAddr; ordinalAddr += WIDTH_ORDINAL, incomingIndex++) { java.math.BigDecimal newVal = DecimalAccumulatorUtilsNoSpill.getBigDecimal(incomingValue + (incomingIndex * WIDTH_INPUT), valBuf, scale); final int tableIndex = PlatformDependent.getInt(ordinalAddr); int chunkIndex = tableIndex >>> LBlockHashTableNoSpill.BITS_IN_CHUNK; int chunkOffset = tableIndex & LBlockHashTableNoSpill.CHUNK_OFFSET_MASK; final long minAddr = valueAddresses[chunkIndex] + (chunkOffset) * WIDTH_ACCUMULATOR; final long bitUpdateAddr = bitAddresses[chunkIndex] + ((chunkOffset >>> 5) * 4); final int bitVal = (PlatformDependent.getByte(incomingBit + ((incomingIndex >>> 3))) >>> (incomingIndex & 7)) & 1; final int bitUpdateVal = bitVal << (chunkOffset & 31); PlatformDependent.putLong(minAddr, Double.doubleToLongBits(min(Double.longBitsToDouble(PlatformDependent.getLong(minAddr)), newVal.doubleValue(), bitVal))); PlatformDependent.putInt(bitUpdateAddr, PlatformDependent.getInt(bitUpdateAddr) | bitUpdateVal); } } }
public void accumulate(final long memoryAddr, final int count) { final long maxMemAddr = memoryAddr + count * WIDTH_ORDINAL; FieldVector inputVector = getInput(); final long incomingBit = inputVector.getValidityBufferAddress(); final long incomingValue = inputVector.getDataBufferAddress(); final long[] bitAddresses = this.bitAddresses; final long[] valueAddresses = this.valueAddresses; final int scale = ((DecimalVector)inputVector).getScale(); int incomingIndex = 0; for(long ordinalAddr = memoryAddr; ordinalAddr < maxMemAddr; ordinalAddr += WIDTH_ORDINAL, incomingIndex++){ java.math.BigDecimal newVal = DecimalAccumulatorUtilsNoSpill.getBigDecimal(incomingValue + (incomingIndex * WIDTH_INPUT), valBuf, scale); final int tableIndex = PlatformDependent.getInt(ordinalAddr); int chunkIndex = tableIndex >>> LBlockHashTableNoSpill.BITS_IN_CHUNK; int chunkOffset = tableIndex & LBlockHashTableNoSpill.CHUNK_OFFSET_MASK; final long maxAddr = valueAddresses[chunkIndex] + (chunkOffset) * WIDTH_ACCUMULATOR; final long bitUpdateAddr = bitAddresses[chunkIndex] + ((chunkOffset >>> 5) * 4); final int bitVal = (PlatformDependent.getByte(incomingBit + ((incomingIndex >>> 3))) >>> (incomingIndex & 7)) & 1; final int bitUpdateVal = bitVal << (chunkOffset & 31); PlatformDependent.putLong(maxAddr, Double.doubleToLongBits(max(Double.longBitsToDouble(PlatformDependent.getLong(maxAddr)), newVal.doubleValue(), bitVal))); PlatformDependent.putInt(bitUpdateAddr, PlatformDependent.getInt(bitUpdateAddr) | bitUpdateVal); } } }
int scale = ((DecimalVector) vector).getScale(); BigDecimal decimalValue = DecimalUtility.getBigDecimalFromArrowBuf(buffer, index, scale);
public void accumulate(final long memoryAddr, final int count) { final long maxAddr = memoryAddr + count * PARTITIONINDEX_HTORDINAL_WIDTH; FieldVector inputVector = getInput(); final long incomingBit = inputVector.getValidityBufferAddress(); final long incomingValue = inputVector.getDataBufferAddress(); final long[] valueAddresses = this.valueAddresses; final int scale = ((DecimalVector)inputVector).getScale(); final int maxValuesPerBatch = super.maxValuesPerBatch; for (long partitionAndOrdinalAddr = memoryAddr; partitionAndOrdinalAddr < maxAddr; partitionAndOrdinalAddr += PARTITIONINDEX_HTORDINAL_WIDTH) { /* get the hash table ordinal */ final int tableIndex = PlatformDependent.getInt(partitionAndOrdinalAddr + HTORDINAL_OFFSET); /* get the index of data in input vector */ final int incomingIndex = PlatformDependent.getInt(partitionAndOrdinalAddr + KEYINDEX_OFFSET); /* get the corresponding data from input vector -- source data for accumulation */ final int bitVal = (PlatformDependent.getByte(incomingBit + ((incomingIndex >>> 3))) >>> (incomingIndex & 7)) & 1; java.math.BigDecimal newVal = DecimalAccumulatorUtils.getBigDecimal(incomingValue + (incomingIndex * WIDTH_INPUT), valBuf, scale); /* get the hash table batch index */ final int chunkIndex = getChunkIndexForOrdinal(tableIndex, maxValuesPerBatch); final int chunkOffset = getOffsetInChunkForOrdinal(tableIndex, maxValuesPerBatch); /* get the target address of accumulation vector */ final long sumAddr = valueAddresses[chunkIndex] + (chunkOffset) * WIDTH_ACCUMULATOR; /* store the accumulated values at the target location of accumulation vector */ PlatformDependent.putLong(sumAddr, Double.doubleToLongBits(Double.longBitsToDouble(PlatformDependent.getLong(sumAddr)) + newVal.doubleValue() * bitVal)); } } }
public void accumulate(final long memoryAddr, final int count) { final long maxAddr = memoryAddr + count * PARTITIONINDEX_HTORDINAL_WIDTH; FieldVector inputVector = getInput(); final long incomingBit = inputVector.getValidityBufferAddress(); final long incomingValue = inputVector.getDataBufferAddress(); final long[] bitAddresses = this.bitAddresses; final long[] valueAddresses = this.valueAddresses; final int scale = ((DecimalVector) inputVector).getScale(); final int maxValuesPerBatch = super.maxValuesPerBatch; for (long partitionAndOrdinalAddr = memoryAddr; partitionAndOrdinalAddr < maxAddr; partitionAndOrdinalAddr += PARTITIONINDEX_HTORDINAL_WIDTH) { /* get the hash table ordinal */ final int tableIndex = PlatformDependent.getInt(partitionAndOrdinalAddr + HTORDINAL_OFFSET); /* get the index of data in input vector */ final int incomingIndex = PlatformDependent.getInt(partitionAndOrdinalAddr + KEYINDEX_OFFSET); /* get the corresponding data from input vector -- source data for accumulation */ final int bitVal = (PlatformDependent.getByte(incomingBit + ((incomingIndex >>> 3))) >>> (incomingIndex & 7)) & 1; java.math.BigDecimal newVal = DecimalAccumulatorUtils.getBigDecimal(incomingValue + (incomingIndex * WIDTH_INPUT), valBuf, scale); /* get the hash table batch index */ final int chunkIndex = getChunkIndexForOrdinal(tableIndex, maxValuesPerBatch); final int chunkOffset = getOffsetInChunkForOrdinal(tableIndex, maxValuesPerBatch); /* get the target addresses of accumulation vector */ final long sumAddr = valueAddresses[chunkIndex] + (chunkOffset) * WIDTH_ACCUMULATOR; final long bitUpdateAddr = bitAddresses[chunkIndex] + ((chunkOffset >>> 5) * 4); final int bitUpdateVal = bitVal << (chunkOffset & 31); /* store the accumulated values at the target location of accumulation vector */ PlatformDependent.putLong(sumAddr, Double.doubleToLongBits(Double.longBitsToDouble(PlatformDependent.getLong(sumAddr)) + newVal.doubleValue() * bitVal)); PlatformDependent.putInt(bitUpdateAddr, PlatformDependent.getInt(bitUpdateAddr) | bitUpdateVal); } } }
public void accumulate(final long memoryAddr, final int count) { final long maxMemAddr = memoryAddr + count * PARTITIONINDEX_HTORDINAL_WIDTH; FieldVector inputVector = getInput(); final long incomingBit = inputVector.getValidityBufferAddress(); final long incomingValue = inputVector.getDataBufferAddress(); final long[] bitAddresses = this.bitAddresses; final long[] valueAddresses = this.valueAddresses; final int scale = ((DecimalVector)inputVector).getScale(); final int maxValuesPerBatch = super.maxValuesPerBatch; for (long partitionAndOrdinalAddr = memoryAddr; partitionAndOrdinalAddr < maxMemAddr; partitionAndOrdinalAddr += PARTITIONINDEX_HTORDINAL_WIDTH) { /* get the hash table ordinal */ final int tableIndex = PlatformDependent.getInt(partitionAndOrdinalAddr + HTORDINAL_OFFSET); /* get the index of data in input vector */ final int incomingIndex = PlatformDependent.getInt(partitionAndOrdinalAddr + KEYINDEX_OFFSET); /* get the corresponding data from input vector -- source data for accumulation */ java.math.BigDecimal newVal = DecimalAccumulatorUtils.getBigDecimal(incomingValue + (incomingIndex * WIDTH_INPUT), valBuf, scale); final int bitVal = (PlatformDependent.getByte(incomingBit + ((incomingIndex >>> 3))) >>> (incomingIndex & 7)) & 1; /* get the hash table batch index */ final int chunkIndex = getChunkIndexForOrdinal(tableIndex, maxValuesPerBatch); final int chunkOffset = getOffsetInChunkForOrdinal(tableIndex, maxValuesPerBatch); /* get the target addresses of accumulation vector */ final long maxAddr = valueAddresses[chunkIndex] + (chunkOffset) * WIDTH_ACCUMULATOR; final long bitUpdateAddr = bitAddresses[chunkIndex] + ((chunkOffset >>> 5) * 4); final int bitUpdateVal = bitVal << (chunkOffset & 31); /* store the accumulated values(new max or existing) at the target location of accumulation vector */ PlatformDependent.putLong(maxAddr, Double.doubleToLongBits(max(Double.longBitsToDouble(PlatformDependent.getLong(maxAddr)), newVal.doubleValue(), bitVal))); PlatformDependent.putInt(bitUpdateAddr, PlatformDependent.getInt(bitUpdateAddr) | bitUpdateVal); } } }
public void accumulate(final long memoryAddr, final int count) { final long maxAddr = memoryAddr + count * PARTITIONINDEX_HTORDINAL_WIDTH; FieldVector inputVector = getInput(); final long incomingBit = inputVector.getValidityBufferAddress(); final long incomingValue = inputVector.getDataBufferAddress(); final long[] bitAddresses = this.bitAddresses; final long[] valueAddresses = this.valueAddresses; final int scale = ((DecimalVector)inputVector).getScale(); final int maxValuesPerBatch = super.maxValuesPerBatch; for (long partitionAndOrdinalAddr = memoryAddr; partitionAndOrdinalAddr < maxAddr; partitionAndOrdinalAddr += PARTITIONINDEX_HTORDINAL_WIDTH) { /* get the hash table ordinal */ final int tableIndex = PlatformDependent.getInt(partitionAndOrdinalAddr + HTORDINAL_OFFSET); /* get the index of data in input vector */ final int incomingIndex = PlatformDependent.getInt(partitionAndOrdinalAddr + KEYINDEX_OFFSET); /* get the corresponding data from input vector -- source data for accumulation */ java.math.BigDecimal newVal = DecimalAccumulatorUtils.getBigDecimal(incomingValue + (incomingIndex * WIDTH_INPUT), valBuf, scale); final int bitVal = (PlatformDependent.getByte(incomingBit + ((incomingIndex >>> 3))) >>> (incomingIndex & 7)) & 1; /* get the hash table batch index */ final int chunkIndex = getChunkIndexForOrdinal(tableIndex, maxValuesPerBatch); final int chunkOffset = getOffsetInChunkForOrdinal(tableIndex, maxValuesPerBatch); /* get the target addresses of accumulation vector */ final long minAddr = valueAddresses[chunkIndex] + (chunkOffset) * WIDTH_ACCUMULATOR; final long bitUpdateAddr = bitAddresses[chunkIndex] + ((chunkOffset >>> 5) * 4); final int bitUpdateVal = bitVal << (chunkOffset & 31); /* store the accumulated values(new min or existing) at the target location of accumulation vector */ PlatformDependent.putLong(minAddr, Double.doubleToLongBits(min(Double.longBitsToDouble(PlatformDependent.getLong(minAddr)), newVal.doubleValue(), bitVal))); PlatformDependent.putInt(bitUpdateAddr, PlatformDependent.getInt(bitUpdateAddr) | bitUpdateVal); } } }
BigDecimal bd = DecimalHelper.getBigDecimalFromSparse(newBuffer, startIndex, DrillBackwardsCompatibilityHandler.NUMBER_DECIMAL_DIGITS, decimalVector.getScale()); assertEquals(bd, decimal1); startIndex += DecimalVector.TYPE_WIDTH + 8; bd = DecimalHelper.getBigDecimalFromSparse(newBuffer, startIndex, DrillBackwardsCompatibilityHandler.NUMBER_DECIMAL_DIGITS, decimalVector.getScale()); assertEquals(bd, decimal2); startIndex += DecimalVector.TYPE_WIDTH + 8; bd = DecimalHelper.getBigDecimalFromSparse(newBuffer, startIndex, DrillBackwardsCompatibilityHandler.NUMBER_DECIMAL_DIGITS, decimalVector.getScale()); assertEquals(bd, decimal3); startIndex += DecimalVector.TYPE_WIDTH + 8; bd = DecimalHelper.getBigDecimalFromSparse(newBuffer, startIndex, DrillBackwardsCompatibilityHandler.NUMBER_DECIMAL_DIGITS, decimalVector.getScale()); assertEquals(bd, decimal4); startIndex += DecimalVector.TYPE_WIDTH + 8; bd = DecimalHelper.getBigDecimalFromSparse(newBuffer, startIndex, DrillBackwardsCompatibilityHandler.NUMBER_DECIMAL_DIGITS, decimalVector.getScale()); assertEquals(bd, decimal5); startIndex += DecimalVector.TYPE_WIDTH + 8; bd = DecimalHelper.getBigDecimalFromSparse(newBuffer, startIndex, DrillBackwardsCompatibilityHandler.NUMBER_DECIMAL_DIGITS, decimalVector.getScale()); assertEquals(bd, decimal6); startIndex += DecimalVector.TYPE_WIDTH + 8; bd = DecimalHelper.getBigDecimalFromSparse(newBuffer, startIndex, DrillBackwardsCompatibilityHandler.NUMBER_DECIMAL_DIGITS, decimalVector.getScale()); assertEquals(bd, decimal7); startIndex += DecimalVector.TYPE_WIDTH + 8; bd = DecimalHelper.getBigDecimalFromSparse(newBuffer, startIndex, DrillBackwardsCompatibilityHandler.NUMBER_DECIMAL_DIGITS, decimalVector.getScale());