gooderp18绿色标准版
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

79 lines
3.0KB

  1. /*-------------------------------------------------------------------------
  2. *
  3. * logtape.h
  4. * Management of "logical tapes" within temporary files.
  5. *
  6. * See logtape.c for explanations.
  7. *
  8. * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  9. * Portions Copyright (c) 1994, Regents of the University of California
  10. *
  11. * src/include/utils/logtape.h
  12. *
  13. *-------------------------------------------------------------------------
  14. */
  15. #ifndef LOGTAPE_H
  16. #define LOGTAPE_H
  17. #include "storage/sharedfileset.h"
  18. /* LogicalTapeSet is an opaque type whose details are not known outside logtape.c. */
  19. typedef struct LogicalTapeSet LogicalTapeSet;
  20. /*
  21. * The approach tuplesort.c takes to parallel external sorts is that workers,
  22. * whose state is almost the same as independent serial sorts, are made to
  23. * produce a final materialized tape of sorted output in all cases. This is
  24. * frozen, just like any case requiring a final materialized tape. However,
  25. * there is one difference, which is that freezing will also export an
  26. * underlying shared fileset BufFile for sharing. Freezing produces TapeShare
  27. * metadata for the worker when this happens, which is passed along through
  28. * shared memory to leader.
  29. *
  30. * The leader process can then pass an array of TapeShare metadata (one per
  31. * worker participant) to LogicalTapeSetCreate(), alongside a handle to a
  32. * shared fileset, which is sufficient to construct a new logical tapeset that
  33. * consists of each of the tapes materialized by workers.
  34. *
  35. * Note that while logtape.c does create an empty leader tape at the end of the
  36. * tapeset in the leader case, it can never be written to due to a restriction
  37. * in the shared buffile infrastructure.
  38. */
  39. typedef struct TapeShare
  40. {
  41. /*
  42. * Currently, all the leader process needs is the location of the
  43. * materialized tape's first block.
  44. */
  45. long firstblocknumber;
  46. } TapeShare;
  47. /*
  48. * prototypes for functions in logtape.c
  49. */
  50. extern LogicalTapeSet *LogicalTapeSetCreate(int ntapes, TapeShare *shared,
  51. SharedFileSet *fileset, int worker);
  52. extern void LogicalTapeSetClose(LogicalTapeSet *lts);
  53. extern void LogicalTapeSetForgetFreeSpace(LogicalTapeSet *lts);
  54. extern size_t LogicalTapeRead(LogicalTapeSet *lts, int tapenum,
  55. void *ptr, size_t size);
  56. extern void LogicalTapeWrite(LogicalTapeSet *lts, int tapenum,
  57. void *ptr, size_t size);
  58. extern void LogicalTapeRewindForRead(LogicalTapeSet *lts, int tapenum,
  59. size_t buffer_size);
  60. extern void LogicalTapeRewindForWrite(LogicalTapeSet *lts, int tapenum);
  61. extern void LogicalTapeFreeze(LogicalTapeSet *lts, int tapenum,
  62. TapeShare *share);
  63. extern size_t LogicalTapeBackspace(LogicalTapeSet *lts, int tapenum,
  64. size_t size);
  65. extern void LogicalTapeSeek(LogicalTapeSet *lts, int tapenum,
  66. long blocknum, int offset);
  67. extern void LogicalTapeTell(LogicalTapeSet *lts, int tapenum,
  68. long *blocknum, int *offset);
  69. extern long LogicalTapeSetBlocks(LogicalTapeSet *lts);
  70. #endif /* LOGTAPE_H */
上海开阖软件有限公司 沪ICP备12045867号-1