Example #1
0
func (self *Shard) executeMergeQuery(querySpec *parser.QuerySpec, processor engine.Processor, t parser.FromClauseType) error {
	seriesAndColumns := querySpec.SelectQuery().GetReferencedColumns()
	iterators := make([]*PointIterator, len(seriesAndColumns))
	streams := make([]engine.StreamQuery, len(iterators))
	i := 0
	var err error
	for s, c := range seriesAndColumns {
		c, iterators[i], err = self.getPointIteratorForSeries(querySpec, s.Name, c)
		if err != nil {
			log.Error(err)
			return err
		}
		defer iterators[i].Close()
		aliases := querySpec.SelectQuery().GetTableAliases(s.Name)
		if len(aliases) > 1 {
			return fmt.Errorf("Cannot have the same table joined more than once")
		}
		streams[i] = PointIteratorStream{
			pi:     iterators[i],
			name:   aliases[0],
			fields: c,
		}
		i++
	}

	h := engine.NewSeriesHeap(querySpec.IsAscending())
	merger := engine.NewCME("Shard", streams, h, processor, t == parser.FromClauseMerge)
	if _, err := merger.Update(); err != nil {
		return err
	}
	return nil
}
Example #2
0
func (self *ClusterConfiguration) GetShardsForQuery(querySpec *parser.QuerySpec) Shards {
	shards := self.getShardsToMatchQuery(querySpec)
	shards = self.getShardRange(querySpec, shards)
	if querySpec.IsAscending() {
		SortShardsByTimeAscending(shards)
	}
	return shards
}
func (self *ClusterConfiguration) GetShardsForQuery(querySpec *parser.QuerySpec) (Shards, error) {
	shards, err := self.getShardsToMatchQuery(querySpec)
	if err != nil {
		return nil, err
	}
	log.Debug("Querying %d shards for query", len(shards))
	shards = self.getShardRange(querySpec, shards)
	if querySpec.IsAscending() {
		SortShardsByTimeAscending(shards)
	}
	return shards, nil
}