Skip to content

Commit ba8ea8b

Browse files
committed
Remove LinRead map and sequencing from the Go client.
1 parent ed3c52b commit ba8ea8b

File tree

3 files changed

+7
-52
lines changed

3 files changed

+7
-52
lines changed

client.go

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,13 @@ package dgo
1919
import (
2020
"context"
2121
"math/rand"
22-
"sync"
2322

2423
"github.com/dgraph-io/dgo/protos/api"
25-
"github.com/dgraph-io/dgo/y"
26-
"github.com/gogo/protobuf/proto"
2724
)
2825

2926
// Dgraph is a transaction aware client to a set of dgraph server instances.
3027
type Dgraph struct {
3128
dc []api.DgraphClient
32-
33-
mu sync.Mutex
34-
linRead *api.LinRead
3529
}
3630

3731
// NewDgraphClient creates a new Dgraph for interacting with the Dgraph store connected to in
@@ -42,25 +36,12 @@ type Dgraph struct {
4236
// A single client is thread safe for sharing with multiple go routines.
4337
func NewDgraphClient(clients ...api.DgraphClient) *Dgraph {
4438
dg := &Dgraph{
45-
dc: clients,
46-
linRead: &api.LinRead{},
39+
dc: clients,
4740
}
4841

4942
return dg
5043
}
5144

52-
func (d *Dgraph) mergeLinRead(src *api.LinRead) {
53-
d.mu.Lock()
54-
defer d.mu.Unlock()
55-
y.MergeLinReads(d.linRead, src)
56-
}
57-
58-
func (d *Dgraph) getLinRead() *api.LinRead {
59-
d.mu.Lock()
60-
defer d.mu.Unlock()
61-
return proto.Clone(d.linRead).(*api.LinRead)
62-
}
63-
6445
// By setting various fields of api.Operation, Alter can be used to do the
6546
// following:
6647
//

txn.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,23 @@ var (
4646
type Txn struct {
4747
context *api.TxnContext
4848

49-
finished bool
50-
mutated bool
51-
sequencing api.LinRead_Sequencing
49+
finished bool
50+
mutated bool
5251

5352
dg *Dgraph
5453
dc api.DgraphClient
5554
}
5655

5756
func (txn *Txn) Sequencing(sequencing api.LinRead_Sequencing) {
58-
txn.sequencing = sequencing
57+
// Sequencing is no longer used.
5958
}
6059

6160
// NewTxn creates a new transaction.
6261
func (d *Dgraph) NewTxn() *Txn {
6362
txn := &Txn{
64-
dg: d,
65-
dc: d.anyClient(),
66-
context: &api.TxnContext{
67-
LinRead: d.getLinRead(),
68-
},
63+
dg: d,
64+
dc: d.anyClient(),
65+
context: &api.TxnContext{},
6966
}
7067
return txn
7168
}
@@ -88,9 +85,7 @@ func (txn *Txn) QueryWithVars(ctx context.Context, q string,
8885
Query: q,
8986
Vars: vars,
9087
StartTs: txn.context.StartTs,
91-
LinRead: txn.context.LinRead,
9288
}
93-
req.LinRead.Sequencing = txn.sequencing
9489
resp, err := txn.dc.Query(ctx, req)
9590
if err == nil {
9691
if err := txn.mergeContext(resp.GetTxn()); err != nil {
@@ -105,9 +100,6 @@ func (txn *Txn) mergeContext(src *api.TxnContext) error {
105100
return nil
106101
}
107102

108-
y.MergeLinReads(txn.context.LinRead, src.LinRead)
109-
txn.dg.mergeLinRead(src.LinRead) // Also merge it with client.
110-
111103
if txn.context.StartTs == 0 {
112104
txn.context.StartTs = src.StartTs
113105
}

y/y.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,9 @@ package y
2020

2121
import (
2222
"errors"
23-
24-
"github.com/dgraph-io/dgo/protos/api"
2523
)
2624

2725
var (
2826
ErrAborted = errors.New("Transaction has been aborted. Please retry.")
2927
ErrConflict = errors.New("Conflicts with pending transaction. Please abort.")
3028
)
31-
32-
func MergeLinReads(dst *api.LinRead, src *api.LinRead) {
33-
if src == nil || src.Ids == nil {
34-
return
35-
}
36-
if dst.Ids == nil {
37-
dst.Ids = make(map[uint32]uint64)
38-
}
39-
for gid, sid := range src.Ids {
40-
if did, has := dst.Ids[gid]; has && did >= sid {
41-
// do nothing.
42-
} else {
43-
dst.Ids[gid] = sid
44-
}
45-
}
46-
}

0 commit comments

Comments
 (0)