home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / OOFILE / docs / ctree.txt < prev    next >
Encoding:
Text File  |  1995-08-24  |  4.3 KB  |  107 lines  |  [TEXT/ttxt]

  1. CTREE CHANGES FOR MACINTOSH PROGRAMMERS
  2. (The following will hopefully be rolled into later releases of c-tree)
  3.  
  4. c-tree changes to enable Mac databases to be built with different creators and types, getting around the current hard-coded constants.
  5.  
  6. 1) in ctclib.c, just before the definition of sopen(), add the lines
  7.     long ctMacCreator = 'CTRE';
  8.     long ctMacType = '????';
  9.  
  10. 2) in ctclib.c, change the following line in sopen()
  11.     rtn = sopenWithType(afilnam, acflag,shflag, 'CTRE', '????');
  12. to
  13.     rtn = sopenWithType(afilnam, acflag,shflag, ctMacCreator, ctMacType);
  14.  
  15. 3) in ctoptn.h, add the following 3 lines
  16. // Macintosh programmers only, hack to allow setting types
  17. extern long ctMacCreator;
  18. extern long ctMacType;
  19.  
  20.  
  21.  
  22. CTREE BACKEND IMPLEMENTATION DETAILS
  23. This provides some documentation of how the c-tree Plus backend works, as much
  24. for our benefit as yours - you should never be fiddling with these mechanisms
  25. unless you are prepared to accept the responsibility of possibly breaking the
  26. database engine.
  27.  
  28. On the other hand, if you have suggested improvements - great!
  29.  
  30.  
  31. COMPARATIVE SEARCHES FOR UNIQUE KEYS
  32. Greater-than
  33. Must append a suffix to the key that's the highest possible suffix. 
  34. eg:
  35. key = 1
  36. first actual value = 1 suffix 26,345
  37. to prevent finding that key, we need to search for > 1 suffix MAXLONG
  38.  
  39. Greater-than or equal
  40. Must append a suffix to the key that's the lowest possible suffix. 
  41. eg:
  42. key = 1
  43. first actual value = 1 suffix 26,345
  44. to find that key, we need to search for > 1 suffix 0
  45.  
  46. Less than
  47. Must append a suffix to the key that's the lowest possible suffix. 
  48. eg:
  49. key = 1
  50. first actual value = 1 suffix 26,345
  51. to find that key, we need to search for < 1 suffix 0
  52.  
  53. Less than or equal
  54. Must append a suffix to the key that's the highest possible suffix. 
  55. eg:
  56. key = 1
  57. first actual value = 1 suffix 26,345
  58. to find that key, we need to search for < 1 suffix MAXLONG
  59.  
  60.  
  61. DUPLICATE KEY BACKGROUND
  62. c-tree handles dup keys by appending the record offset to the key, to make it unique. This means you can't predict the complete value of the key, or the starting key!
  63.  
  64. COMPARATIVE SEARCHES FOR DUPLICATE KEYS
  65. Greater-than
  66. Must append a suffix to the key that's the highest possible suffix. 
  67. eg:
  68. key = 1
  69. first actual value = 1 suffix 26,345
  70. to prevent finding that key, we need to search for > 1 suffix MAXLONG
  71.  
  72. Greater-than or equal
  73. Must append a suffix to the key that's the lowest possible suffix. 
  74. eg:
  75. key = 1
  76. first actual value = 1 suffix 26,345
  77. to find that key, we need to search for > 1 suffix 0
  78.  
  79. Less than
  80. Must append a suffix to the key that's the lowest possible suffix. 
  81. eg:
  82. key = 1
  83. first actual value = 1 suffix 26,345
  84. to find that key, we need to search for < 1 suffix 0
  85.  
  86. Less than or equal
  87. Must append a suffix to the key that's the highest possible suffix. 
  88. eg:
  89. key = 1
  90. first actual value = 1 suffix 26,345
  91. to find that key, we need to search for < 1 suffix MAXLONG
  92.  
  93.  
  94. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  95. FIELD MAPPING TO STORAGE
  96. There is a record buffer associated with every dbTable instance. (We can think about optimizing this with lazy evaluation later.)
  97.  
  98. This record buffer is mapped to the field by a table of offsets and lengths, stored in the OOFILE_tableBackend_ctree class. This mapping table is used in constructing the ctree ISEG structures describing the indexes. It is also used in transferring data between the record buffer and gui classes, or other operators that transfer data. (eg: operator=, operator char* & stream output).
  99.  
  100. Thus, most fields don't have a separate buffer but just refer into the main record buffer.
  101.  
  102. Blob, Text and other (future) expandable fields are contained in a separate file. There is one Blob file per connection (ie: superfile enclosing a set of c-tree files).
  103.  
  104. To optimize writing and reading Blob records, they are not pulled in from the database until needed, by some data interchange or linking to a gui editing class. The blobs are also only written back if updated. Thus, a blob is managed by a pair of length and record offset fields in the main record. The dbBlob object contains also a dirty flag and a pointer to a memory buffer. 
  105.  
  106. A blob which has been cleared or never written has a zero length and no corresponding blob record. This means we have some special case handling for empty dbText fields, which contain a single char - the terminating null, but should be treated as zero-length blobs rather than length=1.
  107.