GithubHelp home page GithubHelp logo

SaveAsSync? about jbinary HOT 2 OPEN

jdataview avatar jdataview commented on September 3, 2024
SaveAsSync?

from jbinary.

Comments (2)

RReverser avatar RReverser commented on September 3, 2024

It won't be portable across platforms. Why do you need it though? You can just not pass any callback if you prefer to, it will save file nevertheless.

from jbinary.

kpetrow avatar kpetrow commented on September 3, 2024

I load in a point cloud(60-200MB binary final of int16's). Then query ~10 million position and apply the positions to the point cloud. The positions come in a stream from mysql server. Then at certain intervals write out the point cloud. I need to stop the mysql stream in order to output the file if being written async to ensure the point cloud isnt modified during output. When sync i can maintain the stream synchronously. I can do a pause in the stream, then pass in call back to resume when outputs the last file, but I think its really messed compared to sync write and doesnt save any time since I need to pause the database stream.

  CONNECTION_POOL = mysql.createConnection({
     connectionLimit: 10,
     host: server_name,
     user: user_name,
     password: password,
     database: schema,
     connectTimeout: 99999999999,
     multipleStatements: true,
     .........
     ..........
 });
 var myObjects, myObject = {};
 myObject.header = module.loadUsingJBin_and_other_stuff('up_to_200MbBinaryFile');
 myObject.myMassiveArray = module.loadUsingArrayBuffer_and_other_stuff('up_to_200MbBinaryFile');

 var positionStream = CONNECTION_POOL.query(myQuery)
 positionStream.on('result', function(currentPositionRow) {
     // this includes spawning multiple myObject's all with their own myMassiveArray
     myObjects = doStuff(myObject, currentPositionRow);

     // if time is write we need to output all the point clouds made
     if (currentPositionRow.time > outputTime && previousPositionRow.time < outputTime) {
         // We could add a puase here
         //CONNECTION_POOL.Pause();
         for (var i = 1; i < myObjects.length; i++) {
             // Conenction pool is paused, do i really want to deal with callback hell for async file write ?
             // callBack = (last) ? function (CONNECTION_POOL) { CONNECTION_POOL.Pause() } : 'NOT_TIME';
             module.WriteUsingJBin(outputTime, myObjects[i] /*, callBack*/ );
         }
     }
 })

I have tried cloning off the object to write but I get memory overflow, because the database stream and math is way faster then the write and garbage collection. Open for any suggestions.

from jbinary.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.