in query/time_series_aggregate.go [493:593]
func (bc *oopkBatchContext) processExpression(exp, parentExp expr.Expr, tableScanners []*TableScanner, foreignTables []*foreignTable,
stream unsafe.Pointer, device int, action rootAction) C.InputVector {
switch e := exp.(type) {
case *expr.ParenExpr:
return bc.processExpression(e.Expr, e, tableScanners, foreignTables, stream, device, action)
case *expr.VarRef:
columnIndex := tableScanners[e.TableID].ColumnsByIDs[e.ColumnID]
var inputVector C.InputVector
// main table
if e.TableID == 0 {
column := bc.columns[columnIndex]
inputVector = makeVectorPartySliceInput(column)
} else {
var timezoneLookup unsafe.Pointer
var timezoneLookupDSize int
switch pe := parentExp.(type) {
case *expr.BinaryExpr:
if pe.Op == expr.CONVERT_TZ {
timezoneLookup = bc.timezoneLookupD.getPointer()
timezoneLookupDSize = bc.timezoneLookupDSize
}
default:
}
inputVector = makeForeignColumnInput(columnIndex, bc.foreignTableRecordIDsD[e.TableID-1].getPointer(), *foreignTables[e.TableID-1], timezoneLookup, timezoneLookupDSize)
}
if action != nil {
action(C.Noop, stream, device, []C.InputVector{inputVector}, e)
return C.InputVector{}
}
return inputVector
case *expr.NumberLiteral, *expr.GeopointLiteral, *expr.UUIDLiteral:
var inputVector C.InputVector
inputVector = makeConstantInput(e, true)
if action != nil {
action(C.Noop, stream, device, []C.InputVector{inputVector}, e)
return C.InputVector{}
}
return inputVector
case *expr.UnaryExpr:
inputVector := bc.processExpression(e.Expr, e, tableScanners, foreignTables, stream, device, nil)
functorType, exist := UnaryExprTypeToCFunctorType[e.Op]
if !exist {
functorType = C.Noop
}
if action != nil {
action(functorType, stream, device, []C.InputVector{inputVector}, e)
return C.InputVector{}
}
dataType := getOutputDataType(e.Type(), 4)
values, nulls := bc.allocateStackFrame(dataType)
var outputVector = makeScratchSpaceOutput(values.getPointer(), nulls.getPointer(), dataType)
doCGoCall(func() C.CGoCallResHandle {
return C.UnaryTransform(inputVector, outputVector, (*C.uint32_t)(bc.indexVectorD.getPointer()),
(C.int)(bc.size), (*C.uint32_t)(bc.baseCountD.getPointer()), (C.uint32_t)(bc.startRow), functorType, stream, C.int(device))
})
if inputVector.Type == C.ScratchSpaceInput {
bc.shrinkStackFrame()
}
return makeScratchSpaceInput(values.getPointer(), nulls.getPointer(), dataType)
case *expr.BinaryExpr:
lhsInputVector := bc.processExpression(e.LHS, e, tableScanners, foreignTables, stream, device, nil)
rhsInputVector := bc.processExpression(e.RHS, e, tableScanners, foreignTables, stream, device, nil)
functorType, exist := BinaryExprTypeToCFunctorType[e.Op]
if !exist {
return makeConstantInput(0.0, false)
}
if action != nil {
action(functorType, stream, device, []C.InputVector{lhsInputVector, rhsInputVector}, e)
return C.InputVector{}
}
outputDataType := getOutputDataType(e.Type(), 4)
values, nulls := bc.allocateStackFrame(outputDataType)
var outputVector = makeScratchSpaceOutput(values.getPointer(), nulls.getPointer(), outputDataType)
doCGoCall(func() C.CGoCallResHandle {
return C.BinaryTransform(lhsInputVector, rhsInputVector, outputVector,
(*C.uint32_t)(bc.indexVectorD.getPointer()), (C.int)(bc.size), (*C.uint32_t)(bc.baseCountD.getPointer()),
(C.uint32_t)(bc.startRow),
functorType, stream, C.int(device))
})
if rhsInputVector.Type == C.ScratchSpaceInput {
bc.shrinkStackFrame()
}
if lhsInputVector.Type == C.ScratchSpaceInput {
bc.shrinkStackFrame()
}
return makeScratchSpaceInput(values.getPointer(), nulls.getPointer(), outputDataType)
default:
return C.InputVector{}
}
}