use of org.apache.hadoop.hive.ql.exec.vector.ColumnVector in project hive by apache.
the class VectorBatchGenerator method assignColumnVectors.
public void assignColumnVectors(VectorizedRowBatch batch, int columnNum, VectorColumnGroupGenerator columnGroup) {
// UNDONE: Multiple types...
GenerateType[] generateTypes = columnGroup.generateTypes();
GenerateType generateType = generateTypes[0];
ColumnVector colVector;
switch(generateType.getCategory()) {
case BOOLEAN:
case BYTE:
case SHORT:
case INT:
case LONG:
colVector = new LongColumnVector();
break;
case FLOAT:
case DOUBLE:
colVector = new DoubleColumnVector();
break;
case STRING:
colVector = new BytesColumnVector();
break;
// UNDONE
case DATE:
case TIMESTAMP:
case BINARY:
case DECIMAL:
case VARCHAR:
case CHAR:
case LIST:
case MAP:
case STRUCT:
case UNION:
default:
throw new RuntimeException("Unsupported catagory " + generateType.getCategory());
}
colVector.init();
batch.cols[columnNum] = colVector;
}
use of org.apache.hadoop.hive.ql.exec.vector.ColumnVector in project hive by apache.
the class VectorColumnGroupGenerator method populateBatchColumn.
private void populateBatchColumn(VectorizedRowBatch batch, int logicalColumnIndex, int size) {
int columnNum = columnNums[logicalColumnIndex];
ColumnVector colVector = batch.cols[columnNum];
GenerateType generateType = generateTypes[logicalColumnIndex];
GenerateCategory category = generateType.getCategory();
Object array = arrays[logicalColumnIndex];
switch(category) {
case BOOLEAN:
{
boolean[] booleanArray = ((boolean[]) array);
long[] vector = ((LongColumnVector) colVector).vector;
for (int i = 0; i < size; i++) {
vector[i] = (booleanArray[i] ? 1 : 0);
}
}
break;
case BYTE:
{
byte[] byteArray = ((byte[]) array);
long[] vector = ((LongColumnVector) colVector).vector;
for (int i = 0; i < size; i++) {
vector[i] = byteArray[i];
}
}
break;
case SHORT:
{
short[] shortArray = ((short[]) array);
long[] vector = ((LongColumnVector) colVector).vector;
for (int i = 0; i < size; i++) {
vector[i] = shortArray[i];
}
}
break;
case INT:
{
int[] intArray = ((int[]) array);
long[] vector = ((LongColumnVector) colVector).vector;
for (int i = 0; i < size; i++) {
vector[i] = intArray[i];
}
}
break;
case LONG:
{
long[] longArray = ((long[]) array);
long[] vector = ((LongColumnVector) colVector).vector;
for (int i = 0; i < size; i++) {
vector[i] = longArray[i];
}
}
break;
case FLOAT:
{
float[] floatArray = ((float[]) array);
double[] vector = ((DoubleColumnVector) colVector).vector;
for (int i = 0; i < size; i++) {
vector[i] = floatArray[i];
}
}
break;
case DOUBLE:
{
double[] doubleArray = ((double[]) array);
double[] vector = ((DoubleColumnVector) colVector).vector;
for (int i = 0; i < size; i++) {
vector[i] = doubleArray[i];
}
}
break;
case STRING:
{
String[] stringArray = ((String[]) array);
BytesColumnVector bytesColVec = ((BytesColumnVector) colVector);
for (int i = 0; i < size; i++) {
byte[] bytes = stringArray[i].getBytes();
bytesColVec.setVal(i, bytes);
}
}
break;
case TIMESTAMP:
{
Timestamp[] timestampArray = ((Timestamp[]) array);
TimestampColumnVector timestampColVec = ((TimestampColumnVector) colVector);
for (int i = 0; i < size; i++) {
Timestamp timestamp = timestampArray[i];
timestampColVec.set(i, timestamp);
}
}
break;
case DATE:
case BINARY:
case DECIMAL:
case VARCHAR:
case CHAR:
case LIST:
case MAP:
case STRUCT:
case UNION:
default:
}
}
Aggregations