[jira] [Updated] (IGNITE-9651) Binary objects comparison may fail when the same reference occurs more than once

2018-09-19 Thread Stanislav Lukyanov (JIRA)


 [ 
https://issues.apache.org/jira/browse/IGNITE-9651?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stanislav Lukyanov updated IGNITE-9651:
---
Description: 
If a composite object contains multiple occurrences of the same POJO that POJO 
will be properly serialized only the first time, and all other references will 
refer to that first object. Because of that the same object may have different 
views in binary format when serialized on its own and when serialized as a part 
of another object.

Having multiple binary views of the same object leads to several issues with 
binary objects comparison. Examples in pseudocode are below, JUnit tests are 
attached


Example 1 (RepeatingFieldTest.java)
{code}
class Key { int i, Pojo pojo1, Pojo pojo2 }
class Pojo { int i }

cache.put(new Key(42, new Pojo(42), new Pojo(42)), 42);

// new Pojo is created for both fields - works
assertEquals(INT, cache.get(new Key(42, new Pojo(42), new Pojo(42;

// same Pojo is used for both fields - fails
// this is because the second field is serialized as a reference to the first 
one, and binary representation differs
Pojo obj = new Pojo(42);
assertEquals(42, cache.get(new Key(42, obj, obj)));
{code}


Example 2 (RepeatingFieldSqlTest.java)

{code}
class Pojo { int i }
class Key { int i, Pojo pojo }
class Value { Pojo pojo, Key key }

Pojo obj = new Pojo(42);
Key key = new Key(42, obj);
Value val = new Value(key, obj);
cache.put(key, val);

// supposed to return 1 row, but returns 0
SqlFieldsQuery qry = new SqlFieldsQuery("select * from Value where _key = key");
{code}

  was:
If a composite object contains multiple occurrences of the same POJO that POJO 
will be properly serialized only the first time, and all other references will 
refer to that first object. Because of that the same object may have different 
views in binary format when serialized on its own and when serialized as a part 
of another object.

Having multiple binary views of the same object leads to several issues with 
binary objects comparison. Examples in pseudocode are below, JUnit tests are 
attached


Example 1 (RepeatingFieldTest.java)
{code}
class Key { int i, Pojo pojo1, Pojo pojo2 }
class Pojo { int i }

cache.put(new Key(42, new Pojo(42), new Pojo(42)), 42);

// new Pojo is created for both fields - works
assertEquals(INT, cache.get(new Key(42, new Pojo(42), new Pojo(42;

// same Pojo is used for both fields - fails
// this is because the second field is serialized as a reference to the first 
one, and binary representation differs
Pojo obj = new Pojo(42);
assertEquals(42, cache.get(new Key(42, obj, obj)));
{code}


Example 2 (RepeatingFieldSqlTest.java)

{code}
class Pojo { int i }
class Key { int i, Pojo pojo }
class Value { Pojo pojo, Key key }

Pojo obj = new Pojo(INT);
Key key = new Key(INT, obj);
Value val = new Value(key, obj);
cache.put(key, val);

// supposed to return 1 row, but returns 0
SqlFieldsQuery qry = new SqlFieldsQuery("select * from Value where _key = key");
{code}


> Binary objects comparison may fail when the same reference occurs more than 
> once
> 
>
> Key: IGNITE-9651
> URL: https://issues.apache.org/jira/browse/IGNITE-9651
> Project: Ignite
>  Issue Type: Bug
>  Components: binary
>Reporter: Stanislav Lukyanov
>Priority: Major
> Attachments: RepeatingFieldSqlTest.java, RepeatingFieldTest.java
>
>
> If a composite object contains multiple occurrences of the same POJO that 
> POJO will be properly serialized only the first time, and all other 
> references will refer to that first object. Because of that the same object 
> may have different views in binary format when serialized on its own and when 
> serialized as a part of another object.
> Having multiple binary views of the same object leads to several issues with 
> binary objects comparison. Examples in pseudocode are below, JUnit tests are 
> attached
> 
> Example 1 (RepeatingFieldTest.java)
> {code}
> class Key { int i, Pojo pojo1, Pojo pojo2 }
> class Pojo { int i }
> cache.put(new Key(42, new Pojo(42), new Pojo(42)), 42);
> // new Pojo is created for both fields - works
> assertEquals(INT, cache.get(new Key(42, new Pojo(42), new Pojo(42;
> // same Pojo is used for both fields - fails
> // this is because the second field is serialized as a reference to the first 
> one, and binary representation differs
> Pojo obj = new Pojo(42);
> assertEquals(42, cache.get(new Key(42, obj, obj)));
> {code}
> 
> Example 2 (RepeatingFieldSqlTest.java)
> {code}
> class Pojo { int i }
> class Key { int i, Pojo pojo }
> class Value { Pojo pojo, Key key }
> Pojo obj = new Pojo(42);
> Key key = new

[jira] [Updated] (IGNITE-9651) Binary objects comparison may fail when the same reference occurs more than once

2018-09-19 Thread Stanislav Lukyanov (JIRA)


 [ 
https://issues.apache.org/jira/browse/IGNITE-9651?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stanislav Lukyanov updated IGNITE-9651:
---
Description: 
If a composite object contains multiple occurrences of the same POJO that POJO 
will be properly serialized only the first time, and all other references will 
refer to that first object. Because of that the same object may have different 
views in binary format when serialized on its own and when serialized as a part 
of another object.

Having multiple binary views of the same object leads to several issues with 
binary objects comparison. Examples in pseudocode are below, JUnit tests are 
attached


Example 1 (RepeatingFieldTest.java)
{code}
class Key { int i, Pojo pojo1, Pojo pojo2 }
class Pojo { int i }

cache.put(new Key(42, new Pojo(42), new Pojo(42)), 42);

// new Pojo is created for both fields - works
assertEquals(INT, cache.get(new Key(42, new Pojo(42), new Pojo(42;

// same Pojo is used for both fields - fails
// this is because the second field is serialized as a reference to the first 
one, and binary representation differs
Pojo obj = new Pojo(42);
assertEquals(42, cache.get(new Key(42, obj, obj)));
{code}


Example 2 (RepeatingFieldSqlTest.java)

{code}
class Pojo { int i }
class Key { int i, Pojo pojo }
class Value { Pojo pojo, Key key }

Pojo obj = new Pojo(INT);
Key key = new Key(INT, obj);
Value val = new Value(key, obj);
cache.put(key, val);

// supposed to return 1 row, but returns 0
SqlFieldsQuery qry = new SqlFieldsQuery("select * from Value where _key = key");
{code}

  was:
If a composite object contains multiple occurrences of the same POJO that POJO 
will be properly serialized only the first time, and all other references will 
refer to that first object. Because of that the same object may have different 
views in binary format when serialized on its own and when serialized as a part 
of another object.

Having multiple binary views of the same object leads to several issues with 
binary objects comparison. Examples in pseudocode are below, JUnit tests are 
attached


Example 1 (RepeatingFieldTest.java)
{code}
class Key { int i, Pojo pojo1, Pojo pojo2 }
class Pojo { int i }

cache.put(new Key(42, new Pojo(42), new Pojo(42)), 42);

// new Pojo is created for both fields - works
assertEquals(INT, cache.get(new Key(42, new Pojo(42), new Pojo(42;

// same Pojo is used for both fields - fails
// this is because the second field is serialized as a reference to the first 
one, and binary representation differs
Pojo obj = new Pojo(42);
assertEquals(42, cache.get(new Key(42, obj, obj)));
{code}


Example 2 (RepeatingFieldSqlTest.java)

{code}
class Pojo { int i }
class Key { int i, Pojo pojo }
class Value { Pojo pojo, Key key }

Pojo obj = new Pojo(INT);
Key key = new Key(INT, obj);
Value val = new Value(key, obj);
cache.put(key, val);

// supposed to return 1 row, but returns 0
SqlFieldsQuery qry = new SqlFieldsQuery("select * from Value where _key = key");

{code}


> Binary objects comparison may fail when the same reference occurs more than 
> once
> 
>
> Key: IGNITE-9651
> URL: https://issues.apache.org/jira/browse/IGNITE-9651
> Project: Ignite
>  Issue Type: Bug
>  Components: binary
>Reporter: Stanislav Lukyanov
>Priority: Major
> Attachments: RepeatingFieldSqlTest.java, RepeatingFieldTest.java
>
>
> If a composite object contains multiple occurrences of the same POJO that 
> POJO will be properly serialized only the first time, and all other 
> references will refer to that first object. Because of that the same object 
> may have different views in binary format when serialized on its own and when 
> serialized as a part of another object.
> Having multiple binary views of the same object leads to several issues with 
> binary objects comparison. Examples in pseudocode are below, JUnit tests are 
> attached
> 
> Example 1 (RepeatingFieldTest.java)
> {code}
> class Key { int i, Pojo pojo1, Pojo pojo2 }
> class Pojo { int i }
> cache.put(new Key(42, new Pojo(42), new Pojo(42)), 42);
> // new Pojo is created for both fields - works
> assertEquals(INT, cache.get(new Key(42, new Pojo(42), new Pojo(42;
> // same Pojo is used for both fields - fails
> // this is because the second field is serialized as a reference to the first 
> one, and binary representation differs
> Pojo obj = new Pojo(42);
> assertEquals(42, cache.get(new Key(42, obj, obj)));
> {code}
> 
> Example 2 (RepeatingFieldSqlTest.java)
> {code}
> class Pojo { int i }
> class Key { int i, Pojo pojo }
> class Value { Pojo pojo, Key key }
> Pojo obj = new Pojo(INT);
> Key key =