Beispiel #1
0
func (ft *Table) GetFlows(query *FlowSearchQuery) *FlowSet {
	ft.RLock()
	defer ft.RUnlock()

	var it *common.Iterator
	if query != nil && query.PaginationRange != nil {
		it = common.NewIterator(0, query.PaginationRange.From, query.PaginationRange.To)
	} else {
		it = common.NewIterator()
	}

	flowset := NewFlowSet()
	for _, f := range ft.table {
		if it.Done() {
			break
		}
		if (query == nil || query.Filter == nil || query.Filter.Eval(f)) && it.Next() {
			if flowset.Start == 0 || flowset.Start > f.Metric.Start {
				flowset.Start = f.Metric.Start
			}
			if flowset.End == 0 || flowset.Start < f.Metric.Last {
				flowset.End = f.Metric.Last
			}
			flowset.Flows = append(flowset.Flows, f)
		}
	}
	return flowset
}
Beispiel #2
0
func (r *GraphTraversalRange) Iterator() *common.Iterator {
	if r != nil {
		return common.NewIterator(0, r[0], r[1])
	}
	return common.NewIterator()
}