Common Lisp Package: SWAP-FILE

README:

FUNCTION

Public

CLOSE (SWAP-FILE)

Closes swap-file.

CREATE (FILESPEC &KEY (IF-EXISTS ERROR) (BLOCK-SIZE 4096))

Creates and returns new swap-file. Swap-file is created to given filespec.

CREATE-BLOCK (SWAP-FILE &KEY (NEXT 0) (DATA (MAKE-EMPTY-DATA SWAP-FILE)))

Allocates and returns empty disk block from swap-file.

DISK-BLOCK-OFFSET (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

FLUSH (SWAP-FILE)

Forces all written changes to be written on to swap-file's file.

OPEN (FILESPEC &KEY (IF-EXISTS OVERWRITE) (IF-DOES-NOT-EXIST ERROR))

Opens and returns existing swap-file.

OPEN-BLOCK (SWAP-FILE OFFSET)

Opens and returns existing disk block from swap-file.

ROLLBACK (SWAP-FILE)

Discard all changes to a swap-file.

SET-FILE-POSITION-AFTER-HEADER (SWAP-FILE &OPTIONAL (OFFSET 0))

Sets swap file's file position after swap file header. If offset is given, the offset is added to file position. The file position after header is reserved for application meta data. Available meta data size is block size reduced by header size.

SWAP-FILE-STREAM (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

WRITE-UINT32-TO-DISK (VALUE SWAP-FILE)

Write 32-bit unsigned byte to disk. Value is written to a write ahead log.

Undocumented

CREATE-BLOCK-STREAM (SWAP-FILE)

SETFDISK-BLOCK-OFFSET (NEW-VALUE INSTANCE)

FORMAT-COMMENT (COMMENT)

FORMAT-DATA (DATA BLOCK-SIZE &OPTIONAL (DATA-FORMATTER #'FORMAT-SWAP-FILE-DATA))

FORMAT-OCTET (V)

FORMAT-SWAP-FILE (SWAP-FILE &OPTIONAL (DATA-FORMATTER #'FORMAT-SWAP-FILE-DATA))

OPEN-BLOCK-STREAM (SWAP-FILE OFFSET &KEY OPTION)

SETFSWAP-FILE-STREAM (NEW-VALUE INSTANCE)

Private

ALLOCATE-NEW-BLOCK (SWAP-FILE &OPTIONAL (DATA (MAKE-EMPTY-DATA SWAP-FILE)))

Returns new empty block from swap file. Disk block is allocated from end of the file if none is available. Empty block data array contains only zeros and fill pointer is set to 0. If data is given, the given data is to allocated block but not flushed to the disk. In that case caller should call write-disk-block after allocation.

APPEND-TO-AVAILABLE (DISK-BLOCK SWAP-FILE)

Pushes given disk-block to swap-file's available list. Available list is updated at disk.

AVAILABLE-P (SWAP-FILE)

Returns t if there is available (deleted) blocks on swap-file, nil otherwise.

CLOSE-BLOCK (SWAP-FILE DISK-BLOCK)

Closes disk block.

CREATE-JOURNAL (SWAP-FILE)

Create journal for a swap-file.

DATA-SIZE-BELOW-MAX (DISK-BLOCK)

Returns disk blocks data size or disk block maximum data size if current disk block's data size is over than maximum.

DISK-BLOCK-DATA (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DISK-BLOCK-DATA-SIZE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DISK-BLOCK-DELETED-P (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DISK-BLOCK-MAX-DATA (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DISK-BLOCK-NEXT (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

ENSURE-DISK-BLOCK (DISK-BLOCK-SPEC SWAP-FILE)

Returns or opens and returns a disk block.

GET-FIRST-AVAILABLE (SWAP-FILE)

Returns first available (deleted) disk block or nil if there is no available disk blocks.

GET-FROM-CACHE (SWAP-FILE OFFSET)

Returns disk block from cache, or nil if disk block with given offset does not exist.

MAKE-DATA-ARRAY (SWAP-FILE INITIAL-CONTENTS)

Returns an array of bytes with given initial contents.

MAKE-EMPTY-DATA (SWAP-FILE)

Returns an empty array of bytes. Array's initial size is max-data-size but the array is adjustable.

MAKE-MASTER-WRITER (SWAP-FILE)

Returns master writer function. The master writer is called by write-ahead log when an entry is committed to swap-file's stream. Master writer locates entry's file position and writes entry's contents to that position.

MAX-DATA-SIZE (BLOCK-SIZE)

Returns maximum size of payload data. This size block-size reduced by the size of block header.

MERGE-DATA (DATA-CHUNKS)

Returns a new adjustable array with fill pointer. Arrays size is equal to sum of given data chunks and contents are merged from data chunks. Data chunks are arrays themselves.

NEXT-P (DISK-BLOCK)

Returns t if disk bock has next block set, nil otherwise.

OFFSET (DISK-BLOCK)

Returns disk block's offset or 0 if disk block is nil.

OPEN-JOURNAL (SWAP-FILE)

Open existing journal for a swap-file.

PUSH-TO-CACHE (SWAP-FILE DISK-BLOCK)

Push disk block to swap-file disk block cache.

READ-CONNECTED-BLOCKS (SWAP-FILE OFFSET)

Returns a list of connected disk blocks read from swap-file starting from disk block at given offset.

READ-DATA (SWAP-FILE OFFSET)

Returns an adjustable array with fill pointer. Function read-data reads connected disk blocks from swap-file starting from given offset. If disk block extends to next block, the data of consequtive blocks are automatically appended to the data array of the read block. In other words, returned data array may contain data from multiple disk blocks.

READ-DISK-BLOCK (SWAP-FILE OFFSET)

Reads and returns disk block from swap file. If disk node is marked as deleted, the data is not read.

READ-DISK-BLOCK-ARRAY (STREAM BLOCK-SIZE)

Reads and returns (single) disk block's data as an array of bytes.

READ-SWAP-FILE-FIRST-AVAILABLE (SWAP-FILE)

Reads and returns offset of first available (deleted) disk block. If there is no available blocks, returns 0.

READ-SWAP-FILE-HEADER (SWAP-FILE)

Reads swap-file header and updates swap-file structure. Returns updated swap-file structure.

READ-SWAP-FILE-NEXT-NEW-OFFSET (SWAP-FILE)

Reads and returns offset of the next new disk block.

SET-BLOCK-DATA (DISK-BLOCK DATA)

Sets disk-blocks data. Returns updated disk-block.

SPLIT-DATA (DATA MAX-SIZE)

Returns data splitted to a list of byte arrays with each having size below max-size.

SWAP-FILE-AVAILABLE-LIST (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SWAP-FILE-BLOCK-CACHE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SWAP-FILE-BLOCK-SIZE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SWAP-FILE-HEADER-SIZE

Returns size of swap-file header.

SWAP-FILE-JOURNAL (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SWAP-FILE-NEXT-NEW-OFFSET (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SWAP-FILE-OPEN-BLOCKS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SWAP-FILE-VERSION (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

WAL-ENTRY-READER (STREAM)

Reads a journal entry from stream. The function is reader for write-ahead log.

WAL-ENTRY-WRITER (ENTRY STREAM)

Writes a journal entry to a stream. The function is writer for write-ahead log.

WRITE-CONNECTED-BLOCKS (DATA-CHUNKS SWAP-FILE OFFSET)

Writes data splitted to data-chunks to the swap-file starting from disk block at given offset. The old disk block contents are overwritten. If the data is shorter than old data the exceeding disk blocks are deleted. If the data is longer than old data new disk blocks are allocated as needed.

WRITE-DATA (DATA SWAP-FILE OFFSET)

Write data to a swap-file and to a given offset.

WRITE-DISK-BLOCK (DISK-BLOCK SWAP-FILE)

Write disk block to swap file. The disk block must be allocated before it can be written. If the data array contents exceed block size new blocks are allocated until all data can fit and also exceeding data is written to the disk.

WRITE-SEQUENCE-TO-DISK (DATA SWAP-FILE)

Write sequence to disk. Sequence is written to a write ahead log.

WRITE-SWAP-FILE-FIRST-AVAILABLE (OFFSET SWAP-FILE)

Writes offset of first available (deleted) disk block to the swap-file's stream.

WRITE-SWAP-FILE-HEADER (SWAP-FILE)

Write swap-file's header to a swap-file's stream.

WRITE-SWAP-FILE-NEXT-NEW-OFFSET (SWAP-FILE)

Writes offset of the next new disk block to swap-file's stream.

WRITE-UINT8-TO-DISK (VALUE SWAP-FILE)

Write 8-bit unsigned byte to disk. Value is written to a write ahead log.

Undocumented

CONVERT-TO-LIST (DATA)

COPY-DISK-BLOCK (INSTANCE)

COPY-SWAP-FILE (INSTANCE)

SETFDISK-BLOCK-DATA (NEW-VALUE INSTANCE)

SETFDISK-BLOCK-DATA-SIZE (NEW-VALUE INSTANCE)

SETFDISK-BLOCK-DELETED-P (NEW-VALUE INSTANCE)

SETFDISK-BLOCK-MAX-DATA (NEW-VALUE INSTANCE)

SETFDISK-BLOCK-NEXT (NEW-VALUE INSTANCE)

DISK-BLOCK-P (OBJECT)

FORMAT-NEW-LINE

FORMAT-SWAP-FILE-BLOCK-HEADER (DATA &OPTIONAL (COUNT 0) &AUX (V (CAR DATA)))

FORMAT-SWAP-FILE-DATA (DATA &OPTIONAL (COUNT 0) &AUX (V (CAR DATA)))

FORMAT-SWAP-FILE-DATA-BLOCK (BLOCK-DATA &OPTIONAL (DATA-FORMATTER #'FORMAT-SWAP-FILE-DATA))

FORMAT-SWAP-FILE-HEADER (BLOCK-DATA &OPTIONAL (BLOCK-SIZE (LENGTH BLOCK-DATA)))

MAKE-DISK-BLOCK (&KEY ((OFFSET DUM86) 0) ((MAX-DATA DUM87) 0) ((DELETED-P DUM88) NIL) ((NEXT DUM89) 0) ((DATA-SIZE DUM90) 0) ((DATA DUM91) NIL))

MAKE-DISK-BLOCK-STREAM (OFFSET SWAP-FILE &KEY OPTION)

MAKE-SWAP-FILE (&KEY ((VERSION DUM0) 1) ((BLOCK-SIZE DUM1) 4096) ((NEXT-NEW-OFFSET DUM2) 0) ((AVAILABLE-LIST DUM3) 0) ((BLOCK-CACHE DUM4) NIL) ((OPEN-BLOCKS DUM5) NIL) ((JOURNAL DUM6) NIL) ((STREAM DUM7) NIL))

READ-SWAP-FILE-DATA (SWAP-FILE)

RESET-COLUMN

SPLIT-TO-BLOCKS (DATA BLOCK-SIZE)

SETFSWAP-FILE-AVAILABLE-LIST (NEW-VALUE INSTANCE)

SETFSWAP-FILE-BLOCK-CACHE (NEW-VALUE INSTANCE)

SETFSWAP-FILE-BLOCK-SIZE (NEW-VALUE INSTANCE)

SETFSWAP-FILE-JOURNAL (NEW-VALUE INSTANCE)

SETFSWAP-FILE-NEXT-NEW-OFFSET (NEW-VALUE INSTANCE)

SETFSWAP-FILE-OPEN-BLOCKS (NEW-VALUE INSTANCE)

SWAP-FILE-P (OBJECT)

SETFSWAP-FILE-VERSION (NEW-VALUE INSTANCE)

MACRO

Public

Undocumented

WITH-OPEN-BLOCK-STREAM ((STREAM SWAP-FILE OFFSET &KEY OPTION) &BODY BODY)

GENERIC-FUNCTION

Private

Undocumented

DATA-SIZE (OBJ)

SLOT-ACCESSOR

Private

Undocumented

STREAM-MODIFIED (OBJECT)

SETFSTREAM-MODIFIED (NEW-VALUE OBJECT)

STREAM-OFFSET (OBJECT)

STREAM-OPTION (OBJECT)

STREAM-SWAP-FILE (OBJECT)

CLASS

Public

Undocumented

SWAP-FILE

Private

Undocumented

DISK-BLOCK

DISK-BLOCK-STREAM