mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-21 15:10:44 +00:00
71 lines
2.2 KiB
C
71 lines
2.2 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* file_cache.h
|
|
* Local File Cache definitions
|
|
*
|
|
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef FILE_CACHE_h
|
|
#define FILE_CACHE_h
|
|
|
|
#include "neon_pgversioncompat.h"
|
|
|
|
typedef struct FileCacheState
|
|
{
|
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
|
uint32 magic;
|
|
uint32 n_chunks;
|
|
uint32 n_pages;
|
|
uint16 chunk_size_log;
|
|
BufferTag chunks[FLEXIBLE_ARRAY_MEMBER];
|
|
/* followed by bitmap */
|
|
} FileCacheState;
|
|
|
|
/* GUCs */
|
|
extern bool lfc_store_prefetch_result;
|
|
extern int lfc_max_size;
|
|
extern int lfc_size_limit;
|
|
extern char *lfc_path;
|
|
|
|
/* functions for local file cache */
|
|
extern void lfc_invalidate(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber nblocks);
|
|
extern void lfc_writev(NRelFileInfo rinfo, ForkNumber forkNum,
|
|
BlockNumber blkno, const void *const *buffers,
|
|
BlockNumber nblocks);
|
|
/* returns number of blocks read, with one bit set in *read for each */
|
|
extern int lfc_readv_select(NRelFileInfo rinfo, ForkNumber forkNum,
|
|
BlockNumber blkno, void **buffers,
|
|
BlockNumber nblocks, bits8 *mask);
|
|
|
|
extern bool lfc_cache_contains(NRelFileInfo rinfo, ForkNumber forkNum,
|
|
BlockNumber blkno);
|
|
extern int lfc_cache_containsv(NRelFileInfo rinfo, ForkNumber forkNum,
|
|
BlockNumber blkno, int nblocks, bits8 *bitmap);
|
|
extern void lfc_init(void);
|
|
extern bool lfc_prefetch(NRelFileInfo rinfo, ForkNumber forknum, BlockNumber blkno,
|
|
const void* buffer, XLogRecPtr lsn);
|
|
extern FileCacheState* lfc_get_state(size_t max_entries);
|
|
extern void lfc_prewarm(FileCacheState* fcs, uint32 n_workers);
|
|
|
|
PGDLLEXPORT void lfc_prewarm_main(Datum main_arg);
|
|
|
|
static inline bool
|
|
lfc_read(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber blkno,
|
|
void *buffer)
|
|
{
|
|
bits8 rv = 0;
|
|
return lfc_readv_select(rinfo, forkNum, blkno, &buffer, 1, &rv) == 1;
|
|
}
|
|
|
|
static inline void
|
|
lfc_write(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber blkno,
|
|
const void *buffer)
|
|
{
|
|
return lfc_writev(rinfo, forkNum, blkno, &buffer, 1);
|
|
}
|
|
|
|
#endif /* FILE_CACHE_H */
|