I think it depends on driver implementation (in my case async sockets/ non
blocking). I implemented similar test in C# and it works fine. So final
code on client side my look like
C#
using (var database = OrientDbPool.Demand(poolName))
{
for (int i = 0; i < 1000; i++)
{
var localList = new List<ORecord>();
for (int ii = 0; ii < 100; ii++)
{
var film = new Film() { Title = "Film " +
i, Year = 1950 + (i % 100) };
var actor = new Actor() { FirstName = "Name
" + i, LastName = "LastName " + i };
var filmRole = new FilmRole() { Actor =
actor, Role = "Role " + i };
film.Cast.Add(filmRole);
localList.Add(film);
localList.Add(filmRole);
localList.Add(actor);
}
var saveOper =
database.SaveChangesAsync(localList.ToArray());// async or sync operation
tasks.Add(saveOper);
}
}
Task.WaitAll(tasks.ToArray());
Synchronous loop Total elapsed time [ms]:43218
Async loop Total elapsed time [ms]:26001
Wrapping up, it's possible to implement it via binary protocol.
Pawel
On Friday, February 14, 2014 3:35:43 PM UTC+1, Giraldo Rosales wrote:
>
> This is a binary question, not an API question. But while using the
> node-orientdb api (or even the java api). If I wanted to loop through
> updates instead of synchronously.
> *Like this:*
> db.open().then(function(){
> db.sql("UPDATE FROM users SET type=1 WHERE id=1", {mode:"a"});
> db.sql("UPDATE FROM users SET type=1 WHERE id=2", {mode:"a"});
> });
>
> *or this:*
> db.open().then(function(){
> for(var g=0; g<list.length; g++) {
> db.sql("UPDATE FROM users SET type=1 WHERE id="+g, {mode:"a"});
> }
> });
>
> It doesn't seem possible on the binary side. The method, "db.sql" sends
> the command, COMMAND, to the OrientDB Binary. And the mode lets the binary
> know what type of query
> ("a"=com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery). The
> "db.open" method opens a database connection.
>
> But the binary doesn't seem to allow asynchronous insert/update statements
> only select statements. I assume it is because it may confuse the system if
> the same record is being updated at the same time. Was this intended or is
> there another way running update and/or insert sql statements to the binary
> asynchronously?
>
> *My only thought is to create a connection for each async command:*
> db.open().then(function(){
> db.sql("UPDATE FROM users SET type=1 WHERE id=1", {mode:"a"});
> });
> db.open().then(function(){
> db.sql("UPDATE FROM users SET type=1 WHERE id=2", {mode:"a"});
> });
>
> Thanks,
> Giraldo
>
>
>
> On Feb 14, 2014 9:15 AM, "Andrey Lomakin" <[email protected]<javascript:>>
> wrote:
>
>> Hi,
>> Sorry can not understand, how asynchronous update command should work ?
>> Could you provide example ?
>>
>>
>> On Thu, Feb 13, 2014 at 10:07 PM, Giraldo Rosales
>> <[email protected]<javascript:>
>> > wrote:
>>
>>> Is there a way to run the binary command, COMMAND, asynchronously with
>>> an UPDATE and/or INSERT sql command? I see non-idempotent commands use
>>> com.orientechnologies.orient.core.sql.OCommandSQL. SELECT sql statements
>>> can use com.orientechnologies.orient.core.sql.query.OSQLSynchQuery
>>> or com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery.
>>>
>>> So I am assuming there is no way to async an UPDATE? Even with the
>>> versioning? If there isn't is there a workaround? Or is it bad to open up a
>>> new connection for each non-idempotent command?
>>>
>>> Thanks,
>>> Giraldo
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "OrientDB" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected] <javascript:>.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> --
>> Best regards,
>> Andrey Lomakin.
>>
>> Orient Technologies
>> the Company behind OrientDB
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "OrientDB" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/orient-database/2yCrji3GEi4/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.