use of org.apache.hadoop.hive.ql.exec.vector.ColumnVector in project hive by apache.
the class IfExprColumnNull method evaluate.
@Override
public void evaluate(VectorizedRowBatch batch) {
if (childExpressions != null) {
super.evaluateChildren(batch);
}
final LongColumnVector arg1ColVector = (LongColumnVector) batch.cols[arg1Column];
final ColumnVector arg2ColVector = batch.cols[arg2Column];
final ColumnVector outputColVector = batch.cols[outputColumnNum];
final int[] sel = batch.selected;
final int n = batch.size;
final boolean[] null1 = arg1ColVector.isNull;
final long[] vector1 = arg1ColVector.vector;
final boolean[] isNull = outputColVector.isNull;
if (n == 0) {
return;
}
// We do not need to do a column reset since we are carefully changing the output.
outputColVector.isRepeating = false;
/*
* Repeating IF expression?
*/
if (arg1ColVector.isRepeating) {
if ((arg1ColVector.noNulls || !null1[0]) && vector1[0] == 1) {
arg2ColVector.copySelected(batch.selectedInUse, sel, n, outputColVector);
} else {
outputColVector.isRepeating = true;
outputColVector.noNulls = false;
isNull[0] = true;
}
return;
}
if (arg1ColVector.noNulls) {
/*
* Repeating THEN expression?
*/
if (arg2ColVector.isRepeating) {
if (batch.selectedInUse) {
for (int j = 0; j < n; j++) {
int i = sel[j];
if (vector1[i] == 1) {
isNull[i] = false;
// Assign repeated value (index 0) over and over.
outputColVector.setElement(i, 0, arg2ColVector);
} else {
isNull[i] = true;
outputColVector.noNulls = false;
}
}
} else {
for (int i = 0; i < n; i++) {
if (vector1[i] == 1) {
isNull[i] = false;
// Assign repeated value (index 0) over and over.
outputColVector.setElement(i, 0, arg2ColVector);
} else {
isNull[i] = true;
outputColVector.noNulls = false;
}
}
}
} else {
if (batch.selectedInUse) {
for (int j = 0; j < n; j++) {
int i = sel[j];
if (vector1[i] == 1) {
isNull[i] = false;
outputColVector.setElement(i, i, arg2ColVector);
} else {
isNull[i] = true;
outputColVector.noNulls = false;
}
}
} else {
for (int i = 0; i < n; i++) {
if (vector1[i] == 1) {
isNull[i] = false;
outputColVector.setElement(i, i, arg2ColVector);
} else {
isNull[i] = true;
outputColVector.noNulls = false;
}
}
}
}
} else /* there are nulls in the inputColVector */
{
/*
* Repeating THEN expression?
*/
if (arg2ColVector.isRepeating) {
if (batch.selectedInUse) {
for (int j = 0; j < n; j++) {
int i = sel[j];
if (!null1[i] && vector1[i] == 1) {
isNull[i] = false;
outputColVector.setElement(i, 0, arg2ColVector);
} else {
isNull[i] = true;
outputColVector.noNulls = false;
}
}
} else {
for (int i = 0; i < n; i++) {
if (!null1[i] && vector1[i] == 1) {
isNull[i] = false;
outputColVector.setElement(i, 0, arg2ColVector);
} else {
isNull[i] = true;
outputColVector.noNulls = false;
}
}
}
} else {
if (batch.selectedInUse) {
for (int j = 0; j < n; j++) {
int i = sel[j];
if (!null1[i] && vector1[i] == 1) {
isNull[i] = false;
outputColVector.setElement(i, i, arg2ColVector);
} else {
isNull[i] = true;
outputColVector.noNulls = false;
}
}
} else {
for (int i = 0; i < n; i++) {
if (!null1[i] && vector1[i] == 1) {
isNull[i] = false;
outputColVector.setElement(i, i, arg2ColVector);
} else {
isNull[i] = true;
outputColVector.noNulls = false;
}
}
}
}
}
}
use of org.apache.hadoop.hive.ql.exec.vector.ColumnVector in project hive by apache.
the class IfExprCondExprColumn method evaluate.
@Override
public void evaluate(VectorizedRowBatch batch) {
int n = batch.size;
if (n <= 0) {
// Nothing to do
return;
}
/*
* Do common analysis of the IF statement boolean expression.
*
* The following protected members can be examined afterwards:
*
* boolean isIfStatementResultRepeated
* boolean isIfStatementResultThen
*
* int thenSelectedCount
* int[] thenSelected
* int elseSelectedCount
* int[] elseSelected
*/
super.evaluate(batch);
ColumnVector outputColVector = batch.cols[outputColumnNum];
boolean[] outputIsNull = outputColVector.isNull;
// We do not need to do a column reset since we are carefully changing the output.
outputColVector.isRepeating = false;
// CONSIDER: Should be do this for all vector expressions that can
// work on BytesColumnVector output columns???
outputColVector.init();
ColumnVector thenColVector = batch.cols[arg2Column];
ColumnVector elseColVector = batch.cols[arg3Column];
final int thenCount = thenSelectedCount;
final int elseCount = elseSelectedCount;
if (isIfStatementResultRepeated) {
if (isIfStatementResultThen) {
// Evaluate THEN expression (only) and copy all its results.
childExpressions[1].evaluate(batch);
thenColVector.copySelected(batch.selectedInUse, batch.selected, n, outputColVector);
} else {
// Evaluate ELSE expression (only) and copy all its results.
childExpressions[2].evaluate(batch);
elseColVector.copySelected(batch.selectedInUse, batch.selected, n, outputColVector);
}
return;
}
// NOTE: We cannot use copySelected below since it is a whole column operation.
conditionalEvaluate(batch, childExpressions[1], thenSelected, thenCount);
for (int i = 0; i < thenCount; i++) {
final int batchIndex = thenSelected[i];
outputIsNull[batchIndex] = false;
outputColVector.setElement(batchIndex, batchIndex, thenColVector);
}
// The ELSE expression is either IdentityExpression (a column) or a ConstantVectorExpression
// (a scalar) and trivial to evaluate.
childExpressions[2].evaluate(batch);
for (int i = 0; i < elseCount; i++) {
final int batchIndex = elseSelected[i];
outputIsNull[batchIndex] = false;
outputColVector.setElement(batchIndex, batchIndex, elseColVector);
}
}
use of org.apache.hadoop.hive.ql.exec.vector.ColumnVector in project hive by apache.
the class IfExprCondExprCondExpr method evaluate.
@Override
public void evaluate(VectorizedRowBatch batch) {
int n = batch.size;
if (n <= 0) {
// Nothing to do
return;
}
/*
* Do common analysis of the IF statement boolean expression.
*
* The following protected members can be examined afterwards:
*
* boolean isIfStatementResultRepeated
* boolean isIfStatementResultThen
*
* int thenSelectedCount
* int[] thenSelected
* int elseSelectedCount
* int[] elseSelected
*/
super.evaluate(batch);
ColumnVector outputColVector = batch.cols[outputColumnNum];
boolean[] outputIsNull = outputColVector.isNull;
// We do not need to do a column reset since we are carefully changing the output.
outputColVector.isRepeating = false;
// CONSIDER: Should be do this for all vector expressions that can
// work on BytesColumnVector output columns???
outputColVector.init();
ColumnVector thenColVector = batch.cols[arg2Column];
ColumnVector elseColVector = batch.cols[arg3Column];
final int thenCount = thenSelectedCount;
final int elseCount = elseSelectedCount;
if (isIfStatementResultRepeated) {
if (isIfStatementResultThen) {
// Evaluate THEN expression (only) and copy all its results.
childExpressions[1].evaluate(batch);
thenColVector.copySelected(batch.selectedInUse, batch.selected, n, outputColVector);
} else {
// Evaluate ELSE expression (only) and copy all its results.
childExpressions[2].evaluate(batch);
elseColVector.copySelected(batch.selectedInUse, batch.selected, n, outputColVector);
}
return;
}
// NOTE: We cannot use copySelected below since it is a whole column operation.
conditionalEvaluate(batch, childExpressions[1], thenSelected, thenCount);
for (int i = 0; i < thenCount; i++) {
final int batchIndex = thenSelected[i];
outputIsNull[batchIndex] = false;
outputColVector.setElement(batchIndex, batchIndex, thenColVector);
}
conditionalEvaluate(batch, childExpressions[2], elseSelected, elseCount);
for (int i = 0; i < elseCount; i++) {
final int batchIndex = elseSelected[i];
outputIsNull[batchIndex] = false;
outputColVector.setElement(batchIndex, batchIndex, elseColVector);
}
}
use of org.apache.hadoop.hive.ql.exec.vector.ColumnVector in project hive by apache.
the class IfExprNullCondExpr method evaluate.
@Override
public void evaluate(VectorizedRowBatch batch) {
int n = batch.size;
if (n <= 0) {
// Nothing to do
return;
}
/*
* Do common analysis of the IF statement boolean expression.
*
* The following protected members can be examined afterwards:
*
* boolean isIfStatementResultRepeated
* boolean isIfStatementResultThen
*
* int thenSelectedCount
* int[] thenSelected
* int elseSelectedCount
* int[] elseSelected
*/
super.evaluate(batch);
ColumnVector outputColVector = batch.cols[outputColumnNum];
boolean[] outputIsNull = outputColVector.isNull;
// We do not need to do a column reset since we are carefully changing the output.
outputColVector.isRepeating = false;
// CONSIDER: Should be do this for all vector expressions that can
// work on BytesColumnVector output columns???
outputColVector.init();
ColumnVector elseColVector = batch.cols[arg3Column];
final int thenCount = thenSelectedCount;
final int elseCount = elseSelectedCount;
if (isIfStatementResultRepeated) {
if (isIfStatementResultThen) {
outputIsNull[0] = true;
outputColVector.noNulls = false;
outputColVector.isRepeating = true;
} else {
// Evaluate ELSE expression (only) and copy all its results.
// Second input parameter but 3rd column.
childExpressions[1].evaluate(batch);
elseColVector.copySelected(batch.selectedInUse, batch.selected, n, outputColVector);
}
return;
}
// NOTE: We cannot use copySelected below since it is a whole column operation.
outputColVector.noNulls = false;
for (int i = 0; i < thenCount; i++) {
outputColVector.isNull[thenSelected[i]] = true;
}
// Second input parameter but 3rd column.
conditionalEvaluate(batch, childExpressions[1], elseSelected, elseCount);
for (int i = 0; i < elseCount; i++) {
final int batchIndex = elseSelected[i];
outputIsNull[batchIndex] = false;
outputColVector.setElement(batchIndex, batchIndex, elseColVector);
}
}
use of org.apache.hadoop.hive.ql.exec.vector.ColumnVector in project hive by apache.
the class IfExprNullNull method evaluate.
@Override
public void evaluate(VectorizedRowBatch batch) {
if (childExpressions != null) {
super.evaluateChildren(batch);
}
final ColumnVector outputColVector = batch.cols[outputColumnNum];
// We do not need to do a column reset since we are carefully changing the output.
outputColVector.isNull[0] = true;
outputColVector.noNulls = false;
outputColVector.isRepeating = true;
}
Aggregations