node-es-transformer 1.0.0-alpha11 → 1.0.0-alpha12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node-es-transformer.cjs.js +37 -17
- package/dist/node-es-transformer.esm.js +37 -17
- package/package.json +1 -1
- package/CHANGELOG.md +0 -32
|
@@ -120,6 +120,8 @@ var EventEmitter = require('events');
|
|
|
120
120
|
|
|
121
121
|
var queueEmitter = new EventEmitter();
|
|
122
122
|
|
|
123
|
+
var parallelCalls = 1;
|
|
124
|
+
|
|
123
125
|
// a simple helper queue to bulk index documents
|
|
124
126
|
function indexQueueFactory(ref) {
|
|
125
127
|
var client = ref.targetClient;
|
|
@@ -130,36 +132,54 @@ function indexQueueFactory(ref) {
|
|
|
130
132
|
|
|
131
133
|
var buffer = [];
|
|
132
134
|
var queue = [];
|
|
133
|
-
var ingesting =
|
|
135
|
+
var ingesting = 0;
|
|
136
|
+
var ingestTimes = [];
|
|
134
137
|
|
|
135
|
-
var ingest =
|
|
138
|
+
var ingest = function (b) {
|
|
136
139
|
if (typeof b !== 'undefined') {
|
|
137
140
|
queue.push(b);
|
|
138
141
|
queueEmitter.emit('queue-size', queue.length);
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
if (
|
|
144
|
+
if (ingestTimes.length > 5) { ingestTimes = ingestTimes.slice(-5); }
|
|
145
|
+
|
|
146
|
+
if (ingesting < parallelCalls) {
|
|
142
147
|
var docs = queue.shift();
|
|
148
|
+
|
|
143
149
|
queueEmitter.emit('queue-size', queue.length);
|
|
144
|
-
|
|
150
|
+
if (queue.length <= 5) {
|
|
151
|
+
queueEmitter.emit('resume');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
ingesting += 1;
|
|
155
|
+
|
|
145
156
|
if (verbose)
|
|
146
157
|
{ console.log(("bulk ingest docs: " + (docs.length / 2) + ", queue length: " + (queue.length))); }
|
|
147
158
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
159
|
+
var start = Date.now();
|
|
160
|
+
client.bulk({ body: docs }).then(function () {
|
|
161
|
+
var end = Date.now();
|
|
162
|
+
var delta = end - start;
|
|
163
|
+
ingestTimes.push(delta);
|
|
164
|
+
ingesting -= 1;
|
|
165
|
+
|
|
166
|
+
var ingestTimesMovingAverage =
|
|
167
|
+
ingestTimes.length > 0 ? ingestTimes.reduce(function (p, c) { return p + c; }, 0) / ingestTimes.length : 0;
|
|
168
|
+
var ingestTimesMovingAverageSeconds = Math.floor(ingestTimesMovingAverage / 1000);
|
|
169
|
+
|
|
170
|
+
if (ingestTimes.length > 0 && ingestTimesMovingAverageSeconds < 30 && parallelCalls < 10) {
|
|
171
|
+
parallelCalls += 1;
|
|
172
|
+
} else if (
|
|
173
|
+
ingestTimes.length > 0 &&
|
|
174
|
+
ingestTimesMovingAverageSeconds >= 30 &&
|
|
175
|
+
parallelCalls > 1
|
|
176
|
+
) {
|
|
177
|
+
parallelCalls -= 1;
|
|
178
|
+
}
|
|
151
179
|
if (queue.length > 0) {
|
|
152
180
|
ingest();
|
|
153
181
|
}
|
|
154
|
-
}
|
|
155
|
-
console.log('bulk index error', err);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// console.log(`ingest: queue.length ${queue.length}`);
|
|
160
|
-
if (queue.length === 0) {
|
|
161
|
-
queueEmitter.emit('queue-size', 0);
|
|
162
|
-
queueEmitter.emit('resume');
|
|
182
|
+
});
|
|
163
183
|
}
|
|
164
184
|
};
|
|
165
185
|
|
|
@@ -190,7 +210,7 @@ function indexQueueFactory(ref) {
|
|
|
190
210
|
};
|
|
191
211
|
}
|
|
192
212
|
|
|
193
|
-
var MAX_QUEUE_SIZE =
|
|
213
|
+
var MAX_QUEUE_SIZE = 15;
|
|
194
214
|
|
|
195
215
|
// create a new progress bar instance and use shades_classic theme
|
|
196
216
|
var progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
|
|
@@ -116,6 +116,8 @@ var EventEmitter = require('events');
|
|
|
116
116
|
|
|
117
117
|
var queueEmitter = new EventEmitter();
|
|
118
118
|
|
|
119
|
+
var parallelCalls = 1;
|
|
120
|
+
|
|
119
121
|
// a simple helper queue to bulk index documents
|
|
120
122
|
function indexQueueFactory(ref) {
|
|
121
123
|
var client = ref.targetClient;
|
|
@@ -126,36 +128,54 @@ function indexQueueFactory(ref) {
|
|
|
126
128
|
|
|
127
129
|
var buffer = [];
|
|
128
130
|
var queue = [];
|
|
129
|
-
var ingesting =
|
|
131
|
+
var ingesting = 0;
|
|
132
|
+
var ingestTimes = [];
|
|
130
133
|
|
|
131
|
-
var ingest =
|
|
134
|
+
var ingest = function (b) {
|
|
132
135
|
if (typeof b !== 'undefined') {
|
|
133
136
|
queue.push(b);
|
|
134
137
|
queueEmitter.emit('queue-size', queue.length);
|
|
135
138
|
}
|
|
136
139
|
|
|
137
|
-
if (
|
|
140
|
+
if (ingestTimes.length > 5) { ingestTimes = ingestTimes.slice(-5); }
|
|
141
|
+
|
|
142
|
+
if (ingesting < parallelCalls) {
|
|
138
143
|
var docs = queue.shift();
|
|
144
|
+
|
|
139
145
|
queueEmitter.emit('queue-size', queue.length);
|
|
140
|
-
|
|
146
|
+
if (queue.length <= 5) {
|
|
147
|
+
queueEmitter.emit('resume');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
ingesting += 1;
|
|
151
|
+
|
|
141
152
|
if (verbose)
|
|
142
153
|
{ console.log(("bulk ingest docs: " + (docs.length / 2) + ", queue length: " + (queue.length))); }
|
|
143
154
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
155
|
+
var start = Date.now();
|
|
156
|
+
client.bulk({ body: docs }).then(function () {
|
|
157
|
+
var end = Date.now();
|
|
158
|
+
var delta = end - start;
|
|
159
|
+
ingestTimes.push(delta);
|
|
160
|
+
ingesting -= 1;
|
|
161
|
+
|
|
162
|
+
var ingestTimesMovingAverage =
|
|
163
|
+
ingestTimes.length > 0 ? ingestTimes.reduce(function (p, c) { return p + c; }, 0) / ingestTimes.length : 0;
|
|
164
|
+
var ingestTimesMovingAverageSeconds = Math.floor(ingestTimesMovingAverage / 1000);
|
|
165
|
+
|
|
166
|
+
if (ingestTimes.length > 0 && ingestTimesMovingAverageSeconds < 30 && parallelCalls < 10) {
|
|
167
|
+
parallelCalls += 1;
|
|
168
|
+
} else if (
|
|
169
|
+
ingestTimes.length > 0 &&
|
|
170
|
+
ingestTimesMovingAverageSeconds >= 30 &&
|
|
171
|
+
parallelCalls > 1
|
|
172
|
+
) {
|
|
173
|
+
parallelCalls -= 1;
|
|
174
|
+
}
|
|
147
175
|
if (queue.length > 0) {
|
|
148
176
|
ingest();
|
|
149
177
|
}
|
|
150
|
-
}
|
|
151
|
-
console.log('bulk index error', err);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// console.log(`ingest: queue.length ${queue.length}`);
|
|
156
|
-
if (queue.length === 0) {
|
|
157
|
-
queueEmitter.emit('queue-size', 0);
|
|
158
|
-
queueEmitter.emit('resume');
|
|
178
|
+
});
|
|
159
179
|
}
|
|
160
180
|
};
|
|
161
181
|
|
|
@@ -186,7 +206,7 @@ function indexQueueFactory(ref) {
|
|
|
186
206
|
};
|
|
187
207
|
}
|
|
188
208
|
|
|
189
|
-
var MAX_QUEUE_SIZE =
|
|
209
|
+
var MAX_QUEUE_SIZE = 15;
|
|
190
210
|
|
|
191
211
|
// create a new progress bar instance and use shades_classic theme
|
|
192
212
|
var progressBar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"license": "Apache-2.0",
|
|
15
15
|
"author": "Walter Rafelsberger <walter@rafelsberger.at>",
|
|
16
16
|
"contributors": [],
|
|
17
|
-
"version": "1.0.0-
|
|
17
|
+
"version": "1.0.0-alpha12",
|
|
18
18
|
"main": "dist/node-es-transformer.cjs.js",
|
|
19
19
|
"module": "dist/node-es-transformer.esm.js",
|
|
20
20
|
"dependencies": {
|
package/CHANGELOG.md
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
## [1.0.0-alpha11](https://github.com/walterra/node-es-transformer/compare/v1.0.0-alpha10...v1.0.0-alpha11) (2023-10-12)
|
|
6
|
-
|
|
7
|
-
### Features
|
|
8
|
-
|
|
9
|
-
- new option 'indexMappingTotalFieldsLimit' ([92edad1](https://github.com/walterra/node-es-transformer/commit/92edad18da7186d3881fc181e6e88b7929bed2d4))
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
- fixes bufferSize to be applied to index reader too ([ffc3749](https://github.com/walterra/node-es-transformer/commit/ffc3749e296cd39f39924571c197986addc756ff))
|
|
14
|
-
|
|
15
|
-
## [`v1.0.0-alpha10`](https://github.com/walterra/node-es-transformer/releases/tag/v1.0.0-alpha10)
|
|
16
|
-
|
|
17
|
-
- New option `mappingsOverride` (0b951e1).
|
|
18
|
-
- New option `query` (45f91db).
|
|
19
|
-
|
|
20
|
-
## [`v1.0.0-alpha9`](https://github.com/walterra/node-es-transformer/releases/tag/v1.0.0-alpha9)
|
|
21
|
-
|
|
22
|
-
- Source and target configs are now expected to be passed in as complete client configs instead of individual parameters (5e6d0c7).
|
|
23
|
-
|
|
24
|
-
## [`v1.0.0-alpha8`](https://github.com/walterra/node-es-transformer/releases/tag/v1.0.0-alpha8)
|
|
25
|
-
|
|
26
|
-
- Exposes events and introduces `finish` event (a3e5810).
|
|
27
|
-
- Drop support for `_type` from `6.x` indices (3a26a84).
|
|
28
|
-
|
|
29
|
-
## [`v1.0.0-alpha7`](https://github.com/walterra/node-es-transformer/releases/tag/v1.0.0-alpha7)
|
|
30
|
-
|
|
31
|
-
- This version locks down `event-stream` to version `3.3.4` because of the security issue described here: https://github.com/dominictarr/event-stream/issues/116
|
|
32
|
-
- Last version to support `_type` from `6.x` indices.
|