Commit 5877724c authored by Geoff Simmons's avatar Geoff Simmons

Pass a slice of Tx (not a slice of pointers) to the read callback.

parent 5dd078e9
......@@ -230,8 +230,7 @@ func checkRec(t *testing.T, rec Record, expRec expRec) {
}
}
func checkTx(t *testing.T, txp *Tx, expTxLen expTxLen) {
tx := *txp
func checkTx(t *testing.T, tx Tx, expTxLen expTxLen) {
expTx := expTxLen.tx
if expTx.typ != txTypeUndef && expTx.typ != tx.Type {
t.Errorf("tx.Type want=%v got=%v", expTx.typ, tx.Type)
......@@ -306,7 +305,7 @@ func checkTx(t *testing.T, txp *Tx, expTxLen expTxLen) {
}
}
func checkTxGrp(t *testing.T, txGrp []*Tx, expTxGrp expTxGrp) {
func checkTxGrp(t *testing.T, txGrp []Tx, expTxGrp expTxGrp) {
if expTxGrp.expTx != undefLen && len(txGrp) != expTxGrp.expTx {
t.Fatalf("number of tx in group got=%v want=%v",
len(txGrp), expTxGrp.expTx)
......@@ -317,7 +316,7 @@ func checkTxGrp(t *testing.T, txGrp []*Tx, expTxGrp expTxGrp) {
}
}
func checkTxGrps(t *testing.T, txGrps [][]*Tx, expTxGrps []expTxGrp) {
func checkTxGrps(t *testing.T, txGrps [][]Tx, expTxGrps []expTxGrp) {
if len(txGrps) != len(expTxGrps) {
t.Fatalf("number of tx groups got=%v want=%v", len(txGrps),
len(expTxGrps))
......@@ -451,8 +450,8 @@ func TestE2EDefaultRead(t *testing.T) {
}
statusChan := make(chan Status)
txChan := make(chan []*Tx, 100)
cb := func(txGrp []*Tx, rdstatus Status) bool {
txChan := make(chan []Tx, 100)
cb := func(txGrp []Tx, rdstatus Status) bool {
switch rdstatus {
case More:
txChan <- txGrp
......@@ -479,7 +478,7 @@ func TestE2EDefaultRead(t *testing.T) {
t.Fatal("/uncacheable Response", err)
}
var txGrps [][]*Tx
var txGrps [][]Tx
TX:
for {
select {
......@@ -497,8 +496,7 @@ TX:
checkTxGrps(t, txGrps, expDefaultRead)
for _, txGrp := range txGrps {
txp := txGrp[0]
tx := *txp
tx := txGrp[0]
if tx.Type == BeReq {
checkBereq(t, tx, *req)
}
......
......@@ -511,7 +511,7 @@ func quote(s string) string {
//export publish
func publish(trans unsafe.Pointer, priv unsafe.Pointer) C.int {
var gtxn []*Tx
var gtxn []Tx
txn := (*[1 << 30]*C.struct_VSL_transaction)(unsafe.Pointer(trans))
if txn[0] == nil {
return 0
......@@ -523,8 +523,8 @@ func publish(trans unsafe.Pointer, priv unsafe.Pointer) C.int {
panic("unmapped transaction channel")
}
for i := 0; txn[i] != nil; i++ {
var tx Tx
vtx := txn[i]
tx := new(Tx)
tx.Type = TxType(C.txtype(vtx))
tx.VXID = uint32(vtx.vxid)
tx.ParentVXID = uint32(vtx.vxid_parent)
......@@ -645,8 +645,8 @@ func (status Status) Error() string {
// read.
//
// When the log read has aggregated a group of transactions, they are
// passed to the callback as a slice of pointers to Tx objects. The
// second argument of type Status is log.More in this case.
// passed to the callback as a slice of Tx objects. The second
// argument of type Status is log.More in this case.
//
// When the log read encounters an error or end condition (end of log
// or end of file), then it passes a Status in the second argument to
......@@ -658,7 +658,7 @@ func (status Status) Error() string {
// more time with the Status set to Stopped, and nil for the
// transaction slice, and the goroutine initiated by the Read method
// is stopped.
type ReadCB func([]*Tx, Status) bool
type ReadCB func([]Tx, Status) bool
// ContinueHandler is the type of a function that is passed to the
// Read method. It is executed when the end-of-log condition is
......@@ -710,7 +710,7 @@ func defaultContinue() bool {
// statusChan := make(chan Status)
//
// // this callback will be passed to the Read method
// cb := func(txGrp []*Tx, rdstatus Status) bool {
// cb := func(txGrp []Tx, rdstatus Status) bool {
// // if the status is not log.More, send it on the status channel
// if rdstatus != log.More {
// statusChan <- rdstatus
......
......@@ -184,7 +184,7 @@ TX:
}
func TestDefaultRead(t *testing.T) {
var txGrps [][]*Tx
var txGrps [][]Tx
expTxn, err := scrapeLog(vxidLog)
if err != nil {
......@@ -199,7 +199,7 @@ func TestDefaultRead(t *testing.T) {
}
statusChan := make(chan Status)
cb := func(txGrp []*Tx, rdstatus Status) bool {
cb := func(txGrp []Tx, rdstatus Status) bool {
if rdstatus != More {
statusChan <- rdstatus
return false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment