private int getBit(int index) { final int byteIndex = index >> 3; final byte b = valueBuffer.getByte(byteIndex); final int bitIndex = index & 7; return (b >> bitIndex) & 0x01; }
public int isSet(int index) { final int byteIndex = index >> 3; final byte b = validityBuffer.getByte(byteIndex); final int bitIndex = index & 7; return (b >> bitIndex) & 0x01; }
/** * Same as {@link #isNull(int)}. * * @param index position of element * @return 1 if element at given index is not null, 0 otherwise */ public int isSet(int index) { final int byteIndex = index >> 3; final byte b = validityBuffer.getByte(byteIndex); final int bitIndex = index & 7; return (b >> bitIndex) & 0x01; }
@Override public void eval() { out.value = in.buffer.getByte(in.start); } }
public int isSet(int index) { final int byteIndex = index >> 3; final byte b = validityBuffer.getByte(byteIndex); final int bitIndex = index & 7; return (b >> bitIndex) & 0x01; }
/** * Same as {@link #isNull(int)}. * * @param index position of element * @return 1 if element at given index is not null, 0 otherwise */ public int isSet(int index) { final int byteIndex = index >> 3; final byte b = validityBuffer.getByte(byteIndex); final int bitIndex = index & 7; return (b >> bitIndex) & 0x01; }
/** * Given a data buffer, get the value stored at a particular position * in the vector. * * <p>This method should not be used externally. * * @param buffer data buffer * @param index position of the element. * @return value stored at the index. */ public static byte get(final ArrowBuf buffer, final int index) { return buffer.getByte(index * TYPE_WIDTH); }
/** * Same as {@link #isNull(int)}. * * @param index position of element * @return 1 if element at given index is not null, 0 otherwise */ public int isSet(int index) { final int byteIndex = index >> 3; final byte b = validityBuffer.getByte(byteIndex); final int bitIndex = index & 7; return (b >> bitIndex) & 0x01; }
@Override public void eval() { out.buffer = text.buffer; out.start = out.end = text.end; //Scan from left of "text", stop until find a char not " " for (int id = text.start; id < text.end; ++id) { if (text.buffer.getByte(id) != spaceInByte) { // Found the 1st char not " ", stop out.start = id; break; } } } // end of eval }
/** * Check if a bit at a given index is set or not. * * @param buffer buffer to check * @param index index of the buffer * @return 1 if bit is set, 0 otherwise. */ public static int get(final ArrowBuf buffer, int index) { final int byteIndex = index >> 3; final byte b = buffer.getByte(byteIndex); final int bitIndex = index & 7; return (b >> bitIndex) & 0x01; }
@Override public char charAt(int index) { if (usAscii) { // Each byte is a char, the index is relative to the start of the original buffer return (char) (buffer.getByte(start + index) & 0x00FF); } else { // The char buffer is a copy so the index directly corresponds return charBuffer.charAt(index); } }
public static String toBinaryStringNoFormat(ArrowBuf buf, int strStart, int strEnd) { StringBuilder result = new StringBuilder(); for (int i = strStart; i < strEnd ; ++i) { appendByteNoFormat(result, buf.getByte(i)); } return result.toString(); }
/** * Get the element at the given index from the vector. * * @param index position of element * @return element at given index */ public byte get(int index) throws IllegalStateException { if (isSet(index) == 0) { throw new IllegalStateException("Value at index is null"); } return valueBuffer.getByte(index * TYPE_WIDTH); }
@Override public int read() { if (pos == total) { return -1; // EOF } int res = current.getByte((int) (pos % size)) & 0xff; pos++; //move read index if ((pos % size) == 0) { current = fetchCurrentBlock(); } return res; }
/** * Get the element at the given index from the vector. * * @param index position of element * @return element at given index */ public byte get(int index) throws IllegalStateException { if (isSet(index) == 0) { throw new IllegalStateException("Value at index is null"); } return valueBuffer.getByte(index * TYPE_WIDTH); }
/** * Same as {@link #get(int)}. * * @param index position of element * @return element at given index */ public Byte getObject(int index) { if (isSet(index) == 0) { return null; } else { return valueBuffer.getByte(index * TYPE_WIDTH); } }
@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)); } } }
/** * 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); }
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); }