Skip to content

Commit 1f5f422

Browse files
committed
refactor
terminology change : asterisk -> wildcard
1 parent 0bf007d commit 1f5f422

9 files changed

+84
-84
lines changed

README.md

+46-46
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ srcJSON : {"abc.def":1}
205205
Output : 1
206206
```
207207

208-
### Asterisk in qualifier
208+
### Wildcard in qualifier
209209

210-
The asterisk in qualifier can be specified mixed with other subscript syntaxes.
210+
The wildcard in qualifier can be specified mixed with other subscript syntaxes.
211211

212212
```text
213213
JSONPath : $[0,1:3,*]
@@ -235,9 +235,9 @@ On the other hand, in the case of the `existence check` in the filter qualifier,
235235
| :------- | :------ |
236236
| Recursive descent | `@..a` |
237237
| Multiple identifier | `@['a','b']` |
238-
| Asterisk identifier | `@.*` |
238+
| Wildcard identifier | `@.*` |
239239
| Slice qualifier | `@[0:1]` |
240-
| Asterisk qualifier | `@[*]` |
240+
| Wildcard qualifier | `@[*]` |
241241
| Union in the qualifier | `@[0,1]` |
242242
| Filter qualifier | `@.a[?(@.b)]` |
243243

@@ -250,46 +250,46 @@ On the other hand, in the case of the `existence check` in the filter qualifier,
250250
goos: windows
251251
goarch: amd64
252252
pkg: github.com/AsaiYusuke/jsonpath
253-
BenchmarkRetrieve_dotNotation-4 889417 1365 ns/op 440 B/op 18 allocs/op
254-
BenchmarkRetrieve_bracketNotation-4 800169 1551 ns/op 520 B/op 21 allocs/op
255-
BenchmarkRetrieve_asterisk_identifier_dotNotation-4 800986 1442 ns/op 464 B/op 20 allocs/op
256-
BenchmarkRetrieve_asterisk_identifier_bracketNotation-4 749656 1625 ns/op 512 B/op 21 allocs/op
257-
BenchmarkRetrieve_multi_identifier-4 480747 2428 ns/op 864 B/op 33 allocs/op
258-
BenchmarkRetrieve_qualifier_index-4 725833 1642 ns/op 576 B/op 22 allocs/op
259-
BenchmarkRetrieve_qualifier_slice-4 571996 2108 ns/op 696 B/op 29 allocs/op
260-
BenchmarkRetrieve_qualifier_asterisk-4 800175 1544 ns/op 512 B/op 21 allocs/op
261-
BenchmarkRetrieve_qualifier_union-4 500564 2554 ns/op 928 B/op 34 allocs/op
262-
BenchmarkRetrieve_filter_logicalOR-4 198552 5753 ns/op 1989 B/op 47 allocs/op
263-
BenchmarkRetrieve_filter_logicalAND-4 214718 5707 ns/op 1989 B/op 47 allocs/op
264-
BenchmarkRetrieve_filter_nodeFilter-4 260708 4638 ns/op 1576 B/op 42 allocs/op
265-
BenchmarkRetrieve_filter_logicalNOT-4 261366 4797 ns/op 1928 B/op 48 allocs/op
266-
BenchmarkRetrieve_filter_compareEQ-4 231926 5371 ns/op 2080 B/op 52 allocs/op
267-
BenchmarkRetrieve_filter_compareNE-4 187755 6798 ns/op 2352 B/op 55 allocs/op
268-
BenchmarkRetrieve_filter_compareGE-4 228984 5440 ns/op 2080 B/op 52 allocs/op
269-
BenchmarkRetrieve_filter_compareGT-4 226922 5343 ns/op 1968 B/op 51 allocs/op
270-
BenchmarkRetrieve_filter_compareLE-4 215439 5362 ns/op 2064 B/op 51 allocs/op
271-
BenchmarkRetrieve_filter_compareLT-4 232552 5276 ns/op 1968 B/op 50 allocs/op
272-
BenchmarkRetrieve_filter_regex-4 164743 7533 ns/op 2926 B/op 63 allocs/op
273-
BenchmarkParserFunc_dotNotation-4 4183525 282 ns/op 144 B/op 6 allocs/op
274-
BenchmarkParserFunc_bracketNotation-4 4191128 284 ns/op 144 B/op 6 allocs/op
275-
BenchmarkParserFunc_asterisk_identifier_dotNotation-4 2783234 426 ns/op 192 B/op 8 allocs/op
276-
BenchmarkParserFunc_asterisk_identifier_bracketNotation-4 2698326 434 ns/op 192 B/op 8 allocs/op
277-
BenchmarkParserFunc_multi_identifier-4 2512260 485 ns/op 240 B/op 9 allocs/op
278-
BenchmarkParserFunc_qualifier_index-4 3274550 357 ns/op 224 B/op 8 allocs/op
279-
BenchmarkParserFunc_qualifier_slice-4 3342894 355 ns/op 192 B/op 8 allocs/op
280-
BenchmarkParserFunc_qualifier_asterisk-4 3392336 357 ns/op 192 B/op 8 allocs/op
281-
BenchmarkParserFunc_qualifier_union-4 1928816 618 ns/op 344 B/op 13 allocs/op
282-
BenchmarkParserFunc_filter_logicalOR-4 859549 1436 ns/op 1104 B/op 18 allocs/op
283-
BenchmarkParserFunc_filter_logicalAND-4 924142 1418 ns/op 1104 B/op 18 allocs/op
284-
BenchmarkParserFunc_filter_nodeFilter-4 999824 1047 ns/op 832 B/op 15 allocs/op
285-
BenchmarkParserFunc_filter_logicalNOT-4 802180 1551 ns/op 1168 B/op 20 allocs/op
286-
BenchmarkParserFunc_filter_compareEQ-4 709693 1638 ns/op 1088 B/op 17 allocs/op
287-
BenchmarkParserFunc_filter_compareNE-4 633304 1918 ns/op 1344 B/op 19 allocs/op
288-
BenchmarkParserFunc_filter_compareGE-4 800367 1551 ns/op 1088 B/op 17 allocs/op
289-
BenchmarkParserFunc_filter_compareGT-4 859352 1552 ns/op 1088 B/op 17 allocs/op
290-
BenchmarkParserFunc_filter_compareLE-4 750492 1567 ns/op 1088 B/op 17 allocs/op
291-
BenchmarkParserFunc_filter_compareLT-4 800217 1560 ns/op 1088 B/op 17 allocs/op
292-
BenchmarkParserFunc_filter_regex-4 669060 1704 ns/op 1096 B/op 17 allocs/op
253+
BenchmarkRetrieve_dotNotation-4 802390 1282 ns/op 432 B/op 18 allocs/op
254+
BenchmarkRetrieve_bracketNotation-4 801190 1578 ns/op 512 B/op 21 allocs/op
255+
BenchmarkRetrieve_wildcard_identifier_dotNotation-4 856964 1420 ns/op 456 B/op 20 allocs/op
256+
BenchmarkRetrieve_wildcard_identifier_bracketNotation-4 707596 1614 ns/op 504 B/op 21 allocs/op
257+
BenchmarkRetrieve_multi_identifier-4 480096 2443 ns/op 856 B/op 33 allocs/op
258+
BenchmarkRetrieve_qualifier_index-4 750308 1621 ns/op 568 B/op 22 allocs/op
259+
BenchmarkRetrieve_qualifier_slice-4 600488 2106 ns/op 688 B/op 29 allocs/op
260+
BenchmarkRetrieve_qualifier_wildcard-4 800319 1550 ns/op 504 B/op 21 allocs/op
261+
BenchmarkRetrieve_qualifier_union-4 462747 2539 ns/op 904 B/op 34 allocs/op
262+
BenchmarkRetrieve_filter_logicalOR-4 218623 5463 ns/op 1853 B/op 45 allocs/op
263+
BenchmarkRetrieve_filter_logicalAND-4 226866 5465 ns/op 1853 B/op 45 allocs/op
264+
BenchmarkRetrieve_filter_nodeFilter-4 260784 4746 ns/op 1488 B/op 41 allocs/op
265+
BenchmarkRetrieve_filter_logicalNOT-4 261564 4606 ns/op 1840 B/op 47 allocs/op
266+
BenchmarkRetrieve_filter_compareEQ-4 227083 5236 ns/op 1992 B/op 51 allocs/op
267+
BenchmarkRetrieve_filter_compareNE-4 221324 5512 ns/op 2264 B/op 54 allocs/op
268+
BenchmarkRetrieve_filter_compareGE-4 231394 5343 ns/op 1992 B/op 51 allocs/op
269+
BenchmarkRetrieve_filter_compareGT-4 237956 5232 ns/op 1880 B/op 50 allocs/op
270+
BenchmarkRetrieve_filter_compareLE-4 231217 5232 ns/op 1976 B/op 50 allocs/op
271+
BenchmarkRetrieve_filter_compareLT-4 227025 5219 ns/op 1880 B/op 49 allocs/op
272+
BenchmarkRetrieve_filter_regex-4 168806 7237 ns/op 2833 B/op 62 allocs/op
273+
BenchmarkParserFunc_dotNotation-4 4852603 248 ns/op 144 B/op 5 allocs/op
274+
BenchmarkParserFunc_bracketNotation-4 4877554 247 ns/op 144 B/op 5 allocs/op
275+
BenchmarkParserFunc_wildcard_identifier_dotNotation-4 3003252 399 ns/op 192 B/op 7 allocs/op
276+
BenchmarkParserFunc_wildcard_identifier_bracketNotation-4 2943961 408 ns/op 192 B/op 7 allocs/op
277+
BenchmarkParserFunc_multi_identifier-4 2593132 456 ns/op 240 B/op 8 allocs/op
278+
BenchmarkParserFunc_qualifier_index-4 3682868 326 ns/op 224 B/op 7 allocs/op
279+
BenchmarkParserFunc_qualifier_slice-4 3730786 330 ns/op 192 B/op 7 allocs/op
280+
BenchmarkParserFunc_qualifier_wildcard-4 3702061 321 ns/op 192 B/op 7 allocs/op
281+
BenchmarkParserFunc_qualifier_union-4 2053358 587 ns/op 344 B/op 12 allocs/op
282+
BenchmarkParserFunc_filter_logicalOR-4 816764 1380 ns/op 1104 B/op 17 allocs/op
283+
BenchmarkParserFunc_filter_logicalAND-4 925590 1375 ns/op 1104 B/op 17 allocs/op
284+
BenchmarkParserFunc_filter_nodeFilter-4 1000000 1009 ns/op 832 B/op 14 allocs/op
285+
BenchmarkParserFunc_filter_logicalNOT-4 857142 1533 ns/op 1168 B/op 19 allocs/op
286+
BenchmarkParserFunc_filter_compareEQ-4 750130 1575 ns/op 1088 B/op 16 allocs/op
287+
BenchmarkParserFunc_filter_compareNE-4 667159 1823 ns/op 1344 B/op 18 allocs/op
288+
BenchmarkParserFunc_filter_compareGE-4 858307 1471 ns/op 1088 B/op 16 allocs/op
289+
BenchmarkParserFunc_filter_compareGT-4 802525 1477 ns/op 1088 B/op 16 allocs/op
290+
BenchmarkParserFunc_filter_compareLE-4 833859 1482 ns/op 1088 B/op 16 allocs/op
291+
BenchmarkParserFunc_filter_compareLT-4 707726 1497 ns/op 1088 B/op 16 allocs/op
292+
BenchmarkParserFunc_filter_regex-4 799903 1633 ns/op 1095 B/op 16 allocs/op
293293
```
294294
</details>
295295

@@ -299,13 +299,13 @@ BenchmarkParserFunc_filter_regex-4 669060 1704
299299
- Identifier
300300
- [x] identifier in dot notations
301301
- [x] identifier in bracket notations
302-
- [x] asterisk identifier
302+
- [x] wildcard
303303
- [x] multiple-identifier in bracket
304304
- [x] recursive retrieve
305305
- Qualifier
306306
- [x] index
307307
- [x] slice
308-
- [x] asterisk
308+
- [x] wildcard
309309
- Filter
310310
- [x] logical operation
311311
- [x] comparator

jsonpath.peg

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ dotChildIdentifier <-
7979
< ( '\\' '\\' / '\\' [.[()=!><\t\r\n ] / [^\\.[()=!><\t\r\n ] )+ > !'()' {
8080
unescapedText := p.unescape(text)
8181
if unescapedText == `*` {
82-
p.pushChildAsteriskIdentifier(unescapedText)
82+
p.pushChildWildcardIdentifier(unescapedText)
8383
} else {
8484
p.pushChildSingleIdentifier(unescapedText)
8585
}
@@ -157,7 +157,7 @@ index <-
157157
} /
158158

159159
'*' {
160-
p.pushAsteriskSubscript()
160+
p.pushWildcardSubscript()
161161
}
162162
) {
163163
p.pushUnionQualifier(p.pop().(syntaxSubscript))

jsonpath.peg.go

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonpath_parser.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ func (p *jsonPathParser) pushChildMultiIdentifier(identifiers []string) {
192192
})
193193
}
194194

195-
func (p *jsonPathParser) pushChildAsteriskIdentifier(text string) {
196-
p.push(&syntaxChildAsteriskIdentifier{
195+
func (p *jsonPathParser) pushChildWildcardIdentifier(text string) {
196+
p.push(&syntaxChildWildcardIdentifier{
197197
syntaxBasicNode: &syntaxBasicNode{
198198
text: text,
199199
multiValue: true,
@@ -283,8 +283,8 @@ func (p *jsonPathParser) pushOmittedIndexSubscript(text string) {
283283
p._pushIndexSubscript(text, true)
284284
}
285285

286-
func (p *jsonPathParser) pushAsteriskSubscript() {
287-
p.push(&syntaxAsteriskSubscript{
286+
func (p *jsonPathParser) pushWildcardSubscript() {
287+
p.push(&syntaxWildcardSubscript{
288288
syntaxBasicSubscript: &syntaxBasicSubscript{
289289
multiValue: true,
290290
},

syntax_node_identifier_child_asterisk.go renamed to syntax_node_identifier_child_wildcard.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package jsonpath
22

33
import "sort"
44

5-
type syntaxChildAsteriskIdentifier struct {
5+
type syntaxChildWildcardIdentifier struct {
66
*syntaxBasicNode
77
}
88

9-
func (i *syntaxChildAsteriskIdentifier) retrieve(
9+
func (i *syntaxChildWildcardIdentifier) retrieve(
1010
root, current interface{}, result *[]interface{}) error {
1111

1212
childErrorMap := make(map[error]struct{}, 1)
@@ -35,7 +35,7 @@ func (i *syntaxChildAsteriskIdentifier) retrieve(
3535
return nil
3636
}
3737

38-
func (i *syntaxChildAsteriskIdentifier) retrieveMap(
38+
func (i *syntaxChildWildcardIdentifier) retrieveMap(
3939
root interface{}, srcMap map[string]interface{}, result *[]interface{},
4040
childErrorMap map[error]struct{}) error {
4141

@@ -66,7 +66,7 @@ func (i *syntaxChildAsteriskIdentifier) retrieveMap(
6666
return lastError
6767
}
6868

69-
func (i *syntaxChildAsteriskIdentifier) retrieveList(
69+
func (i *syntaxChildWildcardIdentifier) retrieveList(
7070
root interface{}, srcList []interface{}, result *[]interface{},
7171
childErrorMap map[error]struct{}) error {
7272

syntax_node_qualifier_union.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ func (u *syntaxUnionQualifier) retrieve(
1313

1414
if _, ok := current.(map[string]interface{}); ok {
1515
if len(u.subscripts) == 1 {
16-
if _, ok := u.subscripts[0].(*syntaxAsteriskSubscript); ok {
16+
if _, ok := u.subscripts[0].(*syntaxWildcardSubscript); ok {
1717
// Switch to the all node analysis mode,
1818
// if "current" variable points the map structure and
19-
// specifying the Asterisk subscript
20-
asteriskIdentifier := syntaxChildAsteriskIdentifier{
19+
// specifying the Wildcard subscript
20+
wildcardIdentifier := syntaxChildWildcardIdentifier{
2121
syntaxBasicNode: &syntaxBasicNode{
2222
text: u.text,
2323
next: u.next,
2424
},
2525
}
26-
return asteriskIdentifier.retrieve(root, current, result)
26+
return wildcardIdentifier.retrieve(root, current, result)
2727
}
2828
}
2929
}

syntax_subscript_asterisk.go renamed to syntax_subscript_wildcard.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package jsonpath
22

3-
type syntaxAsteriskSubscript struct {
3+
type syntaxWildcardSubscript struct {
44
*syntaxBasicSubscript
55
}
66

7-
func (*syntaxAsteriskSubscript) getIndexes(src []interface{}) []int {
7+
func (*syntaxWildcardSubscript) getIndexes(src []interface{}) []int {
88
index, result := 0, make([]int, len(src))
99
for i := range src {
1010
result[index] = i

test_jsonpath_benchmark_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ func BenchmarkRetrieve_bracketNotation(b *testing.B) {
5656
execRetrieve(jsonPath, srcJSON, b)
5757
}
5858

59-
func BenchmarkRetrieve_asterisk_identifier_dotNotation(b *testing.B) {
59+
func BenchmarkRetrieve_wildcard_identifier_dotNotation(b *testing.B) {
6060
jsonPath := `$.*`
6161
srcJSON := `{"a":123.456}`
6262
execRetrieve(jsonPath, srcJSON, b)
6363
}
6464

65-
func BenchmarkRetrieve_asterisk_identifier_bracketNotation(b *testing.B) {
65+
func BenchmarkRetrieve_wildcard_identifier_bracketNotation(b *testing.B) {
6666
jsonPath := `$[*]`
6767
srcJSON := `{"a":123.456}`
6868
execRetrieve(jsonPath, srcJSON, b)
@@ -86,7 +86,7 @@ func BenchmarkRetrieve_qualifier_slice(b *testing.B) {
8686
execRetrieve(jsonPath, srcJSON, b)
8787
}
8888

89-
func BenchmarkRetrieve_qualifier_asterisk(b *testing.B) {
89+
func BenchmarkRetrieve_qualifier_wildcard(b *testing.B) {
9090
jsonPath := `$[*]`
9191
srcJSON := `[{"a":123.456}]`
9292
execRetrieve(jsonPath, srcJSON, b)
@@ -179,13 +179,13 @@ func BenchmarkParserFunc_bracketNotation(b *testing.B) {
179179
execParserFunc(jsonPath, srcJSON, b)
180180
}
181181

182-
func BenchmarkParserFunc_asterisk_identifier_dotNotation(b *testing.B) {
182+
func BenchmarkParserFunc_wildcard_identifier_dotNotation(b *testing.B) {
183183
jsonPath := `$.*`
184184
srcJSON := `{"a":123.456}`
185185
execParserFunc(jsonPath, srcJSON, b)
186186
}
187187

188-
func BenchmarkParserFunc_asterisk_identifier_bracketNotation(b *testing.B) {
188+
func BenchmarkParserFunc_wildcard_identifier_bracketNotation(b *testing.B) {
189189
jsonPath := `$[*]`
190190
srcJSON := `{"a":123.456}`
191191
execParserFunc(jsonPath, srcJSON, b)
@@ -209,7 +209,7 @@ func BenchmarkParserFunc_qualifier_slice(b *testing.B) {
209209
execParserFunc(jsonPath, srcJSON, b)
210210
}
211211

212-
func BenchmarkParserFunc_qualifier_asterisk(b *testing.B) {
212+
func BenchmarkParserFunc_qualifier_wildcard(b *testing.B) {
213213
jsonPath := `$[*]`
214214
srcJSON := `[{"a":123.456}]`
215215
execParserFunc(jsonPath, srcJSON, b)

0 commit comments

Comments
 (0)