Skip to content
This repository has been archived by the owner on Apr 22, 2022. It is now read-only.

mismatch hash value #9

Open
nipadadbhawala opened this issue May 30, 2014 · 0 comments
Open

mismatch hash value #9

nipadadbhawala opened this issue May 30, 2014 · 0 comments

Comments

@nipadadbhawala
Copy link

Hi,

Here is test that I wrote and I see it failing due to the fact that if the data order changes,the hash changes and then it thinks that it is new data.

@Test
    void testPodPool()
    {
        def g = new TinkerGraph()
        def mapper = new GraphObjectMapper(g)

        Map<String, Object> vdc = new LinkedHashMap<String, Object>();

        vdc.put("name", "myVDC");


        Vertex vdcV = mapper.toGraph(vdc);

        Map<String, Object> tenant = new LinkedHashMap<String, Object>();
        tenant.put("name", "teannt");

        Map<String, Object> provider = new LinkedHashMap<String, Object>();
        provider.put("name", "provider");
        provider.put("occupant", tenant);
        provider.put("version", 1);

        Vertex occuV = mapper.toGraph(provider);

        Map<String, Object> pool = new LinkedHashMap<String, Object>();
        pool.put("name", "RI-vDC_PODPool");
        pool.put("occupant", mapper.fromGraph(occuV, LinkedHashMap.class));
        pool.put("vdc", mapper.fromGraph(vdcV, LinkedHashMap.class));

        Vertex poolV = mapper.toGraph(pool);

        int num = Iterables.size(g.query().vertices());
        System.out.println("Update is good: " + (Iterables.size(g.query().vertices()) == 4));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
                GraphSONWriter.outputGraph(g, out);
                System.out.println("Graph: "+ out.toString());
            } catch (IOException e)
            {
                out.close();
                System.out.println(e.detailMessage);
            }
    }

System.out.println("Update is good: " + (Iterables.size(g.query().vertices()) == 4));

this prints false as it creates 5 vertices.

#####received: {name=myVDC}

@@@@@@@@@@@Hashed: {_hash=5099648736912361917, name=myVDC}

#####received: {name=provider, version=1, occupant={name=teannt}}

@@@@@@@@@@@Hashed: {_hash=-7815931700235832755, name=provider, version=1, occupant={name=teannt, _hash=-9217391480162829852}}

#####received: {name=teannt, _hash=-9217391480162829852}

@@@@@@@@@@@Hashed: {name=teannt, _hash=-9217391480162829852}

#####received: {vdc={name=myVDC}, name=RI-vDC_PODPool, occupant={name=provider, occupant={name=teannt}, version=1}}

@@@@@@@@@@@Hashed: {vdc={name=myVDC, _hash=5099648736912361917}, _hash=3462430383314112090, name=RI-vDC_PODPool, occupant={name=provider, occupant={name=teannt, _hash=-9217391480162829852}, version=1, _hash=-1116000336789357522}}

#####received: {name=myVDC, _hash=5099648736912361917}

@@@@@@@@@@@Hashed: {name=myVDC, _hash=5099648736912361917}

#####received: {name=provider, occupant={name=teannt, _hash=-9217391480162829852}, version=1, _hash=-1116000336789357522}

@@@@@@@@@@@Hashed: {name=provider, occupant={name=teannt, _hash=-9217391480162829852}, version=1, _hash=-1116000336789357522}

#####received: {name=teannt, _hash=-9217391480162829852}

@@@@@@@@@@@Hashed: {name=teannt, _hash=-9217391480162829852}
Update is good: false
Graph: {"mode":"NORMAL","vertices":[{"_hash":-9217391480162829852,"name":"teannt","___type":"java.util.LinkedHashMap","_id":"2","_type":"vertex"},{"_hash":-7815931700235832755,"name":"provider","___type":"java.util.LinkedHashMap","version":1,"_id":"1","_type":"vertex"},{"_hash":5099648736912361917,"name":"myVDC","___type":"java.util.LinkedHashMap","_id":"0","_type":"vertex"},{"_hash":-1116000336789357522,"name":"provider","___type":"java.util.LinkedHashMap","version":1,"_id":"6","_type":"vertex"},{"_hash":3462430383314112090,"name":"RI-vDC_PODPool","___type":"java.util.LinkedHashMap","_id":"4","_type":"vertex"}],"edges":[{"_id":"3","_type":"edge","_outV":"1","_inV":"2","_label":"occupant"},{"_id":"7","_type":"edge","_outV":"6","_inV":"2","_label":"occupant"},{"_id":"5","_type":"edge","_outV":"4","_inV":"0","_label":"vdc"},{"_id":"8","_type":"edge","_outV":"4","_inV":"6","_label":"occupant"}]}

From the log you could see that for the provider, since the order changes, the hash changed.

How to fix this issue? Any help is appreciated.

thanks,

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant