Steve Baxter wrote in a post to the mailing list of 31-20-2001:
New to Metakit and not sure whether I am doing something wrong or have found a bug!
You have found a bug. Thanks for the example, which made understanding this one easy. Unfortunately, the problem is a fundamental one which I cannot easily fix (more precisely: I could fix Access, but I can't fix Modify without losing its performance advantage for partial access).
B(b26, Partial memo field access, 0) { c4_BytesProp p1 ("p1"); c4_Storage s1; c4_View raw = s1.GetAs("raw[p1:B]"); c4_View hash = s1.GetAs("hash[_H:I,_R:I]"); c4_View v1 = raw.Hash(hash, 1); v1.Add(p1 [c4_Bytes ("12345", 5)]); A(v1.GetSize() == 1); c4_Bytes buf = p1 (v1[0]); A(buf.Size() == 5); A(buf == c4_Bytes ("12345", 5)); buf = p1(v1[0]).Access(1,3); A(buf == c4_Bytes ("234", 3)); p1 (v1[0]).Modify(c4_Bytes ("ab", 2), 2, 0); buf = p1 (v1[0]); A(buf == c4_Bytes ("12ab5", 5)); p1 (v1[0]).Modify(c4_Bytes ("ABC", 3), 1, 2); buf = p1 (v1[0]); A(buf == c4_Bytes ("1ABCab5", 7)); p1 (v1[0]).Modify(c4_Bytes ("xyz", 3), 2, -2); buf = p1 (v1[0]); A(buf == c4_Bytes ("1Axyz", 5)); p1 (v1[0]).Modify(c4_Bytes ("3456", 4), 4, 0); buf = p1 (v1[0]); A(buf == c4_Bytes ("1Axy3456", 8)); } E;
The above will work properly, if you replace all Access/Modify calls to operate on the underlying "raw" view instead of "v1".
The situation can be summarized as: the new mapped views (hash, ordered, blocked, and indexed) are fine for normal get/set access, but the illusion they present breaks down with Access/Modify for byte properties. In all cases *except* blocked, this will work properly when you use the underlying "raw" view. This is due to the fact that Access/Modify do not insert/delete/move rows, but care must be taken so a key is never modified.
-jcw