[ 
https://issues.apache.org/jira/browse/IGNITE-5553?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16364043#comment-16364043
 ] 

Pavel Pereslegin commented on IGNITE-5553:
------------------------------------------

Hello.

In addition to [discussion on 
devlist|http://apache-ignite-developers.2346864.n4.nabble.com/IgniteSet-implementation-changes-required-td23783.html],
 I want to describe in more detail another way to implement IgniteSet, which 
will not use JVM heap for duplicate values (this approach was not discussed 
yet).

Introduce GridCacheSetIndexKey as follows:
{code:java}
IgniteUuid id;
long idx;
{code}

For each IgniteSet element put two key-value pairs.
First:
{noformat}
   key - GridCacheSetItemKey
 value - GridCacheSetIndexKey
{noformat}
Second:
{noformat}
   key - GridCacheSetIndexKey
 value - GridCacheSetItemKey
{noformat}

Add HEAD and TAIL indexes to the GridCacheSetHeader.

The main purpose for indexes is to hold the data in such way that will allow 
iterate through items from head to tail (similarly to IgniteQueue).

For clarity, I'll give an example of *IgniteSet with elements A, B, C*.
Datastructures cache
||key||value||
|A|0|
|B|1|
|C|2|
|.|.|
|0|A|
|1|B|
|2|C|
|.|.|
{noformat}
head = 0, tail = 3
{noformat}

*Addition of the element "D"*:
||key||value||
|A|0|
|B|1|
|C|2|
|D|3|
|.|.|
|0|A|
|1|B|
|2|C|
|3|D|
|.|.|
{noformat}
 head = 0, tail = 4
{noformat}
 
*To remove element "B"* we can move the tail element ("D") to the location of 
"B":
||key||value||
|A|0|
|C|2|
|D|1|
|.|.|
|0|A|
|1|D|
|2|C|
|-- tail --|
|3|D|
|.|.|
{noformat}
head = 0, tail = 3.
{noformat}

Operation "contains" will work as before, iterator will work as current 
IgniteQueue iterator.

> Ignite PDS 2: IgnitePersistentStoreDataStructuresTest testSet assertion error
> -----------------------------------------------------------------------------
>
>                 Key: IGNITE-5553
>                 URL: https://issues.apache.org/jira/browse/IGNITE-5553
>             Project: Ignite
>          Issue Type: Bug
>          Components: data structures, persistence
>    Affects Versions: 2.1
>            Reporter: Dmitriy Pavlov
>            Assignee: Andrey Kuznetsov
>            Priority: Major
>              Labels: MakeTeamcityGreenAgain, Muted_test, test-fail
>             Fix For: 2.5
>
>
> h2. Notes-4435
> When IgniteSet is restored from persistence, size of set is always 0, [link 
> to test 
> history|http://ci.ignite.apache.org/project.html?projectId=Ignite20Tests&testNameId=-7043871603266099589&tab=testDetails].
> h2. Detailed description
> Unlike *IgniteQueue* which uses separate cache key to store its size 
> *IgniteSet* stores it in a field of some class.
> Test from the link above shows very clearly that after restoring memory state 
> from PDS all set values are restored correctly but size is lost.
> h2. Proposed solution
> One possible solution might be to do the same thing as *IgniteQueue* does: 
> size of *IgniteSet* must be stored is cache instead of volatile in-memory 
> fields of random classes.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to