{"action":"created","issue":{"url":"https://api.github.com/repos/orientechnologies/orientdb/issues/3903","labels_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/3903/labels{/name}","comments_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/3903/comments","events_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/3903/events","html_url":"https://github.com/orientechnologies/orientdb/issues/3903","id":67349873,"number":3903,"title":"ORecordId - hashCode function collisions","user":{"login":"swimmesberger","id":1330294,"avatar_url":"https://avatars.githubusercontent.com/u/1330294?v=3","gravatar_id":"","url":"https://api.github.com/users/swimmesberger","html_url":"https://github.com/swimmesberger","followers_url":"https://api.github.com/users/swimmesberger/followers","following_url":"https://api.github.com/users/swimmesberger/following{/other_user}","gists_url":"https://api.github.com/users/swimmesberger/gists{/gist_id}","starred_url":"https://api.github.com/users/swimmesberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swimmesberger/subscriptions","organizations_url":"https://api.github.com/users/swimmesberger/orgs","repos_url":"https://api.github.com/users/swimmesberger/repos","events_url":"https://api.github.com/users/swimmesberger/events{/privacy}","received_events_url":"https://api.github.com/users/swimmesberger/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/orientechnologies/orientdb/labels/contributor%20friendly","name":"contributor friendly","color":"009800"},{"url":"https://api.github.com/repos/orientechnologies/orientdb/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/orientechnologies/orientdb/labels/performance","name":"performance","color":"eb6420"}],"state":"closed","locked":false,"assignee":{"login":"lvca","id":312606,"avatar_url":"https://avatars.githubusercontent.com/u/312606?v=3","gravatar_id":"","url":"https://api.github.com/users/lvca","html_url":"https://github.com/lvca","followers_url":"https://api.github.com/users/lvca/followers","following_url":"https://api.github.com/users/lvca/following{/other_user}","gists_url":"https://api.github.com/users/lvca/gists{/gist_id}","starred_url":"https://api.github.com/users/lvca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lvca/subscriptions","organizations_url":"https://api.github.com/users/lvca/orgs","repos_url":"https://api.github.com/users/lvca/repos","events_url":"https://api.github.com/users/lvca/events{/privacy}","received_events_url":"https://api.github.com/users/lvca/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/orientechnologies/orientdb/milestones/17","html_url":"https://github.com/orientechnologies/orientdb/milestones/2.2","labels_url":"https://api.github.com/repos/orientechnologies/orientdb/milestones/17/labels","id":613160,"number":17,"title":"2.2","description":"","creator":{"login":"lvca","id":312606,"avatar_url":"https://avatars.githubusercontent.com/u/312606?v=3","gravatar_id":"","url":"https://api.github.com/users/lvca","html_url":"https://github.com/lvca","followers_url":"https://api.github.com/users/lvca/followers","following_url":"https://api.github.com/users/lvca/following{/other_user}","gists_url":"https://api.github.com/users/lvca/gists{/gist_id}","starred_url":"https://api.github.com/users/lvca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lvca/subscriptions","organizations_url":"https://api.github.com/users/lvca/orgs","repos_url":"https://api.github.com/users/lvca/repos","events_url":"https://api.github.com/users/lvca/events{/privacy}","received_events_url":"https://api.github.com/users/lvca/received_events","type":"User","site_admin":false},"open_issues":270,"closed_issues":95,"state":"open","created_at":"2014-03-28T13:17:36Z","updated_at":"2015-10-26T00:16:30Z","due_on":"2015-11-03T23:00:00Z","closed_at":null},"comments":16,"created_at":"2015-04-09T12:24:12Z","updated_at":"2015-10-26T07:35:05Z","closed_at":"2015-10-26T00:14:26Z","body":"The hashCode function of the ORecordId class seems to not work properly:\r\n```java\r\n    ORecordId rec = new ORecordId(12, 31);\r\n    int hash = rec.hashCode();\r\n    ORecordId rec1 = new ORecordId(13, 0);\r\n    int hash1 = rec1.hashCode();\r\n```\r\n\r\nBoth hash and hash1 returns \"403\" as integer value.\r\n\r\nVersion: 2.0.5"},"comment":{"url":"https://api.github.com/repos/orientechnologies/orientdb/issues/comments/151049841","html_url":"https://github.com/orientechnologies/orientdb/issues/3903#issuecomment-151049841","issue_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/3903","id":151049841,"user":{"login":"PhantomYdn","id":1199285,"avatar_url":"https://avatars.githubusercontent.com/u/1199285?v=3","gravatar_id":"","url":"https://api.github.com/users/PhantomYdn","html_url":"https://github.com/PhantomYdn","followers_url":"https://api.github.com/users/PhantomYdn/followers","following_url":"https://api.github.com/users/PhantomYdn/following{/other_user}","gists_url":"https://api.github.com/users/PhantomYdn/gists{/gist_id}","starred_url":"https://api.github.com/users/PhantomYdn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PhantomYdn/subscriptions","organizations_url":"https://api.github.com/users/PhantomYdn/orgs","repos_url":"https://api.github.com/users/PhantomYdn/repos","events_url":"https://api.github.com/users/PhantomYdn/events{/privacy}","received_events_url":"https://api.github.com/users/PhantomYdn/received_events","type":"User","site_admin":false},"created_at":"2015-10-26T07:35:05Z","updated_at":"2015-10-26T07:35:05Z","body":"And, btw, there is no requirement in java to have different hashcodes for different objects.\r\nBut for hashcode for ORecordId I would recommend the following requirements:\r\n1) Very low probability of impact in case of the same cluster rather than between clusters\r\n2) Very fast in calculation\r\n\r\nAnd if I'm correct the following (autogenerated in eclipse) function might be much better for that:\r\n\r\n```\r\n@Override\r\n\tpublic int hashCode() {\r\n\t\tfinal int prime = 31;\r\n\t\tint result = 1;\r\n\t\tresult = prime * result + clusterId;\r\n\t\tresult = prime * result + clusterPosition;\r\n\t\treturn result;\r\n\t}\r\n``` "}}