Problem with InsertPart when Technical_SetTable_OverwriteIsNotAllowed () is turned on.

May 6, 2013 at 11:49 PM
Edited May 6, 2013 at 11:50 PM
Hi blaze, I've got some interesting problem in the following scenario:
NestedTable nt;

nt = transaction.InsertTable<byte> ("t1", 1, 0);
nt.Technical_SetTable_OverwriteIsNotAllowed ();
nt.InsertPart<ulong, uint> (1, 0, 32);
Now I should have entry with key "1" and Value is 36 bytes long,
but after that if I do the following:
{byte[36]}
    [0]: 0
    [1]: 0
    [2]: 0
    [3]: 0
    [4]: 0
    [5]: 0
    [6]: 0
    [7]: 0
    [8]: 0
    [9]: 0
    [10]: 0
    [11]: 0
    [12]: 0
    [13]: 0
    [14]: 0
    [15]: 0
    [16]: 0
    [17]: 0
    [18]: 0
    [19]: 0
    [20]: 0
    [21]: 0
    [22]: 0
    [23]: 0
    [24]: 0
    [25]: 0
    [26]: 0
    [27]: 0
    [28]: 0
    [29]: 0
    [30]: 0
    [31]: 0
    [32]: 0
    [33]: 0
    [34]: 0
    [35]: 0
Now I execute:
nt.InsertPart<ulong, uint> (1, 1, 0);
And then:
nt.Select<ulong, byte[]> (1).Value;
{byte[4]}
    [0]: 0
    [1]: 0
    [2]: 0
    [3]: 1
It shows me that Value has been truncated to 4 bytes. This only happens when,
Technical_SetTable_OverwriteIsNotAllowed () is turned on, if it is off it works as it should.
Is this intended behavior ?
May 7, 2013 at 8:35 AM
Yes, it's not good, but there is no way to fix it, for Technical_SetTable_OverwriteIsNotAllowed case.

Workaround:
  • don't use InsertPart, only Insert
  • you read the whole value into memory
  • then change its middle part (DBreeze.Utils.BytesProcessing CopyInside or CopyInsideArrayCanGrow)
  • then you insert the complete value.
  • All the time Technical_SetTable_OverwriteIsNotAllowed can be on.
May 7, 2013 at 10:50 AM
So, I've committed version 049, where tried to solve InsertPart problem for Technical_SetTable_OverwriteIsNotAllowed.
It's only in git repo, not published as release yet - for short time range tests.
DLL's from Release folders can be used.
May 7, 2013 at 10:53 AM
In any case InsertPart still tends to overwrite values (even in Technical_SetTable_OverwriteIsNotAllowed case), that can bring to a speed loss.
So, if you need speed, while update, - use workaround technique described before.
May 7, 2013 at 3:49 PM
I apologize for always brining You the bad news :))
May 7, 2013 at 7:06 PM
Yeah, you have to think how to sweeten the pill :)