Пример #1
0
// BQLRandomGraphWalking creates the benchmark.
func BQLRandomGraphWalking(ctx context.Context, st storage.Store, chanSize int) ([]*runtime.BenchEntry, error) {
	rgSize := []int{1000, 10000}
	sizes := []int{10, 1000, 100000}
	var trplSets [][]*triple.Triple
	var ids []string
	var gids []string
	var gSizes []int
	gs, err := getGraphGenerators(rgSize)
	if err != nil {
		return nil, err
	}
	for idx, g := range gs {
		for _, s := range sizes {
			ts, err := g.Generate(s)
			if err != nil {
				return nil, err
			}
			trplSets = append(trplSets, ts)
			ids = append(ids, fmt.Sprintf("bql rg branch_factor=%04d, size=%07d", rgSize[idx], s))
			gids = append(gids, fmt.Sprintf("bql_b%d_s%d", rgSize[idx], s))
			gSizes = append(gSizes, s)
		}
	}
	var bes []*runtime.BenchEntry
	reps := []int{10}
	for bqlIdx, bqlQuery := range treeGraphWalkingBQL {
		bql := bqlQuery
		for i, max := 0, len(ids); i < max; i++ {
			for idxReps, r := range reps {
				var g storage.Graph
				gID := fmt.Sprintf("bql_rg_%d_%s_r%d_i%d", bqlIdx, gids[i], i, idxReps)
				data := trplSets[i]
				bes = append(bes, &runtime.BenchEntry{
					BatteryID: fmt.Sprintf("Run BQL random graph walking query %d", bqlIdx),
					ID:        fmt.Sprintf("%s, reps=%02d", ids[i], r),
					Triples:   gSizes[i],
					Reps:      r,
					Setup: func() error {
						var err error
						g, err = st.NewGraph(ctx, "?"+gID)
						if err != nil {
							return err
						}
						return g.AddTriples(ctx, data)
					},
					F: func() error {
						query := fmt.Sprintf(bql, gID)
						_, err := run.BQL(ctx, query, st, chanSize)
						return err
					},
					TearDown: func() error {
						return st.DeleteGraph(ctx, "?"+gID)
					},
				})
			}
		}
	}
	return bes, nil
}
Пример #2
0
// RemoveExistingTreeTriplesBenchmark creates the benchmark.
func RemoveExistingTreeTriplesBenchmark(ctx context.Context, st storage.Store, chanSize int) ([]*runtime.BenchEntry, error) {
	bFactors := []int{2, 200}
	sizes := []int{10, 1000, 100000}
	var trplSets [][]*triple.Triple
	var ids []string
	var gids []string
	var gSizes []int
	gs, err := getTreeGenerators(bFactors)
	if err != nil {
		return nil, err
	}
	for idx, g := range gs {
		for _, s := range sizes {
			ts, err := g.Generate(s)
			if err != nil {
				return nil, err
			}
			trplSets = append(trplSets, ts)
			ids = append(ids, fmt.Sprintf("etg branch_factor=%04d, size=%07d", bFactors[idx], s))
			gids = append(gids, fmt.Sprintf("b%d_s%d", bFactors[idx], s))
			gSizes = append(gSizes, s)
		}
	}
	var bes []*runtime.BenchEntry
	reps := []int{10}
	for i, max := 0, len(ids); i < max; i++ {
		for idxReps, r := range reps {
			var g storage.Graph
			gID := fmt.Sprintf("remove_existing_tree_%s_r%d_i%d", gids[i], i, idxReps)
			data := trplSets[i]
			bes = append(bes, &runtime.BenchEntry{
				BatteryID: "Remove existing triples",
				ID:        fmt.Sprintf("%s, reps=%02d", ids[i], r),
				Triples:   gSizes[i],
				Reps:      r,
				Setup: func() error {
					var err error
					g, err = st.NewGraph(ctx, gID)
					if err != nil {
						return err
					}
					return g.AddTriples(ctx, data)
				},
				F: func() error {
					return g.RemoveTriples(ctx, data)
				},
				TearDown: func() error {
					return st.DeleteGraph(ctx, gID)
				},
			})
		}
	}
	return bes, nil
}
Пример #3
0
Файл: io.go Проект: rtu/badwolf
// ReadIntoGraph reads a graph out of the provided reader. The data on the
// reader is interpret as text. Each line represents one triple using the
// standard serialized format. ReadIntoGraph will stop if fails to Parse
// a triple on the stream. The triples read till then would have also been
// added to the graph. The int value returns the number of triples added
func ReadIntoGraph(g storage.Graph, r io.Reader, b literal.Builder) (int, error) {
	cnt, scanner := 0, bufio.NewScanner(r)
	scanner.Split(bufio.ScanLines)
	for scanner.Scan() {
		text := strings.TrimSpace(scanner.Text())
		if text == "" {
			continue
		}
		t, err := triple.ParseTriple(text, b)
		if err != nil {
			return cnt, err
		}
		cnt++
		g.AddTriples([]*triple.Triple{t})
	}
	return cnt, nil
}