Skip to content
Snippets Groups Projects
Unverified Commit 2a73fc96 authored by Janardhan Reddy's avatar Janardhan Reddy
Browse files

call commitMutations in a goroutine in query tests

Copy key in iterator before calling posting.GetNoStore
parent cf091ca9
Branches
No related tags found
No related merge requests found
......@@ -75,7 +75,9 @@ func addEdge(t *testing.T, attr string, src uint64, edge *protos.DirectedEdge) {
l.AddMutationWithIndex(context.Background(), edge, txn))
commit := commitTs(startTs)
require.NoError(t, txn.CommitMutations(context.Background(), commit))
go func() {
require.NoError(t, txn.CommitMutations(context.Background(), commit))
}()
}
func makeFacets(facetKVs map[string]string) (fs []*protos.Facet, err error) {
......
......@@ -69,7 +69,7 @@ var rdfTypeMap = map[types.TypeID]string{
}
func toRDF(buf *bytes.Buffer, item kv, readTs uint64) {
item.list.Iterate(readTs, 0, func(p *protos.Posting) bool {
err := item.list.Iterate(readTs, 0, func(p *protos.Posting) bool {
buf.WriteString(item.prefix)
if !bytes.Equal(p.Value, nil) {
// Value posting
......@@ -128,6 +128,11 @@ func toRDF(buf *bytes.Buffer, item kv, readTs uint64) {
buf.WriteString(" .\n")
return true
})
if err != nil {
// TODO: Throw error back to the user.
// Ensure that we are not missing errCheck at other places.
x.Printf("Error while exporting :%v\n", err)
}
}
func toSchema(buf *bytes.Buffer, s *skv) {
......@@ -264,6 +269,7 @@ func export(bdir string, readTs uint64) error {
txn := pstore.NewTransactionAt(readTs, false)
defer txn.Discard()
iterOpts := badger.DefaultIteratorOptions
iterOpts.PrefetchValues = false
it := txn.NewIterator(iterOpts)
defer it.Close()
prefix := new(bytes.Buffer)
......@@ -322,7 +328,9 @@ func export(bdir string, readTs uint64) error {
prefix.WriteString("> <")
prefix.WriteString(pred)
prefix.WriteString("> ")
l := posting.GetNoStore(key)
nkey := make([]byte, len(key))
copy(nkey, key)
l := posting.GetNoStore(nkey)
chkv <- kv{
prefix: prefix.String(),
list: l,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment