Example #1
0
// Create and return a new JoinEngine given the shards that will be
// processed and the query
func NewJoinEngine(shards []uint32, query *parser.SelectQuery, next Processor) Processor {
	tableNames := query.GetFromClause().Names
	name := query.GetFromClause().GetString()
	log4go.Debug("NewJoinEngine: shards=%v, query=%s, next=%s, tableNames=%v, name=%s",
		shards, query.GetQueryString(), next.Name(), tableNames, name)

	joinEngine := &JoinEngine{
		next:        next,
		name:        name,
		tablesState: make([]joinEngineState, len(tableNames)),
		tableIdx:    make(map[string]int, len(tableNames)),
		query:       query,
		pts:         0,
	}

	for i, tn := range tableNames {
		alias := tn.GetAlias()
		joinEngine.tablesState[i] = joinEngineState{}
		joinEngine.tableIdx[alias] = i
	}

	mergeEngine := NewCommonMergeEngine(shards, false, query.Ascending, joinEngine)
	return mergeEngine
}