[ 
https://issues.apache.org/jira/browse/SOLR-743?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12627684#action_12627684
 ] 

Yonik Seeley commented on SOLR-743:
-----------------------------------

bq. Any chance on sharing the test code used for that ? 

I checked it in for future reference.... it's commented out in 
BasicFunctionalityTest.

{code}
  public void testFieldPerf() {
    IndexSchema schema = h.getCore().getSchema();
    SchemaField[] fields = schema.getDynamicFieldPrototypes();
    boolean createNew = false;

    long start = System.currentTimeMillis();
    int ret = 0;
    for (int i=0; i<10000000; i++) {
      for (SchemaField f : fields) {
        if (createNew) f = new SchemaField(f, "fakename");
        if (f.indexed()) ret += 1;
        if (f.isCompressed()) ret += 2;
        if (f.isRequired()) ret += 3;
        if (f.multiValued()) ret += 4;
        if (f.omitNorms()) ret += 5;
        if (f.sortMissingFirst()) ret += 6;
        if (f.sortMissingLast())ret += 7;
        if (f.stored()) ret += 8;
        if (f.storeTermOffsets()) ret += 9;
        if (f.storeTermPositions()) ret += 10;
        if (f.storeTermVector()) ret += 11;
      }
    }
    long end = System.currentTimeMillis();
    System.out.println("ret=" + ret + " time="+ (end-start));
{code}

A native bitwise-and + check for non-zero is a single cycle instruction (TEST 
in x86).  Consider everything else that needs to be done for EnumSet.contains()
- possible null check on the EnumSet instance, method call, then null check on 
the param
- getClass() and compare to check to see that the enum being checked for is of 
the right class (COLOR and not SUIT, etc)
- cast to Enum type, get the ordinal value, do a shift by that value, then do 
the bitwise-and.



> Update the bitset usage in Schema to enums
> ------------------------------------------
>
>                 Key: SOLR-743
>                 URL: https://issues.apache.org/jira/browse/SOLR-743
>             Project: Solr
>          Issue Type: Improvement
>            Reporter: Mark Miller
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: SOLR-743.patch, SOLR-743.patch
>
>
> For all of the reasons given by smarter people than I (specifically, 
> Effective Java), and because its just easier to follow.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to