Commit 5c89e673 authored by priit's avatar priit
Browse files

KEELELIIN-40

parent 938af859
......@@ -7,6 +7,7 @@
"test": "./node_modules/.bin/istanbul test _mocha -- -R spec --timeout 15000"
},
"dependencies": {
"JSONStream": "^1.0.4",
"body-parser": "~1.12.4",
"debug": "~2.2.0",
"express": "~4.12.4",
......
......@@ -18,7 +18,7 @@ describe('File util', function() {
done();
});
it('Faili kopeerimine', function(done) {
it('Faili liigutamine', function(done) {
//loo fail
fs.writeFileSync(mvSource, 'Faili sisu');
......@@ -44,7 +44,7 @@ describe('File util', function() {
should(fs.existsSync(mvSource)).not.be.ok();
should(fs.existsSync(mvTarget)).not.be.ok();
FileUtil.mv(mvSource, mvTarget, function(){
FileUtil.cp(mvSource, mvTarget, function(){
should(fs.existsSync(mvSource)).not.be.ok();
should(fs.existsSync(mvTarget)).be.ok();
......
/**
* Created by priit on 26.05.15.
*/
/*
var FileUtil = require('../src/util/file');
FileUtil.cp('./12m', '13m', function () {
console.log('Copied');
});*/
require('../app');
return;
var tmp = [];
var index = 0;
while(index < 100000000){
index++;
if(index % 1000000 == 0){
console.log(index);
}
// 75 200 000 with no param
//--max_old_space_size=4000
// 112 800 000
//112800000
tmp.push('Helloworld');
}
JSON.stringify({arr: tmp});
/////////////////////////
return;
var fs = require('fs');
var tmp = [];
var index = 0;
while(true){
index++;
if(index % 10 == 0){
console.log(index);
}
tmp.push(fs.readFileSync('13m').toString());
// 75 200 000 with no param
//--max_old_space_size=4000
// 112 800 000
//112800000
}
/**
* Loob ~1GB json objektide faili ja pasib seda striimis
*/
var fs = require('fs');
var JSONStream = require('JSONStream');
var path = 'list';
var writer = fs.createWriteStream(path);
var dataX = JSON.stringify({data: 'Helloworld', index: {value: '123'}});
dataX = dataX + dataX + dataX +dataX +dataX +dataX +dataX + dataX + dataX + dataX;
var encoding = 'utf-8';
var i = 0;
function loop(){
i++;
if(i % 100000 == 0){
console.log(i);
}
if(i < 2300000){
writer.write(dataX, encoding, function () {
loop();
});
} else {
parse();
}
}
loop();
function parse(){
writer.on("finish",function (){
var rd = fs.createReadStream(path);
var parser = JSONStream.parse();
rd.pipe(parser);
var index = 0;
parser.on('data', function (obj) {
index++;
if(index % 100000 == 0){
console.log(index);
console.log(obj); // whatever you will do with each JSON object
}
});
});
writer.end();
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment