Giter Site home page Giter Site logo

Querying about aerospike-client-nodejs HOT 9 CLOSED

aerospike avatar aerospike commented on August 23, 2024
Querying

from aerospike-client-nodejs.

Comments (9)

wchu-citrusleaf avatar wchu-citrusleaf commented on August 23, 2024

This is definitely on our roadmap to add. Thanks.

from aerospike-client-nodejs.

mingfai avatar mingfai commented on August 23, 2024

+1, and also scan api like Java. without a query mechanism, the NodeJS client is incomplete/not production ready, you'd better mark it as "alpha" or "preview release".

from aerospike-client-nodejs.

mullanaphy avatar mullanaphy commented on August 23, 2024

It's not that simple, since node.js is single threaded. Personally what I ended up doing for a project was make a C process that I spawn in my node.js module and converse back and forth via stdin/out and it performs well (300m results in batches of 1000 results each, performs for us ~30k results a second).

from aerospike-client-nodejs.

mingfai avatar mingfai commented on August 23, 2024

ic. so a technical challenge is NodeJS client uses C client, and it cannot easily sprawn new thread/process so operation that load a let of records will block the while NodeJS app. I think there are many uses of using NodeJS client that may tolerate the limitation, e.g.

  • for admin or ad-hoc operation like data patching
  • query for a very small set of data with index

the dev may consider to implement the query api, and give a strong warning on the limitation. And then address the process spawning issue and Scan API later.

from aerospike-client-nodejs.

shimondoodkin avatar shimondoodkin commented on August 23, 2024

+1 how do i do set scans?

from aerospike-client-nodejs.

bbulkow avatar bbulkow commented on August 23, 2024

A bunch of design discussions here at Aerospike Central, we think we've found the right implementation path to get various queries in soon. Thanks for the comment about reasonable limitations.

from aerospike-client-nodejs.

shimondoodkin avatar shimondoodkin commented on August 23, 2024

i guess it is possible to use the java driver in nodejs
like nodejs jdbc module works but it needs figuring out how to do it

simple working code:

//index.js
//npm init
//npm install java
//download latest jar with dependencies http://www.aerospike.com/download/client/java/

//help on java: https://github.com/joeferner/node-java

if(require.main === module) { var  repl = require("repl");repl.start({ useGlobal:true,  useColors:true, }); }
//some variables are without var to put them in global so it will be visible in repl

var java = require("java");
java.classpath.push("aerospike-client-3.0.28-jar-with-dependencies.jar");

var AerospikeClient = java.import('com.aerospike.client.AerospikeClient');
//var ClientPolicy = java.import('com.aerospike.client.policy.ClientPolicy');
//var WritePolicy = java.import('com.aerospike.client.policy.WritePolicy');
 Bin = java.import('com.aerospike.client.Bin');//global
 Key = java.import('com.aerospike.client.Key');//global
 Record = java.import('com.aerospike.client.Record');//global
 newBinsArray = function(arr){return java.newArray("com.aerospike.client.Bin", arr)}

/*
policy = new ClientPolicy();
        policy.user = params.user;
        policy.password = params.password;
        policy.failIfNotConnected = true;

var ArrayList = java.import('java.util.ArrayList');
var list = new ArrayList();
list.addSync('item1');
java.newInstanceSync("java.lang.Long", 5);

var client = new AerospikeClient(policy, "10.0.2.15", "3000");
*/

//writePolicy =new WritePolicy();//global

client = new AerospikeClient("127.0.0.1", 3000);//global 

var key = new Key("test", "demo", "putgetkey");
var bin1 = new Bin("bin1", "value1");
var bin2 = new Bin("bin2", "value2");

var binsArray = java.newArray("com.aerospike.client.Bin", [bin1, bin2]);
// Write a record
//client.putSync(writePolicy, key, binsArray);
client.putSync(null, key, binsArray);

// Read a record
var record = client.getSync(null, key);
if (record == null) {
 console.log('record not found');
}
else
{       
var received1 = record.getValueSync(bin1.name);
var received2 = record.getValueSync(bin2.name);
console.info("Bin matched: namespace=%s set=%s key=%s bina=%s valuea=%s binb=%s valueb=%s generation=%d expiration=%d", 
                key.namespace, key.setName, key.userKey, bin1.name, received1, bin2.name, received2, record.generation, record.expiration);
}

//client.closeSync();

//probably any operation that is over network or disk should be async here is an async version,
//just append callback to end with err and result as the return value.

//var  client = new AerospikeClient("127.0.0.1", 3000);

var key = new Key("test", "demo", "putgetkey");
var bin1 = new Bin("bin1", "value11");
var bin2 = new Bin("bin2", "value22");

// Write a record
//client.putSync(writePolicy, key, binsArray);
client.put(null, key, newBinsArray([bin1, bin2]), function(err,result){
     // Read a record
    client.get(null, key,function(err,record){
        if (record == null) {
            console.log('record not found');
        }
        else
        {       
            var received1 = record.getValueSync(bin1.name);
            var received2 = record.getValueSync(bin2.name);
            console.info("Bin matched: namespace=%s set=%s key=%s bina=%s valuea=%s binb=%s valueb=%s generation=%d expiration=%d", 
                            key.namespace, key.setName, key.userKey, bin1.name, received1, bin2.name, received2, record.generation, record.expiration);
        }
        //client.closeSync();
    });
});

from aerospike-client-nodejs.

Daeik avatar Daeik commented on August 23, 2024

Will there be any updates on the node aerospike client soon? I checked that last updates on this repository is about 3~4 months ago. And I want to know that query and streaming UDF feature will be included.

from aerospike-client-nodejs.

GayathriKaliyamoorthy avatar GayathriKaliyamoorthy commented on August 23, 2024

Hi,
We have just released scan and query feature today. Please use the new API and give us your feedback.

from aerospike-client-nodejs.

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.