Exemple #1
0
func mergeDomains(engine storage.Engine, w origins.Writer, domains []string, since, asof time.Time) int {
	var (
		err   error
		count int
		log   *view.Log
	)

	iters := make([]origins.Iterator, len(domains))

	// Merge and output facts across domains.
	for i, d := range domains {
		log, err = view.OpenLog(engine, d, "commit")

		if err != nil {
			logrus.Fatal(err)
		}

		iters[i] = log.View(since, asof)
	}

	if count, err = origins.Copy(view.Merge(iters...), w); err != nil {
		logrus.Fatal(err)
	}

	return count
}
Exemple #2
0
func concatDomains(engine storage.Engine, w origins.Writer, domains []string, since, asof time.Time) int {
	var (
		err      error
		n, count int
		log      *view.Log
	)

	// Output facts for each domain in the order they are supplied.
	for _, d := range domains {
		log, err = view.OpenLog(engine, d, "commit")

		if err != nil {
			logrus.Fatal(err)
		}

		v := log.View(since, asof)

		n, err = origins.Copy(v, w)

		if err != nil {
			logrus.Fatal(err)
		}

		count += n
	}

	return count
}