[odb-users] Change-tracking map, list and set containers

ALAIN MARI alain.mari at se.com
Thu Jan 17 03:26:14 EST 2019


Sorry, but I didn't see that the answer to that question is in the documentation !

-----Message d'origine-----
De : odb-users-bounces at codesynthesis.com [mailto:odb-users-bounces at codesynthesis.com] De la part de ALAIN MARI
Envoyé : mardi 15 janvier 2019 17:35
À : odb-users at codesynthesis.com
Objet : RE: [odb-users] Change-tracking map, list and set containers

[External email: Use caution with links and attachments]

________________________________



Actually, we have big maps (up to 1 million elements) in which we make lots of lookups.
So it is mandatory to have sorted vector (persistent) to mimic the map behavior.

Unfortunately, when I want to apply standard algorithm std::sort, on odb::vector, compilation fails with this message :

1>c:\program files (x86)\microsoft visual 
1>studio\2017\enterprise\vc\tools\msvc\14.16.27023\include\algorithm(3835): error C3892: '_First': you cannot assign to a variable that is const c:\program files (x86)\microsoft visual studio\2017\enterprise\vc\tools\msvc\14.16.27023\include\algorithm(4023): note: see reference to function template instantiation '_BidIt std::_Insertion_sort_unchecked<_RanIt,_Pr>(_BidIt,const _BidIt,_Pr)' being compiled
1>        with
1>        [
1>            _BidIt=odb::vector_iterator<odb::vector<int,std::allocator<int>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>>,
1>            _RanIt=odb::vector_iterator<odb::vector<int,std::allocator<int>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types<int>>>>,
1>            _Pr=std::less<void>
1>        ]



-----Message d'origine-----
De : Boris Kolpackov [mailto:boris at codesynthesis.com] Envoyé : mardi 15 janvier 2019 15:04 À : ALAIN MARI <alain.mari at se.com> Cc : odb-users at codesynthesis.com Objet : Re: [odb-users] Change-tracking map, list and set containers

[External email: Use caution with links and attachments]

________________________________



ALAIN MARI <alain.mari at se.com> writes:

> Sometimes, maps can be advantageously replaced by sorted vectors.

True. Or even unsorted (if you normally have just a handful of elements, linear search over an unsorted vector can be faster that map lookup due to data locality).


> Besides, I will try to maintain a vector/map in parallel in some of 
> our persistent objects but I'm afraid of memory consumption in that 
> case.

You can always get clever and maintain a pointer to the map's element in the vector or some such. It will require a bit of extra mapping effort for ODB, but otherwise should be doable.


> I will also look inside your odb::vector implementation to get a sense 
> of the complexity, and to see I we can adapt it to std::list.

Yes, I think std::list we can handle using odb::vector's implementation (vector_impl); off the top of my head I don't see any good reasons to replicate the list's storage model for the change state.


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________


______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________



More information about the odb-users mailing list