-
Notifications
You must be signed in to change notification settings - Fork 0
/
wynik_5_A.json
248 lines (229 loc) · 7.92 KB
/
wynik_5_A.json
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
MongoDB shell version v4.4.4
connecting to: mongodb://127.0.0.1:27017/atd?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("81cb8593-3e7b-4c2c-970a-31c4332108fd") }
MongoDB server version: 4.4.4
{
"_batch" : [
{
"_id" : "Poland",
"totalCredits" : 0,
"avgCredits" : null
}
],
"_useReadCommands" : true,
"_cursorid" : NumberLong(0),
"_batchSize" : undefined,
"_maxAwaitTimeMS" : undefined,
"_txnNumber" : undefined,
"_ns" : "atd.people",
"_db" : atd,
"_collName" : "people",
"_cursorHandle" : {
},
"isClosed" : function() {
if (this._useReadCommands) {
return bsonWoCompare({_: this._cursorid}, {_: NumberLong(0)}) === 0;
}
return this._cursor.isClosed();
},
"isExhausted" : function() {
return this.isClosed() && this.objsLeftInBatch() === 0;
},
"close" : function() {
if (!this._useReadCommands) {
this._cursor.close();
} else if (bsonWoCompare({_: this._cursorid}, {_: NumberLong(0)}) !== 0) {
var killCursorCmd = {
killCursors: this._collName,
cursors: [this._cursorid],
};
var cmdRes = this._db.runCommand(killCursorCmd);
if (cmdRes.ok != 1) {
throw _getErrorWithCode(cmdRes, "killCursors command failed: " + tojson(cmdRes));
}
this._cursorHandle.zeroCursorId();
this._cursorid = NumberLong(0);
}
},
"_updatePostBatchResumeToken" : function(cursorObj) {
if (cursorObj.postBatchResumeToken) {
this._postBatchResumeToken = cursorObj.postBatchResumeToken;
if ((cursorObj.firstBatch || cursorObj.nextBatch).length === 0) {
this._resumeToken = this._postBatchResumeToken;
}
this._isChangeStream = true;
}
},
"_runGetMoreCommand" : function() {
// Construct the getMore command.
var getMoreCmd = {getMore: this._cursorid, collection: this._collName};
if (this._batchSize) {
getMoreCmd["batchSize"] = this._batchSize;
}
// maxAwaitTimeMS is only supported when using read commands.
if (this._maxAwaitTimeMS) {
getMoreCmd.maxTimeMS = this._maxAwaitTimeMS;
}
if (this._txnNumber) {
getMoreCmd.txnNumber = NumberLong(this._txnNumber);
getMoreCmd.autocommit = false;
}
// Deliver the getMore command, and check for errors in the response.
var cmdRes = this._db.runCommand(getMoreCmd);
assert.commandWorked(cmdRes, () => "getMore command failed: " + tojson(cmdRes));
if (this._ns !== cmdRes.cursor.ns) {
throw Error("unexpected collection in getMore response: " + this._ns +
" != " + cmdRes.cursor.ns);
}
if (!cmdRes.cursor.id.compare(NumberLong("0"))) {
this._cursorHandle.zeroCursorId();
this._cursorid = NumberLong("0");
} else if (this._cursorid.compare(cmdRes.cursor.id)) {
throw Error("unexpected cursor id: " + this._cursorid.toString() +
" != " + cmdRes.cursor.id.toString());
}
// If the command result represents a change stream cursor, update our postBatchResumeToken.
this._updatePostBatchResumeToken(cmdRes.cursor);
// Successfully retrieved the next batch.
this._batch = cmdRes.cursor.nextBatch.reverse();
},
"_hasNextUsingCommands" : function() {
assert(this._useReadCommands);
if (!this._batch.length) {
if (!this._cursorid.compare(NumberLong("0"))) {
return false;
}
this._runGetMoreCommand();
}
return this._batch.length > 0;
},
"hasNext" : function() {
if (this._useReadCommands) {
return this._hasNextUsingCommands();
}
return this._batch.length || this._cursor.hasNext();
},
"next" : function() {
if (this._batch.length) {
// Pop the next result off the batch.
const nextDoc = this._batch.pop();
if (this._isChangeStream) {
// If this is the last result in the batch, the postBatchResumeToken becomes the current
// resume token for the cursor. Otherwise, the resume token is the _id of 'nextDoc'.
this._resumeToken = (this._batch.length ? nextDoc._id : this._postBatchResumeToken);
}
return nextDoc;
} else if (this._useReadCommands) {
// Have to call hasNext() here, as this is where we may issue a getMore in order to retrieve
// the next batch of results.
if (!this.hasNext())
throw Error("error hasNext: false");
return this._batch.pop();
} else {
if (!this._cursor.hasNext())
throw Error("error hasNext: false");
var ret = this._cursor.next();
if (ret.$err)
throw _getErrorWithCode(ret, "error: " + tojson(ret));
return ret;
}
},
"objsLeftInBatch" : function() {
if (this._useReadCommands) {
return this._batch.length;
} else if (this._batch.length) {
return this._batch.length;
} else {
return this._cursor.objsLeftInBatch();
}
},
"getId" : function() {
return this._cursorid;
},
"getResumeToken" : function() {
// Return the most recent recorded resume token, if such a token exists.
return this._resumeToken;
},
"help" : function() {
// This is the same as the "Cursor Methods" section of DBQuery.help().
print("\nCursor methods");
print("\t.toArray() - iterates through docs and returns an array of the results");
print("\t.forEach( func )");
print("\t.map( func )");
print("\t.hasNext()");
print("\t.next()");
print(
"\t.objsLeftInBatch() - returns count of docs left in current batch (when exhausted, a new getMore will be issued)");
print("\t.itcount() - iterates through documents and counts them");
print(
"\t.getResumeToken() - for a change stream cursor, obtains the most recent valid resume token, if it exists.");
print("\t.pretty() - pretty print each document, possibly over multiple lines");
print("\t.close()");
},
"toArray" : function() {
if (this._arr)
return this._arr;
var a = [];
while (this.hasNext())
a.push(this.next());
this._arr = a;
return a;
},
"forEach" : function(func) {
while (this.hasNext())
func(this.next());
},
"map" : function(func) {
var a = [];
while (this.hasNext())
a.push(func(this.next()));
return a;
},
"itcount" : function() {
var num = 0;
// Track how many bytes we've used this cursor to iterate iterated. This function can be called
// with some very large cursors. SpiderMonkey appears happy to allow these objects to
// accumulate, so regular gc() avoids an overly large memory footprint.
//
// TODO: migrate this function into c++
var bytesSinceGC = 0;
while (this.hasNext()) {
num++;
var nextDoc = this.next();
bytesSinceGC += Object.bsonsize(nextDoc);
// Garbage collect every 10 MB.
if (bytesSinceGC > (10 * 1024 * 1024)) {
bytesSinceGC = 0;
gc();
}
}
return num;
},
"shellPrint" : function() {
try {
var start = new Date().getTime();
var n = 0;
while (this.hasNext() && n < DBQuery.shellBatchSize) {
var s = this._prettyShell ? tojson(this.next()) : tojson(this.next(), "", true);
print(s);
n++;
}
if (typeof _verboseShell !== 'undefined' && _verboseShell) {
var time = new Date().getTime() - start;
print("Fetched " + n + " record(s) in " + time + "ms");
}
if (this.hasNext()) {
print("Type \"it\" for more");
___it___ = this;
} else {
___it___ = null;
}
} catch (e) {
print(e);
}
},
"pretty" : function() {
this._prettyShell = true;
return this;
}
}