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

Nikolay Izhikov commented on IGNITE-15978:
------------------------------------------

Hello, [~vermakov], [~tledkov-gridgain]

Looks like this commit introduce a blocker.
Second read of array field fail and read some garbage.
This happen because when object read with handle stream position don't move to 
the end of already deserialized object.
So second array element is just random bytes from the middle of the stream.

BinaryObjectBuilderAdditionalSelfTest
{code:java}
    /** */
    @Test
    public void testArrayFieldSeveralRead() throws Exception {
        try (Ignite ignite = startGrid(1)) {
            TestClass1[] expArr = new TestClass1[] {new TestClass1(), new 
TestClass1()};

            BinaryObject arrObj = ignite.binary().toBinary(new 
TestClsWithArray(expArr));

            for (int i = 0; i < 10; i++)
                Assert.assertArrayEquals(i + " iteration", expArr, 
PlatformUtils.unwrapBinariesInArray(arrObj.field("arr")));

            arrObj = 
ignite.binary().builder(TestClsWithArray.class.getName()).setField("arr", 
expArr).build();

            for (int i = 0; i < 10; i++)
                Assert.assertArrayEquals(i + " iteration", expArr, 
PlatformUtils.unwrapBinariesInArray(arrObj.field("arr")));
        }
        finally {
            clearBinaryMeta();
        }
    }

    /** Test class with array. */
    public static class TestClsWithArray {
        /** */
        private final Object[] arr;

        /** */
        public TestClsWithArray(TestClass1[] arr) {
            this.arr = arr;
        }
    }
{code}

> Support binary HANLDEs by BinaryObjectBuilder
> ---------------------------------------------
>
>                 Key: IGNITE-15978
>                 URL: https://issues.apache.org/jira/browse/IGNITE-15978
>             Project: Ignite
>          Issue Type: Improvement
>          Components: sql
>            Reporter: Vladimir Ermakov
>            Assignee: Vladimir Ermakov
>            Priority: Major
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> We have to support binary HANLDEs by BinaryObjectBuilder.
> Now, the binary object is created by marshaling the java object may contain 
> filed that is represented by the HANDLE (reference) to the other member of 
> the upper object.e.g.
>  
> {code:java}
> class MyClass {
>    List<Value> lst0;
>    List<Value> lst1;
> }
> MyClass var = new MyClass();
> var.lst0 = ...;
> var.lst1 = lst0; // Will be serialized as the HANDLE with offset that refers 
> to the lst0 {code}
> But the same layout of the binary object cannot be built by 
> BinaryObjectBuilder.e.g.:
> {code:java}
> BinaryObjectBuilder bob = builder("MyClass");
> List<Value> lst = ...;
> bob.setField("lst0", lst);
> bob.setField("lst1", lst);
> BinaryObject bo = bob.build(); // Binary object will not contain HANDLE. The 
> collections will be marshaled independently, {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to