List:Falcon Storage Engine« Previous MessageNext Message »
From:Lars-Erik Bjørk Date:December 19 2008 10:39am
Subject:Some questions
View as plain text  
Hi again.

There is some parts of StorageDatabase::getSegmentValue that confuses  
me.

First of all, it seems that some of the keys are passed from the  
server as endian independent, whereas some of them are not. Do you  
know if that really is the case? It looks kind of strange to me.

Second, why do we do things like this:

            int64 temp = (int64)
                 ((uint64)(((uint32) ((UCHAR) ptr[0])) +
                     (((uint32) ((UCHAR) ptr[1])) << 8) +
                     (((uint32) ((UCHAR) ptr[2])) << 16) +
                     (((uint32) ((UCHAR) ptr[3])) << 24)) +
                 (((uint64)(((uint32) ((UCHAR) ptr[4])) +
                     (((uint32) ((UCHAR) ptr[5])) << 8) +
                     (((uint32) ((UCHAR) ptr[6])) << 16) +
                     (((uint32) ((UCHAR) ptr[7])) << 24)))
                 << 32));
             value->setValue(temp);

  instead of

             int64 temp;
             memcpy(&temp, ptr, sizeof(temp));
             value->setValue(temp);
?

Is the memcpy significantly slower? It is used elsewhere in the same  
method, for example for float. I find the memcpy alternative to be  
much more readable, that is for sure!
Maybe I am just mixing things here, I used to be a Java boy, all this  
casting and bit-shifting confuses me :)

/Lars-Erik
Thread
Some questionsLars-Erik Bjørk19 Dec
  • RE: Some questionsVladislav Vaintroub19 Dec
    • Re: Some questionsLars-Erik Bjørk19 Dec