【发布时间】:2015-04-17 05:51:48
【问题描述】:
我正在尝试使用 MarkLogic 的 Node.js 读取 xml/json 文档。我已经从以下 URL 下载了 Node.js API 代码库。
https://github.com/marklogic/node-client-api
它适用于 500KB 等小型文档。但我们的要求是读取大型文档,例如 2 MB 或 10 MB。
对此,我们有两种情况,如下所述:-
案例 1:- 每当我尝试使用 MarkLogic Node.js API 读取文档时,我应该得到不止一个块,但我只得到一个块作为响应。所以由于这个原因它不起作用。
var chunks = 0;
var length = 0;
db.documents.read("test.xml").stream('chunked').
on('data', function(chunk) {
console.log(chunk);
console.log(chunk.length);
chunks++;
length += chunk.length;
}).
on('error', function(error) {
console.log(JSON.stringify(error));
}).
on('end', function() {
console.log('read '+chunks+' chunks of '+length+' length');
console.log('done');
});
案例 2:- 每当我尝试使用“http-digest-client”包读取一些大文档(如 2 MB 或 10 MB)时,它工作正常,我得到完整的 xml 作为响应。
var digest = require('http-digest-client')('<Username>', '<password>');
digest.request({
host: '<Host server>',
path: '/v1/documents?uri=test.xml',
port: 8007,
method: 'GET',
}, function (res) {
reply(res);
});
我已经在下面提到的示例中使用大文档对此进行了测试(请参阅下面的 url),但我得到了与上面案例 1 中描述的相同的响应。
https://github.com/marklogic/node-client-api/blob/develop/examples/read-stream.js#L27
根据我的要求,我想使用 MarkLogic Node.js API 阅读大文档(案例 1)。
- 如何使用 MarkLogic Node.js API 读取大型文档?
- 是否有任何选项可以增加池内存大小或任何其他内存大小?
- 此问题是否与内存大小有关?
【问题讨论】: