Skip to content

Commit f22056c

Browse files
committed
feat: remove txs that only happened once
Signed-off-by: Andres Taylor <[email protected]>
1 parent 69f1c71 commit f22056c

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

go/transactions/transaction_signature.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ func (pi predicateInfo) compareTo(b predicateInfo) int {
6363
}
6464

6565
func (tx *TxSignature) MarshalJSON() ([]byte, error) {
66-
// Transform Predicates to an array of strings
6766
predicateStrings := make([]string, len(tx.Predicates))
6867
for i, predicate := range tx.Predicates {
6968
predicateStrings[i] = predicate.String()
@@ -144,7 +143,6 @@ func (m *txSignatureMap) Add(tx *TxSignature) {
144143
}
145144

146145
func (tx *TxSignature) Equals(other *TxSignature) bool {
147-
// Compare Queries
148146
if len(tx.Queries) != len(other.Queries) {
149147
return false
150148
}
@@ -154,7 +152,6 @@ func (tx *TxSignature) Equals(other *TxSignature) bool {
154152
}
155153
}
156154

157-
// Compare Predicates
158155
if len(tx.Predicates) != len(other.Predicates) {
159156
return false
160157
}
@@ -168,10 +165,14 @@ func (tx *TxSignature) Equals(other *TxSignature) bool {
168165
}
169166

170167
func (m *txSignatureMap) MarshalJSON() ([]byte, error) {
171-
// Collect all TxSignatures into a slice
168+
// Collect all interesting TxSignatures into a slice
172169
var signatures []*TxSignature
173170
for _, bucket := range m.data {
174-
signatures = append(signatures, bucket...)
171+
for _, txSig := range bucket {
172+
if txSig.Count > 1 {
173+
signatures = append(signatures, txSig)
174+
}
175+
}
175176
}
176177

177178
sort.Slice(signatures, func(i, j int) bool {

go/transactions/transactions.go

-2
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ func (s *state) consume(ch <-chan []sqlparser.Statement, wg *sync.WaitGroup) {
217217
s.consumeUpdate(query, st, n, tx)
218218
case *sqlparser.Delete:
219219
s.consumeDelete(query, st, n, tx)
220-
default:
221-
panic(fmt.Sprintf("not supported for now: %T", query))
222220
}
223221
}
224222
s.addSignature(tx)

0 commit comments

Comments
 (0)