Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -909,52 +909,6 @@ protected final void handleSafe(int index, int dataLength) {
}
}


/******************************************************************
* *
* helper methods currently *
* used by JsonFileReader and *
* JsonFileWriter *
* *
******************************************************************/


/**
* Method used by Json Reader to explicitly set the data of the variable
* width vector elements. The method takes care of allocating the memory
* for the vector if caller hasn't done so.
*
* This method should not be used externally.
*
* @param data ArrowBuf for storing variable width elements in the vector
* @param offset offset of the element
* @param allocator memory allocator
* @param index position of the element in the vector
* @param value array of bytes for the element
* @param valueCount number of elements in the vector
* @return buffer holding the variable width data.
*/
public static ArrowBuf set(ArrowBuf data, ArrowBuf offset,
BufferAllocator allocator, int index, byte[] value,
int valueCount) {
if (data == null) {
data = allocator.buffer(INITIAL_BYTE_COUNT);
}
final int currentBufferCapacity = data.capacity();
final int currentStartOffset = offset.getInt(index * OFFSET_WIDTH);
while (currentBufferCapacity < currentStartOffset + value.length) {
final ArrowBuf newBuf = allocator.buffer(currentBufferCapacity * 2);
newBuf.setBytes(0, data, 0, currentBufferCapacity);
data.release();
data = newBuf;
}
data.setBytes(currentStartOffset, value, 0, value.length);
if (index == (valueCount - 1)) {
data.writerIndex(offset.getInt(valueCount * OFFSET_WIDTH));
}
return data;
}

/**
* Method used by Json Writer to read a variable width element from
* the variable width vector and write to Json.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* maintained to track which elements in the vector are null.
*/
public class NullableBigIntVector extends BaseNullableFixedWidthVector {
private static final byte TYPE_WIDTH = 8;
public static final byte TYPE_WIDTH = 8;
private final FieldReader reader;

/**
Expand Down Expand Up @@ -290,41 +290,6 @@ public void setSafe(int index, int isSet, long value) {
set(index, isSet, value);
}


/******************************************************************
* *
* helper routines currently *
* used in JsonFileReader and JsonFileWriter *
* *
******************************************************************/


/**
* Given a data buffer, this method sets the element value at a particular
* position. Reallocates the buffer if needed.
*
* This method should not be used externally.
*
* @param buffer data buffer
* @param allocator allocator
* @param valueCount number of elements in the vector
* @param index position of the new element
* @param value element value
* @return data buffer
*/
public static ArrowBuf set(ArrowBuf buffer, BufferAllocator allocator,
int valueCount, int index, long value) {
if (buffer == null) {
buffer = allocator.buffer(valueCount * TYPE_WIDTH);
}
buffer.setLong(index * TYPE_WIDTH, value);
if (index == (valueCount - 1)) {
buffer.writerIndex(valueCount * TYPE_WIDTH);
}

return buffer;
}

/**
* Given a data buffer, get the value stored at a particular position
* in the vector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,40 +292,6 @@ public void setSafe(int index, int isSet, int value) {
set(index, isSet, value);
}

/******************************************************************
* *
* helper routines currently *
* used in JsonFileReader *
* *
******************************************************************/


/**
* Given a data buffer, this method sets the element value at a particular
* position. Reallocates the buffer if needed.
*
* This method should not be used externally.
*
* @param buffer data buffer
* @param allocator allocator
* @param valueCount number of elements in the vector
* @param index position of the new element
* @param value element value
* @return data buffer
*/
public static ArrowBuf set(ArrowBuf buffer, BufferAllocator allocator,
int valueCount, int index, int value) {
if (buffer == null) {
buffer = allocator.buffer(valueCount * TYPE_WIDTH);
}
buffer.setInt(index * TYPE_WIDTH, value);
if (index == (valueCount - 1)) {
buffer.writerIndex(valueCount * TYPE_WIDTH);
}

return buffer;
}

/**
* Given a data buffer, get the value stored at a particular position
* in the vector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,40 +296,6 @@ public void setSafe(int index, int isSet, long value) {
set(index, isSet, value);
}

/******************************************************************
* *
* helper routines currently *
* used in JsonFileReader *
* *
******************************************************************/


/**
* Given a data buffer, this method sets the element value at a particular
* position. Reallocates the buffer if needed.
*
* This method should not be used externally.
*
* @param buffer data buffer
* @param allocator allocator
* @param valueCount number of elements in the vector
* @param index position of the new element
* @param value element value
* @return data buffer
*/
public static ArrowBuf set(ArrowBuf buffer, BufferAllocator allocator,
int valueCount, int index, long value) {
if (buffer == null) {
buffer = allocator.buffer(valueCount * TYPE_WIDTH);
}
buffer.setLong(index * TYPE_WIDTH, value);
if (index == (valueCount - 1)) {
buffer.writerIndex(valueCount * TYPE_WIDTH);
}

return buffer;
}

/**
* Given a data buffer, get the value stored at a particular position
* in the vector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* maintained to track which elements in the vector are null.
*/
public class NullableDecimalVector extends BaseNullableFixedWidthVector {
private static final byte TYPE_WIDTH = 16;
public static final byte TYPE_WIDTH = 16;
private final FieldReader reader;

private final int precision;
Expand Down Expand Up @@ -355,41 +355,6 @@ public void setSafe(int index, int isSet, int start, ArrowBuf buffer) {
}


/******************************************************************
* *
* helper routines currently *
* used in JsonFileReader *
* *
******************************************************************/


/**
* Given a data buffer, this method sets the element value at a particular
* position. Reallocates the buffer if needed.
*
* This method should not be used externally.
*
* @param buffer data buffer
* @param allocator allocator
* @param valueCount number of elements in the vector
* @param index position of the new element
* @param value element value as array of bytes
* @return data buffer
*/
public static ArrowBuf set(ArrowBuf buffer, BufferAllocator allocator,
int valueCount, int index, byte[] value) {
if (buffer == null) {
buffer = allocator.buffer(valueCount * TYPE_WIDTH);
}
DecimalUtility.writeByteArrayToArrowBuf(value, buffer, index);
if (index == (valueCount - 1)) {
buffer.writerIndex(valueCount * TYPE_WIDTH);
}

return buffer;
}


/******************************************************************
* *
* vector transfer *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* maintained to track which elements in the vector are null.
*/
public class NullableFloat4Vector extends BaseNullableFixedWidthVector {
private static final byte TYPE_WIDTH = 4;
public static final byte TYPE_WIDTH = 4;
private final FieldReader reader;

/**
Expand Down Expand Up @@ -291,41 +291,6 @@ public void setSafe(int index, int isSet, float value) {
set(index, isSet, value);
}


/******************************************************************
* *
* helper routines currently *
* used in JsonFileReader and JsonFileWriter *
* *
******************************************************************/


/**
* Given a data buffer, this method sets the element value at a particular
* position. Reallocates the buffer if needed.
*
* This method should not be used externally.
*
* @param buffer data buffer
* @param allocator allocator
* @param valueCount number of elements in the vector
* @param index position of the new element
* @param value element value
* @return data buffer
*/
public static ArrowBuf set(ArrowBuf buffer, BufferAllocator allocator,
int valueCount, int index, float value) {
if (buffer == null) {
buffer = allocator.buffer(valueCount * TYPE_WIDTH);
}
buffer.setFloat(index * TYPE_WIDTH, value);
if (index == (valueCount - 1)) {
buffer.writerIndex(valueCount * TYPE_WIDTH);
}

return buffer;
}

/**
* Given a data buffer, get the value stored at a particular position
* in the vector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* maintained to track which elements in the vector are null.
*/
public class NullableFloat8Vector extends BaseNullableFixedWidthVector {
private static final byte TYPE_WIDTH = 8;
public static final byte TYPE_WIDTH = 8;
private final FieldReader reader;

/**
Expand Down Expand Up @@ -291,41 +291,6 @@ public void setSafe(int index, int isSet, double value) {
set(index, isSet, value);
}


/******************************************************************
* *
* helper routines currently *
* used in JsonFileReader and JsonFileWriter *
* *
******************************************************************/


/**
* Given a data buffer, this method sets the element value at a particular
* position. Reallocates the buffer if needed.
*
* This method should not be used externally.
*
* @param buffer data buffer
* @param allocator allocator
* @param valueCount number of elements in the vector
* @param index position of the new element
* @param value element value
* @return data buffer
*/
public static ArrowBuf set(ArrowBuf buffer, BufferAllocator allocator,
int valueCount, int index, double value) {
if (buffer == null) {
buffer = allocator.buffer(valueCount * TYPE_WIDTH);
}
buffer.setDouble(index * TYPE_WIDTH, value);
if (index == (valueCount - 1)) {
buffer.writerIndex(valueCount * TYPE_WIDTH);
}

return buffer;
}

/**
* Given a data buffer, get the value stored at a particular position
* in the vector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* maintained to track which elements in the vector are null.
*/
public class NullableIntVector extends BaseNullableFixedWidthVector {
private static final byte TYPE_WIDTH = 4;
public static final byte TYPE_WIDTH = 4;
private final FieldReader reader;

/**
Expand Down Expand Up @@ -291,40 +291,6 @@ public void setSafe(int index, int isSet, int value) {
set(index, isSet, value);
}

/******************************************************************
* *
* helper routines currently *
* used in JsonFileReader and JsonFileWriter *
* *
******************************************************************/


/**
* Given a data buffer, this method sets the element value at a particular
* position. Reallocates the buffer if needed.
*
* This method should not be used externally.
*
* @param buffer data buffer
* @param allocator allocator
* @param valueCount number of elements in the vector
* @param index position of the new element
* @param value element value
* @return data buffer
*/
public static ArrowBuf set(ArrowBuf buffer, BufferAllocator allocator,
int valueCount, int index, int value) {
if (buffer == null) {
buffer = allocator.buffer(valueCount * TYPE_WIDTH);
}
buffer.setInt(index * TYPE_WIDTH, value);
if (index == (valueCount - 1)) {
buffer.writerIndex(valueCount * TYPE_WIDTH);
}

return buffer;
}

/**
* Given a data buffer, get the value stored at a particular position
* in the vector.
Expand Down
Loading