use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class VectorPTFEvaluatorLongLastValue method evaluateGroupBatch.
public void evaluateGroupBatch(VectorizedRowBatch batch, boolean isLastGroupBatch) {
evaluateInputExpr(batch);
// Last row of last batch determines isGroupResultNull and long lastValue.
// We do not filter when PTF is in reducer.
Preconditions.checkState(!batch.selectedInUse);
if (!isLastGroupBatch) {
return;
}
final int size = batch.size;
if (size == 0) {
return;
}
LongColumnVector longColVector = ((LongColumnVector) batch.cols[inputColumnNum]);
if (longColVector.isRepeating) {
if (longColVector.noNulls || !longColVector.isNull[0]) {
lastValue = longColVector.vector[0];
isGroupResultNull = false;
} else {
isGroupResultNull = true;
}
} else if (longColVector.noNulls) {
lastValue = longColVector.vector[size - 1];
isGroupResultNull = false;
} else {
final int lastBatchIndex = size - 1;
if (!longColVector.isNull[lastBatchIndex]) {
lastValue = longColVector.vector[lastBatchIndex];
isGroupResultNull = false;
} else {
isGroupResultNull = true;
}
}
}
use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class VectorPTFEvaluatorRowNumber method evaluateGroupBatch.
public void evaluateGroupBatch(VectorizedRowBatch batch, boolean isLastGroupBatch) {
evaluateInputExpr(batch);
final int size = batch.size;
LongColumnVector longColVector = (LongColumnVector) batch.cols[outputColumnNum];
long[] vector = longColVector.vector;
for (int i = 0; i < size; i++) {
vector[i] = rowNumber++;
}
}
use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class VectorizedListColumnReader method fillColumnVector.
private void fillColumnVector(PrimitiveObjectInspector.PrimitiveCategory category, ListColumnVector lcv, List valueList, int elementNum) {
int total = valueList.size();
setChildrenInfo(lcv, total, elementNum);
switch(category) {
case BOOLEAN:
lcv.child = new LongColumnVector(total);
for (int i = 0; i < valueList.size(); i++) {
((LongColumnVector) lcv.child).vector[i] = ((List<Integer>) valueList).get(i);
}
break;
case INT:
case BYTE:
case SHORT:
case DATE:
case INTERVAL_YEAR_MONTH:
case LONG:
lcv.child = new LongColumnVector(total);
for (int i = 0; i < valueList.size(); i++) {
((LongColumnVector) lcv.child).vector[i] = ((List<Long>) valueList).get(i);
}
break;
case DOUBLE:
lcv.child = new DoubleColumnVector(total);
for (int i = 0; i < valueList.size(); i++) {
((DoubleColumnVector) lcv.child).vector[i] = ((List<Double>) valueList).get(i);
}
break;
case BINARY:
case STRING:
case CHAR:
case VARCHAR:
lcv.child = new BytesColumnVector(total);
lcv.child.init();
for (int i = 0; i < valueList.size(); i++) {
byte[] src = ((List<byte[]>) valueList).get(i);
((BytesColumnVector) lcv.child).setRef(i, src, 0, src.length);
}
break;
case FLOAT:
lcv.child = new DoubleColumnVector(total);
for (int i = 0; i < valueList.size(); i++) {
((DoubleColumnVector) lcv.child).vector[i] = ((List<Float>) valueList).get(i);
}
break;
case DECIMAL:
decimalTypeCheck(type);
int precision = type.asPrimitiveType().getDecimalMetadata().getPrecision();
int scale = type.asPrimitiveType().getDecimalMetadata().getScale();
lcv.child = new DecimalColumnVector(total, precision, scale);
for (int i = 0; i < valueList.size(); i++) {
((DecimalColumnVector) lcv.child).vector[i].set(((List<byte[]>) valueList).get(i), scale);
}
break;
case INTERVAL_DAY_TIME:
case TIMESTAMP:
default:
throw new RuntimeException("Unsupported type in the list: " + type);
}
}
use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class VectorizedPrimitiveColumnReader method decodeDictionaryIds.
/**
* Reads `num` values into column, decoding the values from `dictionaryIds` and `dictionary`.
*/
private void decodeDictionaryIds(int rowId, int num, ColumnVector column, TypeInfo columnType, LongColumnVector dictionaryIds) {
System.arraycopy(dictionaryIds.isNull, rowId, column.isNull, rowId, num);
if (column.noNulls) {
column.noNulls = dictionaryIds.noNulls;
}
column.isRepeating = column.isRepeating && dictionaryIds.isRepeating;
PrimitiveTypeInfo primitiveColumnType = (PrimitiveTypeInfo) columnType;
switch(primitiveColumnType.getPrimitiveCategory()) {
case INT:
case BYTE:
case SHORT:
for (int i = rowId; i < rowId + num; ++i) {
((LongColumnVector) column).vector[i] = dictionary.readInteger((int) dictionaryIds.vector[i]);
if (!(dictionary.isValid(((LongColumnVector) column).vector[i]))) {
setNullValue(column, i);
((LongColumnVector) column).vector[i] = 0;
}
}
break;
case DATE:
case INTERVAL_YEAR_MONTH:
case LONG:
for (int i = rowId; i < rowId + num; ++i) {
((LongColumnVector) column).vector[i] = dictionary.readLong((int) dictionaryIds.vector[i]);
}
break;
case BOOLEAN:
for (int i = rowId; i < rowId + num; ++i) {
((LongColumnVector) column).vector[i] = dictionary.readBoolean((int) dictionaryIds.vector[i]) ? 1 : 0;
}
break;
case DOUBLE:
for (int i = rowId; i < rowId + num; ++i) {
((DoubleColumnVector) column).vector[i] = dictionary.readDouble((int) dictionaryIds.vector[i]);
}
break;
case BINARY:
for (int i = rowId; i < rowId + num; ++i) {
((BytesColumnVector) column).setVal(i, dictionary.readBytes((int) dictionaryIds.vector[i]));
}
break;
case STRING:
for (int i = rowId; i < rowId + num; ++i) {
((BytesColumnVector) column).setVal(i, dictionary.readString((int) dictionaryIds.vector[i]));
}
break;
case VARCHAR:
for (int i = rowId; i < rowId + num; ++i) {
((BytesColumnVector) column).setVal(i, dictionary.readVarchar((int) dictionaryIds.vector[i]));
}
break;
case CHAR:
for (int i = rowId; i < rowId + num; ++i) {
((BytesColumnVector) column).setVal(i, dictionary.readChar((int) dictionaryIds.vector[i]));
}
break;
case FLOAT:
for (int i = rowId; i < rowId + num; ++i) {
((DoubleColumnVector) column).vector[i] = dictionary.readFloat((int) dictionaryIds.vector[i]);
}
break;
case DECIMAL:
decimalTypeCheck(type);
DecimalColumnVector decimalColumnVector = ((DecimalColumnVector) column);
decimalColumnVector.precision = (short) type.asPrimitiveType().getDecimalMetadata().getPrecision();
decimalColumnVector.scale = (short) type.asPrimitiveType().getDecimalMetadata().getScale();
for (int i = rowId; i < rowId + num; ++i) {
decimalColumnVector.vector[i].set(dictionary.readDecimal((int) dictionaryIds.vector[i]), decimalColumnVector.scale);
}
break;
case TIMESTAMP:
for (int i = rowId; i < rowId + num; ++i) {
((TimestampColumnVector) column).set(i, dictionary.readTimestamp((int) dictionaryIds.vector[i]));
}
break;
case INTERVAL_DAY_TIME:
default:
throw new UnsupportedOperationException("Unsupported type: " + type);
}
}
use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class VectorizedPrimitiveColumnReader method readBatch.
@Override
public void readBatch(int total, ColumnVector column, TypeInfo columnType) throws IOException {
int rowId = 0;
while (total > 0) {
// Compute the number of values we want to read in this page.
int leftInPage = (int) (endOfPageValueCount - valuesRead);
if (leftInPage == 0) {
readPage();
leftInPage = (int) (endOfPageValueCount - valuesRead);
}
int num = Math.min(total, leftInPage);
if (isCurrentPageDictionaryEncoded) {
LongColumnVector dictionaryIds = new LongColumnVector();
// Read and decode dictionary ids.
readDictionaryIDs(num, dictionaryIds, rowId);
decodeDictionaryIds(rowId, num, column, columnType, dictionaryIds);
} else {
// assign values in vector
readBatchHelper(num, column, columnType, rowId);
}
rowId += num;
total -= num;
}
}
Aggregations