Bug #493

IPAACA-CPP batch payload update does not work correctly when changing multiple values in a dictionary > level 1

Added by Hendrik Buschmeier almost 8 years ago. Updated almost 8 years ago.

Status:ResolvedStart date:2016-12-07
Priority:NormalDue date:
Assignee:Ramin Yaghoubzadeh% Done:

100%

Category:-
Target version:-

Description

The following batch payload update of a map {"test": {"1": "hello"}, {"2": "world"}, {"3": "!"}}.

ipaaca::IU::ptr iu = ipaaca::IU::create("test”);
iu->payload()["hello"] = std::map<std:string, std::string>{{"1", "hello"}, {"2", "world"}, {"3", "!"}};
ob->add(iu);
{
    ipaaca::Locker locker(iu->payload());
    iu->payload()["test"]["1"] = "hallo";
    iu->payload()["test”]["2"] = “welt";
}

Results in the IU {"test" : {"2": “welt”}} instead of {"test": {"1": "hallo"}, {"2": "welt"}, {"3": "!"}}.

IPAACA-Python shows the correct behaviour:

import ipaaca
ob = ipaaca.OutputBuffer("test")
iu = ipaaca.IU("test")
iu.payload["test"] = {"1": "hello", "2": "world", "3": "!"}
ob.add(iu)
with iu.payload:
    iu.payload["test"]["2"] = "hallo" 
    iu.payload["test"]["3"] = "welt" 

A minimal working example is attached.

mwe.cpp Magnifier (1.317 KB) Hendrik Buschmeier, 2016-12-07 21:48

History

#1 Updated by Hendrik Buschmeier almost 8 years ago

As a workaround, the following can be used:

iu->payload()["test"] = std::map<std:string, std::string>{
    {"1", "hallo"},
    {"2", "welt"},
    {"3", iu->payload()["test"]["3"]} // <- needs to be re-included
};

#2 Updated by Ramin Yaghoubzadeh almost 8 years ago

  • Status changed from New to Feedback
  • % Done changed from 0 to 80

Considered fixed in 219bc8 (branch rsb0.14), tests pending.
(Windows binary package to follow suit soon.)

In locked mode, PayloadEntryProxies are now preferably generated from cached information, for the lock-owning thread only (other threads still only read form the last known globally known state).

ATTENTION: general note: non-Locked writes are by design not thread-safe. Make sure to use Locker frames around all code that might be called from more than one thread at the same time and write to the same IUs (e.g. IU event handlers that themselves update existing IUs)!

Hendrik Buschmeier wrote:

The following batch payload update of a map {"test": {"1": "hello"}, {"2": "world"}, {"3": "!"}}.

[...]

Results in the IU {"test" : {"2": “welt”}} instead of {"test": {"1": "hallo"}, {"2": "welt"}, {"3": "!"}}.

#3 Updated by Ramin Yaghoubzadeh almost 8 years ago

(Windows binary package to follow suit soon.)

For testing in Windows (and since the deps did not change) please simply replace your SOA_REPO_DIR\ipaaca-windows with the "ipaaca-windows" repo from the SCS server.

#4 Updated by Ramin Yaghoubzadeh almost 8 years ago

  • Status changed from Feedback to Resolved
  • % Done changed from 80 to 100

Initial tests / applications working. Considered RESOLVED until any contrary evidence might open another issue ;)

Also available in: Atom PDF