@Override public void eval() { out.buffer = buf; out.start = out.end = 0; out.buffer.setByte(0, in.value); ++out.end; } }
public void setType(int index, MinorType type) { while (index >= getTypeBufferValueCapacity()) { reallocTypeBuffer(); } typeBuffer.setByte(index * TYPE_WIDTH , (byte) type.ordinal()); }
@Override protected void _setByte(int index, int value) { setByte(index, value); }
private void setValue(int index, int value) { valueBuffer.setByte(index * TYPE_WIDTH, value); }
private void setValue(int index, int value) { valueBuffer.setByte(index * TYPE_WIDTH, value); }
private void setValue(int index, byte value) { valueBuffer.setByte(index * TYPE_WIDTH, value); }
private void setValue(int index, byte value) { valueBuffer.setByte(index * TYPE_WIDTH, value); }
@Override public void append(byte data) { if(!collect){ return; } expandTmpBufIfNecessary(); tmpBuf.setByte(charLengthOffset, data); charLengthOffset++; }
/** * Set the byte of the given index in the data buffer by applying a bit mask to * the current byte at that index. * * @param data buffer to set * @param byteIndex byteIndex within the buffer * @param bitMask bit mask to be set */ static void setBitMaskedByte(ArrowBuf data, int byteIndex, byte bitMask) { byte currentByte = data.getByte(byteIndex); currentByte |= bitMask; data.setByte(byteIndex, currentByte); } }
@Override public void eval() { out.buffer = buffer = buffer.reallocIfNeeded( (left.end - left.start) + (right.end - right.start)); out.start = out.end = 0; int id = 0; for (id = left.start; id < left.end; id++) { out.buffer.setByte(out.end++, left.buffer.getByte(id)); } for (id = right.start; id < right.end; id++) { out.buffer.setByte(out.end++, right.buffer.getByte(id)); } } }
@Override public void eval() { int size = 0; size += (arg1.end - arg1.start); size += (arg2.end - arg2.start); buffer = buffer.reallocIfNeeded(size); out.buffer = buffer; out.start = out.end = 0; out.isSet = 1; if (arg1.isSet == 1) { for (int id = arg1.start; id < arg1.end; id++) { out.buffer.setByte(out.end++, arg1.buffer.getByte(id)); } } if (arg2.isSet == 1) { for (int id = arg2.start; id < arg2.end; id++) { out.buffer.setByte(out.end++, arg2.buffer.getByte(id)); } } } }
@Override public void eval() { out.buffer = buffer = buffer.reallocIfNeeded(input.end- input.start); out.start = 0; out.end = input.end - input.start; for (int id = input.start; id < input.end; id++) { byte currentByte = input.buffer.getByte(id); // 'A - Z' : 0x41 - 0x5A // 'a - z' : 0x61 - 0x7A if (currentByte >= 0x41 && currentByte <= 0x5A) { currentByte += 0x20; } out.buffer.setByte(id - input.start, currentByte) ; } } }
@Override public void eval() { out.buffer = buffer = buffer.reallocIfNeeded(input.end- input.start); out.start = 0; out.end = input.end - input.start; for (int id = input.start; id < input.end; id++) { byte currentByte = input.buffer.getByte(id); // 'A - Z' : 0x41 - 0x5A // 'a - z' : 0x61 - 0x7A if (currentByte >= 0x61 && currentByte <= 0x7A) { currentByte -= 0x20; } out.buffer.setByte(id - input.start, currentByte) ; } } }
/** * swap the bytes in place to get the BE byte order in NullableDecimalVector * @param dataBuffer data buffer of decimal vector */ static void patchDecimal(final ArrowBuf dataBuffer) { final int decimalLength = DecimalVector.TYPE_WIDTH; int startPoint = dataBuffer.readerIndex(); final int valueCount = dataBuffer.readableBytes()/decimalLength; for (int i = 0; i < valueCount; i++) { for (int j = startPoint, k = startPoint + decimalLength - 1; j < k; j++, k--) { final byte firstByte = dataBuffer.getByte(j); final byte lastByte = dataBuffer.getByte(k); dataBuffer.setByte(j, lastByte); dataBuffer.setByte(k, firstByte); } startPoint += decimalLength; } }
public void copyFrom(int fromIndex, int thisIndex, UInt1Vector from) { BitVectorHelper.setValidityBit(validityBuffer, thisIndex, from.isSet(fromIndex)); final byte value = from.valueBuffer.getByte(fromIndex * TYPE_WIDTH); valueBuffer.setByte(thisIndex * TYPE_WIDTH, value); }
/** * Copy a cell value from a particular index in source vector to a particular * position in this vector. * * @param fromIndex position to copy from in source vector * @param thisIndex position to copy to in this vector * @param from source vector */ public void copyFrom(int fromIndex, int thisIndex, TinyIntVector from) { BitVectorHelper.setValidityBit(validityBuffer, thisIndex, from.isSet(fromIndex)); final byte value = from.valueBuffer.getByte(fromIndex * TYPE_WIDTH); valueBuffer.setByte(thisIndex * TYPE_WIDTH, value); }
/** * Set the bit at provided index to 1. * * @param validityBuffer validity buffer of the vector * @param index index to be set */ public static void setValidityBitToOne(ArrowBuf validityBuffer, int index) { final int byteIndex = byteIndex(index); final int bitIndex = bitIndex(index); byte currentByte = validityBuffer.getByte(byteIndex); final byte bitMask = (byte) (1L << bitIndex); currentByte |= bitMask; validityBuffer.setByte(byteIndex, currentByte); }
@Override public void eval() { final int len = in.end - in.start; out.start = 0; out.end = len; out.buffer = buffer = buffer.reallocIfNeeded(len); int charlen = 0; int index = in.end; int innerindex = 0; for (int id = in.start; id < in.end; id += charlen) { innerindex = charlen = com.dremio.exec.expr.fn.impl.StringFunctionUtil.utf8CharLen(in.buffer, id, errCtx); while (innerindex > 0) { out.buffer.setByte(index - innerindex, in.buffer.getByte(id + (charlen - innerindex))); innerindex-- ; } index -= charlen; } } }
/** * Set the bit at a given index to provided value (1 or 0). * * @param validityBuffer validity buffer of the vector * @param index index to be set * @param value value to set */ public static void setValidityBit(ArrowBuf validityBuffer, int index, int value) { final int byteIndex = byteIndex(index); final int bitIndex = bitIndex(index); byte currentByte = validityBuffer.getByte(byteIndex); final byte bitMask = (byte) (1L << bitIndex); if (value != 0) { currentByte |= bitMask; } else { currentByte -= (bitMask & currentByte); } validityBuffer.setByte(byteIndex, currentByte); }
@Override public void eval() { out.buffer = buffer.reallocIfNeeded(input.end - input.start); buffer = out.buffer; out.start = 0; out.end = input.end - input.start; for (int id = input.start; id < input.end; id++) { byte currentByte = input.buffer.getByte(id); // 'A - Z' : 0x41 - 0x5A // 'a - z' : 0x61 - 0x7A // space : 0x20 if (currentByte >= 0x61 && currentByte <= 0x7A && (id == input.start || input.buffer.getByte(id - 1) == 0x20)) { currentByte -= 0x20; } if (currentByte >= 0x41 && currentByte <= 0x5A && !(id == input.start || input.buffer.getByte(id - 1) == 0x20)) { currentByte += 0x20; } out.buffer.setByte(id - input.start, currentByte); } } }