Skip to content

Commit 1b7f4f1

Browse files
committed
fix(stats): close accumulator to finalize output
1 parent 4e9d716 commit 1b7f4f1

39 files changed

+1715
-239
lines changed

api/datasets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func (h *DatasetHandlers) replyWithGetResponse(w http.ResponseWriter, r *http.Re
288288
return
289289
}
290290

291-
if params.Selector == "body" {
291+
if params.Selector != "" {
292292
page := util.PageFromRequest(r)
293293
dataResponse := DataResponse{
294294
Path: result.Dataset.BodyPath,

api/datasets_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ func TestDatasetGet(t *testing.T) {
492492
assertStatusCode(t, "get meta component", actualStatusCode, 200)
493493

494494
// Can get at an ipfs version
495-
actualStatusCode, _ = APICall("/get/peer/test_ds/at/mem/QmfEv94F7QAhZB5a9sRjMWPrhDjBwcUuWcJrYWEAjvs4AW", dsHandler.GetHandler)
495+
actualStatusCode, _ = APICall("/get/peer/test_ds/at/mem/QmeTvt83npHg4HoxL8bp8yz5bmG88hUVvRc5k9taW8uxTr", dsHandler.GetHandler)
496496
assertStatusCode(t, "get at content-addressed version", actualStatusCode, 200)
497497

498498
// Error 404 if ipfs version doesn't exist

api/testdata/api.snapshot

2.7 KB
Binary file not shown.

api/testdata/cities/exported.zip

1 Byte
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "test_ds",
3-
"path": "/mem/QmfEv94F7QAhZB5a9sRjMWPrhDjBwcUuWcJrYWEAjvs4AW",
3+
"path": "/mem/QmeTvt83npHg4HoxL8bp8yz5bmG88hUVvRc5k9taW8uxTr",
44
"peername": "peer",
55
"qri": "ds:0"
66
}

base/dataset_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func TestRawDatasetRefs(t *testing.T) {
9595
Published: false
9696
`, map[string]string{
9797
"ProfileID": "QmZePf5LeXow3RW5U1AgEiNbW46YnRGhZ7HPvm1UmPFPwt",
98-
"Path": "/mem/QmUfofLxWuGjECZcN1JbZaXZ2C2kQckpNArPeNutLpbuKE",
98+
"Path": "/mem/QmbZEoPWbvtDhiLgEcteeBumC2sKQU1eVBEEvrRexexRMW",
9999
})
100100

101101
if diff := cmp.Diff(expect, actual); diff != "" {

base/dsfs/compute_fields.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ func (cff *computeFieldsFile) handleRows(ctx context.Context) {
269269
cff.ds.Structure.Depth = depth + 1 // need to add one for the original enclosure
270270
cff.ds.Structure.Length = cff.bytesRead
271271

272+
// as we're using a manual setup on the EntryReader we also need
273+
// to manually close the accumulator to finalize results before write
274+
cff.acc.Close()
275+
272276
// If the body exists and is small enough, deserialize it and assign it
273277
if cff.diffMessageBuf != nil {
274278
if err := cff.diffMessageBuf.Close(); err != nil {

base/dsfs/dataset_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ func TestCreateDataset(t *testing.T) {
174174
repoFiles int // expected total count of files in repo after test execution
175175
}{
176176
{"cities",
177-
"/mem/Qmf9ADYUJum5wgppEHAVRDXTzjwi5r9vaCdUbKxVksbwrS", nil, 9},
177+
"/mem/QmcDaRWnD4e58HsM9rsT3SY5vfhK9hAqmFVppc71JnBEpi", nil, 9},
178178
{"all_fields",
179-
"/mem/QmYBKKMfFnWYRXmN1Jh2GvzMMHSqoTPgnezbRu5rrU3R9U", nil, 19},
179+
"/mem/QmQ2yM2pCQbYcWxdP4R1yeVKBkkMR8ZjKr3x8RzJfrXQmu", nil, 19},
180180
{"cities_no_commit_title",
181-
"/mem/QmVkfXUpKA5QyH8gjam4Ynjnny6HJRSMUvsmR9ni8HfkU8", nil, 22},
181+
"/mem/QmVFBZpQ9k5w8jF9A1jTRfQ2YW5y4haSNjmqj5H9c23DqW", nil, 22},
182182
{"craigslist",
183-
"/mem/QmZboLmWvgUKnrGeMqL8b3M6YA5JaiS2i6MQBxeJ5G5Xho", nil, 28},
183+
"/mem/QmNiNcJ4dtG4GhZSGdYWZzL4ojvx3wndNQRCErG94ywfFP", nil, 28},
184184
}
185185

186186
for _, c := range good {

base/dsfs/testdata/all_fields/expect.dataset.json

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"bodyPath": "/mem/QmcCcPTqmckdXLBwPQXxfyW2BbFcUT6gqv9oGeWDkrNTyD",
33
"commit": {
44
"message": "created dataset",
5-
"path": "/mem/QmeT15DVgG6wC3sEAm8m3DXPeC7s96R2TYY73nfQ7XDjmM",
5+
"path": "/mem/QmZZfXr5fHxAvei1Ce5tWnkVn63HKGSAK7syVdAbxcWbLS",
66
"qri": "cm:0",
7-
"signature": "KE5udsl1gV+y20eZU0yUuBXkT2qbhVQbMeeGqGvPp9yZgY9HJ7x70XM4+WoJIVA+MpsiAAltETzr8xUUp6giEtYhfUTOrv+EN9Q8ZHIfWBQ9JEp66o3UYMeidSXRI9JocEEscXI2LGeHvbFrwaf22naHq72k3Bq4U7oDmOFxh4oqJyaxHjR7XR67+odasH/HGhJsENwCQ+4XaxFFmYOP568VImzOjpfS/Raepb34FtdDdWuhCX0aWd0C6S1JK253Z3D4DrBo41s9aTGgSuJyAwKoCKgs9yqcsubD1BUlf8hRX8y60+vn3TcZnACdvsDgn/7xKiaPABec/gm9zDpLOw==",
7+
"signature": "GxXsCQFH00n0y92LMGPON9n1fk++Nnrzw3lCWkGW0NdN7MzIkZWKs8b0JRksJAt6UngZOlRITS2zLxHqhwI8by/QzLl08jwV30RzvyVeTIlScDfN6BHCA1CcMcxOSL6nkgqDBXIQJZozM9e4Y5NJ4t+pIyo3JoMCF0SzzlTUkD3G6g1jGDVBeqYrsdb07l1T4IdGbDBrF1U8kvKF51CLfgRH5Oj/bq4LqgoN1EoMCP/4Ke6eJzy885rJ73BYpVEhU7T0WY6iiHvFzmaJ7+lSzy6QMxGJ6+lgBaQ0NJaSNq15nH2z1SBNkN3gY4Eag5vLX78NVvp7dOnW/7xqsOVmWQ==",
88
"timestamp": "2001-01-01T01:01:01.000000001Z",
99
"title": "I'm a commit"
1010
},
@@ -44,36 +44,60 @@
4444
}
4545
},
4646
"stats": {
47-
"path": "/mem/QmQDuV6Xw8QJDov2M1kYNWfE15AvfCUaDFuCc1iemAVQSw",
47+
"path": "/mem/QmS8FiQV4pQ89vLSoqrhvnodkgXaimyZ5uuWXYqQeHea4N",
4848
"qri": "sa:0",
4949
"stats": [
5050
{
5151
"count": 5,
52-
"frequencies": {},
52+
"frequencies": {
53+
"chatham": 1,
54+
"chicago": 1,
55+
"new york": 1,
56+
"raleigh": 1,
57+
"toronto": 1
58+
},
5359
"maxLength": 8,
5460
"minLength": 7,
55-
"type": "string"
61+
"type": "string",
62+
"unique": 5
5663
},
5764
{
5865
"count": 5,
59-
"frequencies": {},
66+
"frequencies": {
67+
"250000": 1,
68+
"300000": 1,
69+
"35000": 1,
70+
"40000000": 1,
71+
"8500000": 1
72+
},
6073
"maxLength": 8,
6174
"minLength": 5,
62-
"type": "string"
75+
"type": "string",
76+
"unique": 5
6377
},
6478
{
6579
"count": 5,
66-
"frequencies": {},
80+
"frequencies": {
81+
"44.4": 2,
82+
"50.65": 1,
83+
"55.5": 1,
84+
"65.25": 1
85+
},
6786
"maxLength": 5,
6887
"minLength": 4,
69-
"type": "string"
88+
"type": "string",
89+
"unique": 4
7090
},
7191
{
7292
"count": 5,
73-
"frequencies": {},
93+
"frequencies": {
94+
"false": 1,
95+
"true": 4
96+
},
7497
"maxLength": 5,
7598
"minLength": 4,
76-
"type": "string"
99+
"type": "string",
100+
"unique": 2
77101
}
78102
]
79103
},

base/dsfs/testdata/cities/expect.dataset.json

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"bodyPath": "/mem/QmcCcPTqmckdXLBwPQXxfyW2BbFcUT6gqv9oGeWDkrNTyD",
33
"commit": {
44
"message": "created dataset",
5-
"path": "/mem/QmfZ7hswWxDjCivijUi9QkmNcp6BtXdjpHkteCFzdcSxQj",
5+
"path": "/mem/QmW2w8mjpz7bjFbbvvV7PqRmSMrB1Ybt2vWfKdtdUZbq8W",
66
"qri": "cm:0",
7-
"signature": "eH4B8CUlMlDikOw1kIHvYRGVF0Auc7PoGiUJV0vStsnYNzu9RVsI7aaODA0cAh/S5q3kc9kiid/xDfFxbpnNShj5r3RyvuFwiSZsVY+K1zNZ4FdhItv2evJs47ZOu/MuQl+cHDlzt4sbwfd4JouMNzE0W1D/1YiPnPOnaCar3dQ5mP0NAqmxSzf3w2DIa2k6/unUGRO374R4acmqiAB4tesErJB3njXRZfgjaAD3THUBB1rG+r3GROzb+r9UiZyY7aOLO55MImSJX2FI7/YqjNboZOnh2QSLKE502QsvsgackZRr95/l7nKIVx1AsslVEDU77mdEOKlCo84qmi+UPQ==",
7+
"signature": "EKuBms9Tw8dt+zslGU7w7TPjaLs6sqF+hSWhZuSm5g6jU/CYc44gH3zLpOXNlSzwv5FLramoBHkcmlFCjmjbZgAIXOwcPeQ58mrlG5KFde0yIK883xMlr+7C7wPpf6RinMFs2Y3NBhOJcuObDW1bSPENRaCJ0bBrGTH42mxkQr5j2KpkHHr+PEhWOnN63r79eeI9YtDce7WMOUiUKoBvSIRkQ3M9l3RxmqQ0bQnyZUq1J+hsd171mnDbEaMU1Ii0ehl6An5EkiwWAho/1wlMcHe3fuKzoglVR7tQuY4BceQ7IX7yj5cAqdBLJToftchscTpo6fciiFxNpAml2PUF6A==",
88
"timestamp": "2001-01-01T01:01:01.000000001Z",
99
"title": "initial commit"
1010
},
@@ -51,35 +51,68 @@
5151
}
5252
},
5353
"stats": {
54-
"path": "/mem/QmdQz7LYFDChz3SuWjKaDEkVRymmJN1XGXgpXr6rRbMnK6",
54+
"path": "/mem/QmZjVHiq1brwXQRKMDcc2TuE8UHhQCyTa3WMWnrYXJRUUG",
5555
"qri": "sa:0",
5656
"stats": [
5757
{
5858
"count": 5,
59-
"frequencies": {},
59+
"frequencies": {
60+
"chatham": 1,
61+
"chicago": 1,
62+
"new york": 1,
63+
"raleigh": 1,
64+
"toronto": 1
65+
},
6066
"maxLength": 8,
6167
"minLength": 7,
62-
"type": "string"
68+
"type": "string",
69+
"unique": 5
6370
},
6471
{
6572
"count": 5,
6673
"histogram": {
67-
"bins": null,
68-
"frequencies": []
74+
"bins": [
75+
35000,
76+
250000,
77+
300000,
78+
8500000,
79+
40000000,
80+
40000001
81+
],
82+
"frequencies": [
83+
1,
84+
1,
85+
1,
86+
1,
87+
1
88+
]
6989
},
7090
"max": 40000000,
71-
"mean": 49085000,
91+
"mean": 9817000,
92+
"median": 300000,
7293
"min": 35000,
7394
"type": "numeric"
7495
},
7596
{
7697
"count": 5,
7798
"histogram": {
78-
"bins": null,
79-
"frequencies": []
99+
"bins": [
100+
44.4,
101+
50.65,
102+
55.5,
103+
65.25,
104+
66.25
105+
],
106+
"frequencies": [
107+
2,
108+
1,
109+
1,
110+
1
111+
]
80112
},
81113
"max": 65.25,
82-
"mean": 260.2,
114+
"mean": 52.04,
115+
"median": 50.65,
83116
"min": 44.4,
84117
"type": "numeric"
85118
},

0 commit comments

Comments
 (0)