You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on the documentation:
"A pump reads data from its input buffer or stream and copies it to the output buffer by default:"
If I use the following example:
var datapumps = require('datapumps');
var mssql = require('mssql');
Promise = require('bluebird');
var config = {
user: 'user',
password: 'pw',
server: 'server', // You can use 'localhost\instance' to connect to named instance
database: 'db',
stream: true, // You can enable streaming globally
requestTimeout: 60000,
options: {
encrypt: false // Use this if you're on Windows Azure
}
}
var connection = new mssql.Connection(config, function (err) {
if (err) {
console.log(err);
return;
}
var request = connection.request();
//Only executed if not streaming i.e streaming = false
request.query('some query', function (err, recordset) {
// ... error checks
if (err) {
console.log(err);
}
});
//All Event Emitters are used when streaming i.e streaming = true
request.on('recordset', function (columns) {
// Emitted once for each recordset in a query
});
request.on('row', function (row) {
// Emitted for each row
extract_input_buffer.writeAsync(row);
console.log(extract_input_buffer.content.length);
});
request.on('error', function (err) {
// May be emitted multiple times
});
request.on('done', function (returnValue) {
// Always emitted as the last one
connection.close();
extract_input_buffer.seal();
});
});
var extract_pump = new datapumps.Pump();
var extract_input_buffer = new datapumps.Buffer({size: 100});
var extract_output_buffer = extract_pump.buffer();
extract_pump.errorBuffer().on('write', function (data) {
console.log(data);
});
extract_pump.buffer('output').on('write', function (data) {
console.log(extract_output_buffer.content.length);
});
extract_pump.buffer('output').on('end', function (data) {
console.log("output buffer has ended")
});
transform_pump
.logErrorsToConsole()
.run()
.then(function () {
var from1buffer = extract_pump.from();
var output1buffer = extract_pump.buffer('output');
var from2buffer = transform_pump.from();
var output2buffer = transform_pump.buffer('output');
console.log(from1buffer.content.length);
console.log(output1buffer.content.length);
console.log(from2buffer.content.length);
console.log(output2buffer.content.length);
});
I see the extract_output_buffer written to, in line 66, however it is not being picked up in the transform_pump. Based on line 81 I set the transform_pump input buffer to the output buffer of extract_pump.
What am I am missing? Can you clarify?
The text was updated successfully, but these errors were encountered:
Based on the documentation:
"A pump reads data from its input buffer or stream and copies it to the output buffer by default:"
If I use the following example:
var datapumps = require('datapumps');
var mssql = require('mssql');
Promise = require('bluebird');
var config = {
user: 'user',
password: 'pw',
server: 'server', // You can use 'localhost\instance' to connect to named instance
database: 'db',
stream: true, // You can enable streaming globally
requestTimeout: 60000,
options: {
encrypt: false // Use this if you're on Windows Azure
}
}
var connection = new mssql.Connection(config, function (err) {
});
var extract_pump = new datapumps.Pump();
var extract_input_buffer = new datapumps.Buffer({size: 100});
var extract_output_buffer = extract_pump.buffer();
extract_pump.errorBuffer().on('write', function (data) {
console.log(data);
});
extract_pump.buffer('output').on('write', function (data) {
console.log(extract_output_buffer.content.length);
});
extract_pump.buffer('output').on('end', function (data) {
console.log("output buffer has ended")
});
var transform_pump = new datapumps.Pump();
extract_pump
.from(extract_input_buffer)
.to(transform_pump, 'output')
.logErrorsToConsole()
.run()
.then(function(){
transform_pump
.logErrorsToConsole()
.run()
.then(function () {
var from1buffer = extract_pump.from();
var output1buffer = extract_pump.buffer('output');
var from2buffer = transform_pump.from();
var output2buffer = transform_pump.buffer('output');
console.log(from1buffer.content.length);
console.log(output1buffer.content.length);
console.log(from2buffer.content.length);
console.log(output2buffer.content.length);
});
I see the extract_output_buffer written to, in line 66, however it is not being picked up in the transform_pump. Based on line 81 I set the transform_pump input buffer to the output buffer of extract_pump.
What am I am missing? Can you clarify?
The text was updated successfully, but these errors were encountered: