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

Vladimir Ozerov commented on IGNITE-1770:
-----------------------------------------

I propose picking FNV1 algo for schema ID calculation. It offers pretty nice 
distribution. Using it shows minimal performance drop during object write 
(~1-2% in Java with standard Address object).

{code}
private static final int FNV1_OFFSET_BASIS = 0x811C9DC5;
private static final int FNV1_PRIME = 0x01000193;

int schemaId = FNV1_OFFSET_BASIS;

void onFieldAdded(int fieldId) {
    int schemaId0 = schemaId ^ (fieldId & 0xFF);
    schemaId0 = schemaId0 * FNV1_PRIME;
    schemaId0 = schemaId0 ^ ((fieldId >> 8) & 0xFF);
    schemaId0 = schemaId0 * FNV1_PRIME;
    schemaId0 = schemaId0 ^ ((fieldId >> 16) & 0xFF);
    schemaId0 = schemaId0 * FNV1_PRIME;
    schemaId0 = schemaId0 ^ ((fieldId >> 24) & 0xFF);
    schemaId0 = schemaId0 * FNV1_PRIME;

    schemaId = schemaId0;
}
{code}

> Portables: implement constant-time field lookup.
> ------------------------------------------------
>
>                 Key: IGNITE-1770
>                 URL: https://issues.apache.org/jira/browse/IGNITE-1770
>             Project: Ignite
>          Issue Type: Task
>          Components: general, interop
>    Affects Versions: ignite-1.4
>            Reporter: Vladimir Ozerov
>            Assignee: Vladimir Ozerov
>            Priority: Blocker
>             Fix For: 1.5
>
>
> See 
> https://cwiki.apache.org/confluence/display/IGNITE/Portable+object+constant-time+field+lookup



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to