Loading...

sqlite-dev@sqlite.org

[Prev] Thread [Next]  |  [Prev] Date [Next]

[sqlite-dev] Struct member ordering Jim Gullen Thu Feb 02 14:05:15 2012

Apologies if this subject has been "discussed to death".
---
1. (I think) Struct member order should be largest to smallest (for best 
compaction), where possible.
Consider struct MemPage in btreeInt.h, which ordering is nearly the opposite:
8 u8s (was 7 u8s until recently)   // impl requirement note: "u8 isInit" must 
be the first byte
6 u16s
5 of these: struct _OvflCell { u8*, u16 }
5 ptrs of various datatypes
1 u32
New order?: 8 u8s, 5 ptrs, 5 structs, 1 u32, 6 u16s
---
2. (I think) Alphabetizing is an ever-present order of the day, where possible.
  u8 isInit;           /* True if previously initialized. MUST BE FIRST! */
  u8 nOverflow;        /* Number of overflow cell bodies in aCell[] */
  u8 intKey;           /* True if intkey flag is set */
  u8 leaf;             /* True if leaf flag is set */
  u8 hasData;          /* True if this page stores data */
  u8 hdrOffset;        /* 100 for page 1.  0 otherwise */
  u8 childPtrSize;     /* 0 if leaf==1.  4 if leaf==0 */
  u8 max1bytePayload;  /* min(maxLocal,127) */
---
  u8 isInit;           /* True if previously initialized. MUST BE FIRST! */
  u8 childPtrSize;     /* 0 if leaf==1.  4 if leaf==0 */
  u8 hasData;          /* True if this page stores data */
  u8 hdrOffset;        /* 100 for page 1.  0 otherwise */
  u8 intKey;           /* True if intkey flag is set */
  u8 leaf;             /* True if leaf flag is set */
  u8 max1bytePayload;  /* min(maxLocal,127) */
  u8 nOverflow;        /* Number of overflow cell bodies in aCell[] */
_______________________________________________
sqlite-dev mailing list
[EMAIL PROTECTED]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-dev