@@ -28,20 +28,20 @@ import (
2828)
2929
3030type (
31- TxSignature struct {
32- Count int `json:"count"`
33- Queries []TxQuery `json:"qqueries"`
31+ Signature struct {
32+ Count int `json:"count"`
33+ Queries []Query `json:"qqueries"`
3434 }
3535
36- TxQuery struct {
36+ Query struct {
3737 Op string `json:"op"`
3838 AffectedTable string `json:"affected_table"`
3939 UpdatedColumns []string `json:"updated_columns,omitempty"`
4040 Predicates []predicateInfo `json:"predicates,omitempty"`
4141 }
4242
4343 txSignatureMap struct {
44- data map [uint64 ][]* TxSignature
44+ data map [uint64 ][]* Signature
4545 }
4646
4747 predicateInfo struct {
@@ -60,17 +60,17 @@ func (pi predicateInfo) String() string {
6060 return fmt .Sprintf ("%s.%s %s %s" , pi .Table , pi .Col , pi .Op .ToString (), val )
6161}
6262
63- func (tx * TxSignature ) MarshalJSON () ([]byte , error ) {
63+ func (tx * Signature ) MarshalJSON () ([]byte , error ) {
6464 return json .Marshal (struct {
65- Count int `json:"count"`
66- Queries []TxQuery `json:"query-signatures"`
65+ Count int `json:"count"`
66+ Queries []Query `json:"query-signatures"`
6767 }{
6868 Count : tx .Count ,
6969 Queries : tx .Queries ,
7070 })
7171}
7272
73- func (tx * TxSignature ) Hash64 () uint64 {
73+ func (tx * Signature ) Hash64 () uint64 {
7474 hasher := fnv .New64a ()
7575
7676 for _ , query := range tx .Queries {
@@ -80,7 +80,7 @@ func (tx *TxSignature) Hash64() uint64 {
8080 return hasher .Sum64 ()
8181}
8282
83- func (tx TxQuery ) addToHash (hash hash.Hash64 ) {
83+ func (tx Query ) addToHash (hash hash.Hash64 ) {
8484 _ , _ = hash .Write ([]byte (tx .Op ))
8585 _ , _ = hash .Write ([]byte {0 })
8686 _ , _ = hash .Write ([]byte (tx .AffectedTable ))
@@ -97,7 +97,7 @@ func (tx TxQuery) addToHash(hash hash.Hash64) {
9797 }
9898}
9999
100- func (tx TxQuery ) Equals (other TxQuery ) bool {
100+ func (tx Query ) Equals (other Query ) bool {
101101 if tx .Op != other .Op {
102102 return false
103103 }
@@ -125,19 +125,19 @@ func (tx TxQuery) Equals(other TxQuery) bool {
125125
126126func newTxSignatureMap () * txSignatureMap {
127127 return & txSignatureMap {
128- data : make (map [uint64 ][]* TxSignature ),
128+ data : make (map [uint64 ][]* Signature ),
129129 }
130130}
131131
132- func (m * txSignatureMap ) Add (tx * TxSignature ) {
132+ func (m * txSignatureMap ) Add (tx * Signature ) {
133133 hash := tx .Hash64 ()
134134
135135 bucket , exists := m .data [hash ]
136136
137137 // Check if the hash already exists
138138 if ! exists {
139139 tx .Count = 1
140- m .data [hash ] = []* TxSignature {tx }
140+ m .data [hash ] = []* Signature {tx }
141141 return
142142 }
143143
@@ -153,7 +153,7 @@ func (m *txSignatureMap) Add(tx *TxSignature) {
153153 m .data [hash ] = append (bucket , tx )
154154}
155155
156- func (tx * TxSignature ) Equals (other * TxSignature ) bool {
156+ func (tx * Signature ) Equals (other * Signature ) bool {
157157 if len (tx .Queries ) != len (other .Queries ) {
158158 return false
159159 }
@@ -167,7 +167,7 @@ func (tx *TxSignature) Equals(other *TxSignature) bool {
167167}
168168
169169// CleanUp removes values that are only used once and replaces them with -1
170- func (tx * TxSignature ) CleanUp () * TxSignature {
170+ func (tx * Signature ) CleanUp () * Signature {
171171 usedValues := make (map [int ]int )
172172
173173 // First let's count how many times each value is used
@@ -180,7 +180,7 @@ func (tx *TxSignature) CleanUp() *TxSignature {
180180 // Now we replace values only used once with -1
181181 newCount := 0
182182 newValues := make (map [int ]int )
183- newQueries := make ([]TxQuery , 0 , len (tx .Queries ))
183+ newQueries := make ([]Query , 0 , len (tx .Queries ))
184184 for _ , query := range tx .Queries {
185185 newPredicates := make ([]predicateInfo , 0 , len (query .Predicates ))
186186 for _ , predicate := range query .Predicates {
@@ -198,23 +198,23 @@ func (tx *TxSignature) CleanUp() *TxSignature {
198198 }
199199 newPredicates = append (newPredicates , predicate )
200200 }
201- newQueries = append (newQueries , TxQuery {
201+ newQueries = append (newQueries , Query {
202202 Op : query .Op ,
203203 AffectedTable : query .AffectedTable ,
204204 UpdatedColumns : query .UpdatedColumns ,
205205 Predicates : newPredicates ,
206206 })
207207 }
208208
209- return & TxSignature {
209+ return & Signature {
210210 Queries : newQueries ,
211211 Count : tx .Count ,
212212 }
213213}
214214
215215func (m * txSignatureMap ) MarshalJSON () ([]byte , error ) {
216216 // Collect all interesting TxSignatures into a slice
217- var signatures []* TxSignature
217+ var signatures []* Signature
218218 for _ , bucket := range m .data {
219219 for _ , txSig := range bucket {
220220 if txSig .Count > 1 {
0 commit comments