1999-10-13 17:02:32 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* buffile.h
|
2017-11-25 19:19:43 +01:00
|
|
|
* Management of large buffered temporary files.
|
1999-10-13 17:02:32 +02:00
|
|
|
*
|
|
|
|
* The BufFile routines provide a partial replacement for stdio atop
|
|
|
|
* virtual file descriptors managed by fd.c. Currently they only support
|
|
|
|
* buffered access to a virtual file, without any of stdio's formatting
|
|
|
|
* features. That's enough for immediate needs, but the set of facilities
|
|
|
|
* could be expanded if necessary.
|
|
|
|
*
|
|
|
|
* BufFile also supports working with temporary files that exceed the OS
|
|
|
|
* file size limit and/or the largest offset representable in an int.
|
|
|
|
* It might be better to split that out as a separately accessible module,
|
|
|
|
* but currently we have no need for oversize temp files without buffered
|
|
|
|
* access.
|
|
|
|
*
|
2022-01-08 01:04:57 +01:00
|
|
|
* Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1999-10-13 17:02:32 +02:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/storage/buffile.h
|
1999-10-13 17:02:32 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BUFFILE_H
|
|
|
|
#define BUFFILE_H
|
|
|
|
|
2021-08-30 05:15:35 +02:00
|
|
|
#include "storage/fileset.h"
|
2017-12-02 01:30:56 +01:00
|
|
|
|
1999-10-13 17:02:32 +02:00
|
|
|
/* BufFile is an opaque type whose details are not known outside buffile.c. */
|
|
|
|
|
|
|
|
typedef struct BufFile BufFile;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* prototypes for functions in buffile.c
|
|
|
|
*/
|
|
|
|
|
2007-06-07 21:19:57 +02:00
|
|
|
extern BufFile *BufFileCreateTemp(bool interXact);
|
1999-10-13 17:02:32 +02:00
|
|
|
extern void BufFileClose(BufFile *file);
|
|
|
|
extern size_t BufFileRead(BufFile *file, void *ptr, size_t size);
|
2020-06-16 07:23:36 +02:00
|
|
|
extern void BufFileWrite(BufFile *file, void *ptr, size_t size);
|
2008-03-10 21:06:27 +01:00
|
|
|
extern int BufFileSeek(BufFile *file, int fileno, off_t offset, int whence);
|
|
|
|
extern void BufFileTell(BufFile *file, int *fileno, off_t *offset);
|
1999-10-16 21:49:28 +02:00
|
|
|
extern int BufFileSeekBlock(BufFile *file, long blknum);
|
2018-11-15 00:34:04 +01:00
|
|
|
extern int64 BufFileSize(BufFile *file);
|
Support parallel btree index builds.
To make this work, tuplesort.c and logtape.c must also support
parallelism, so this patch adds that infrastructure and then applies
it to the particular case of parallel btree index builds. Testing
to date shows that this can often be 2-3x faster than a serial
index build.
The model for deciding how many workers to use is fairly primitive
at present, but it's better than not having the feature. We can
refine it as we get more experience.
Peter Geoghegan with some help from Rushabh Lathia. While Heikki
Linnakangas is not an author of this patch, he wrote other patches
without which this feature would not have been possible, and
therefore the release notes should possibly credit him as an author
of this feature. Reviewed by Claudio Freire, Heikki Linnakangas,
Thomas Munro, Tels, Amit Kapila, me.
Discussion: http://postgr.es/m/CAM3SWZQKM=Pzc=CAHzRixKjp2eO5Q0Jg1SoFQqeXFQ647JiwqQ@mail.gmail.com
Discussion: http://postgr.es/m/CAH2-Wz=AxWqDoVvGU7dq856S4r6sJAj6DBn7VMtigkB33N5eyg@mail.gmail.com
2018-02-02 19:25:55 +01:00
|
|
|
extern long BufFileAppend(BufFile *target, BufFile *source);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2021-08-30 05:15:35 +02:00
|
|
|
extern BufFile *BufFileCreateFileSet(FileSet *fileset, const char *name);
|
|
|
|
extern void BufFileExportFileSet(BufFile *file);
|
|
|
|
extern BufFile *BufFileOpenFileSet(FileSet *fileset, const char *name,
|
2021-09-02 04:43:46 +02:00
|
|
|
int mode, bool missing_ok);
|
|
|
|
extern void BufFileDeleteFileSet(FileSet *fileset, const char *name,
|
|
|
|
bool missing_ok);
|
2021-08-30 05:15:35 +02:00
|
|
|
extern void BufFileTruncateFileSet(BufFile *file, int fileno, off_t offset);
|
2017-12-02 01:30:56 +01:00
|
|
|
|
1999-10-13 17:02:32 +02:00
|
|
|
#endif /* BUFFILE_H */
|