MCPcopy
hub / github.com/uber/aresdb / processExpression

Method processExpression

query/time_series_aggregate.go:462–562  ·  view source on GitHub ↗

processExpression does AST tree dfs traversal and apply root action on the root level, rootAction includes filterAction, writeToDimensionVectorAction and makeWriteToMeasureVectorAction

(exp, parentExp expr.Expr, tableScanners []*TableScanner, foreignTables []*foreignTable,
	stream unsafe.Pointer, device int, action rootAction)

Source from the content-addressed store, hash-verified

460// processExpression does AST tree dfs traversal and apply root action on the root level,
461// rootAction includes filterAction, writeToDimensionVectorAction and makeWriteToMeasureVectorAction
462func (bc *oopkBatchContext) processExpression(exp, parentExp expr.Expr, tableScanners []*TableScanner, foreignTables []*foreignTable,
463 stream unsafe.Pointer, device int, action rootAction) C.InputVector {
464 switch e := exp.(type) {
465 case *expr.ParenExpr:
466 return bc.processExpression(e.Expr, e, tableScanners, foreignTables, stream, device, action)
467 case *expr.VarRef:
468 columnIndex := tableScanners[e.TableID].ColumnsByIDs[e.ColumnID]
469 var inputVector C.InputVector
470 // main table
471 if e.TableID == 0 {
472 column := bc.columns[columnIndex]
473 inputVector = makeVectorPartySliceInput(column)
474 } else {
475 var timezoneLookup unsafe.Pointer
476 var timezoneLookupDSize int
477 switch pe := parentExp.(type) {
478 case *expr.BinaryExpr:
479 if pe.Op == expr.CONVERT_TZ {
480 timezoneLookup = bc.timezoneLookupD.getPointer()
481 timezoneLookupDSize = bc.timezoneLookupDSize
482 }
483 default:
484 }
485 inputVector = makeForeignColumnInput(columnIndex, bc.foreignTableRecordIDsD[e.TableID-1].getPointer(), *foreignTables[e.TableID-1], timezoneLookup, timezoneLookupDSize)
486 }
487
488 if action != nil {
489 action(C.Noop, stream, device, []C.InputVector{inputVector}, e)
490 return C.InputVector{}
491 }
492 return inputVector
493 case *expr.NumberLiteral, *expr.GeopointLiteral:
494 var inputVector C.InputVector
495 inputVector = makeConstantInput(e, true)
496 if action != nil {
497 action(C.Noop, stream, device, []C.InputVector{inputVector}, e)
498 return C.InputVector{}
499 }
500 return inputVector
501 case *expr.UnaryExpr:
502 inputVector := bc.processExpression(e.Expr, e, tableScanners, foreignTables, stream, device, nil)
503 functorType, exist := UnaryExprTypeToCFunctorType[e.Op]
504 if !exist {
505 functorType = C.Noop
506 }
507
508 if action != nil {
509 action(functorType, stream, device, []C.InputVector{inputVector}, e)
510 return C.InputVector{}
511 }
512
513 values, nulls := bc.allocateStackFrame()
514 dataType := getOutputDataType(e.Type(), 4)
515 var outputVector = makeScratchSpaceOutput(values.getPointer(), nulls.getPointer(), dataType)
516
517 C.UnaryTransform(inputVector, outputVector, (*C.uint32_t)(bc.indexVectorD.getPointer()),
518 (C.int)(bc.size), (*C.uint32_t)(bc.baseCountD.getPointer()), (C.uint32_t)(bc.startRow), functorType, stream, C.int(device))
519

Callers 7

filterMethod · 0.80
joinMethod · 0.80
evalMeasuresMethod · 0.80
evalDimensionsMethod · 0.80

Calls 11

allocateStackFrameMethod · 0.95
shrinkStackFrameMethod · 0.95
appendStackFrameMethod · 0.95
makeForeignColumnInputFunction · 0.85
makeConstantInputFunction · 0.85
getOutputDataTypeFunction · 0.85
makeScratchSpaceOutputFunction · 0.85
makeScratchSpaceInputFunction · 0.85
getPointerMethod · 0.80
TypeMethod · 0.65

Tested by

no test coverage detected