/
summary_counters.go
120 lines (105 loc) · 3.27 KB
/
summary_counters.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
* Copyright (c) 2002-2019 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package neo4j
// Counters contains statistics about the changes made to the database made as part
// of the statement execution.
type Counters interface {
// Whether there were any updates at all, eg. any of the counters are greater than 0.
ContainsUpdates() bool
// The number of nodes created.
NodesCreated() int
// The number of nodes deleted.
NodesDeleted() int
// The number of relationships created.
RelationshipsCreated() int
// The number of relationships deleted.
RelationshipsDeleted() int
PropertiesSet() int
// The number of labels added to nodes.
LabelsAdded() int
// The number of labels removed from nodes.
LabelsRemoved() int
// The number of indexes added to the schema.
IndexesAdded() int
// The number of indexes removed from the schema.
IndexesRemoved() int
// The number of constraints added to the schema.
ConstraintsAdded() int
// The number of constraints removed from the schema.
ConstraintsRemoved() int
}
type neoCounters struct {
nodesCreated int
nodesDeleted int
relationshipsCreated int
relationshipsDeleted int
propertiesSet int
labelsAdded int
labelsRemoved int
indexesAdded int
indexesRemoved int
constraintsAdded int
constraintsRemoved int
}
func (counters *neoCounters) NodesCreated() int {
return counters.nodesCreated
}
func (counters *neoCounters) NodesDeleted() int {
return counters.nodesDeleted
}
func (counters *neoCounters) RelationshipsCreated() int {
return counters.relationshipsCreated
}
func (counters *neoCounters) RelationshipsDeleted() int {
return counters.relationshipsDeleted
}
func (counters *neoCounters) PropertiesSet() int {
return counters.propertiesSet
}
func (counters *neoCounters) LabelsAdded() int {
return counters.labelsAdded
}
func (counters *neoCounters) LabelsRemoved() int {
return counters.labelsRemoved
}
func (counters *neoCounters) IndexesAdded() int {
return counters.indexesAdded
}
func (counters *neoCounters) IndexesRemoved() int {
return counters.indexesRemoved
}
func (counters *neoCounters) ConstraintsAdded() int {
return counters.constraintsAdded
}
func (counters *neoCounters) ConstraintsRemoved() int {
return counters.constraintsRemoved
}
func (counters *neoCounters) ContainsUpdates() bool {
return counters.nodesCreated > 0 ||
counters.nodesDeleted > 0 ||
counters.relationshipsCreated > 0 ||
counters.relationshipsDeleted > 0 ||
counters.propertiesSet > 0 ||
counters.labelsAdded > 0 ||
counters.labelsRemoved > 0 ||
counters.indexesAdded > 0 ||
counters.indexesRemoved > 0 ||
counters.constraintsAdded > 0 ||
counters.constraintsRemoved > 0
}