Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.6 KiB

  1. //============== DAE: OS/2 Database Access Engine ===================
  2. //============== SCB: Sort Control Block ===================
  3. #ifndef FCB_INCLUDED
  4. #error scb.h requires fcb.h
  5. #endif /* FCB_INCLUDED */
  6. #ifdef SCB_INCLUDED
  7. #error scb.h already included
  8. #endif /* SCB_INCLUDED */
  9. #define SCB_INCLUDED
  10. typedef ULONG RID, *PRID;
  11. typedef struct
  12. {
  13. PN pn;
  14. UINT cbfRun;
  15. } RUN, *PRUN;
  16. /* choose crunMost so that crunMost % crunMergeMost = crunMergeMost - 1
  17. /**/
  18. #define crunMergeMost 16 // max number of runs to be merged
  19. #define crunMost 31 // size of run directory
  20. #define fSCBInsert (1<<0)
  21. #define fSCBIndex (1<<1)
  22. #define fSCBUnique (1<<2)
  23. #define SCBSetInsert( pscb ) ((pscb)->fFlags |= fSCBInsert )
  24. #define SCBResetInsert( pscb ) ((pscb)->fFlags &= ~fSCBInsert )
  25. #define FSCBInsert( pscb ) ((pscb)->fFlags & fSCBInsert )
  26. #define SCBSetIndex( pscb ) ((pscb)->fFlags |= fSCBIndex )
  27. #define SCBResetIndex( pscb ) ((pscb)->fFlags &= ~fSCBIndex )
  28. #define FSCBIndex( pscb ) ((pscb)->fFlags & fSCBIndex )
  29. #define SCBSetUnique( pscb ) ((pscb)->fFlags |= fSCBUnique )
  30. #define SCBResetUnique( pscb ) ((pscb)->fFlags &= ~fSCBUnique )
  31. #define FSCBUnique( pscb ) ((pscb)->fFlags & fSCBUnique )
  32. struct _scb
  33. {
  34. struct _fcb fcb; // MUST BE FIRST FIELD IN STRUCTURE
  35. JET_GRBIT grbit; // sort grbit
  36. INT fFlags; // sort flags
  37. // in-memory related
  38. LONG cbSort; // size of sort buffer
  39. #ifdef WIN16
  40. HANDLE hrgbSort; // handle for sort buffer
  41. #endif /* WIN16 */
  42. BYTE *rgbSort; // sort buffer
  43. BYTE *pbEnd; // end of last inserted record
  44. BYTE **rgpb; // beginning of array of pointers
  45. BYTE **ppbMax; // end of array of pointers
  46. LONG wRecords; // count of records in sort buffer
  47. // disk related
  48. BYTE *rgpbMerge[crunMost];
  49. struct _bf *rgpbf[crunMergeMost];
  50. struct _bf *pbfOut; // output buffer
  51. BYTE *pbOut; // current pos in output buffer
  52. BYTE *pbMax; // end of output buffer (could be computed)
  53. RUN rgrun[crunMost]; // run directory
  54. INT crun;
  55. INT bf; // input buffers
  56. INT cpbMerge; // merge tree
  57. #ifdef DEBUG
  58. LONG cbfPin;
  59. LONG lInput;
  60. LONG lOutput;
  61. #endif
  62. };
  63. #ifdef DEBUG
  64. #define SCBPin( pscb ) ( (pscb)->cbfPin++ )
  65. #define SCBUnpin( pscb ) { Assert( (pscb)->cbfPin > 0 ); (pscb)->cbfPin--; }
  66. #else
  67. #define SCBPin( pscb )
  68. #define SCBUnpin( pscb )
  69. #endif
  70. #define PscbMEMAlloc() (SCB*)PbMEMAlloc(iresSCB)
  71. #ifdef DEBUG /* Debug check for illegal use of freed scb */
  72. #define MEMReleasePscb(pscb) { MEMRelease(iresSCB, (BYTE*)(pscb)); pscb = pscbNil; }
  73. #else
  74. #define MEMReleasePscb(pscb) { MEMRelease(iresSCB, (BYTE*)(pscb)); }
  75. #endif