2004-06-25 18:59:24 +00:00
|
|
|
#ifndef __BLOB_MANAGER_H
|
|
|
|
#define __BLOB_MANAGER_H
|
|
|
|
|
|
|
|
#include <lladd/common.h>
|
|
|
|
BEGIN_C_DECLS
|
|
|
|
|
2004-06-28 21:10:10 +00:00
|
|
|
/**
|
|
|
|
@file
|
2004-07-06 20:59:36 +00:00
|
|
|
blobManager - Provides blob handling.
|
|
|
|
|
2004-06-25 18:59:24 +00:00
|
|
|
Plan for modularity: Exactly one blob manager per storeFile.
|
2004-07-06 20:59:36 +00:00
|
|
|
Alternatively, we could use the bufferManager's record length
|
|
|
|
field to allow for more than one blob manager per buffer
|
|
|
|
manager. (Right now, this field is set to a special value for
|
|
|
|
blobs; thie could be extended for other types of records.)
|
|
|
|
|
2004-06-25 18:59:24 +00:00
|
|
|
Blob manager interacts with page manger via page manager's
|
|
|
|
public api.
|
2004-06-28 21:10:10 +00:00
|
|
|
|
|
|
|
Blob updates work as follows:
|
|
|
|
|
|
|
|
(1) A transaction obtains an exclusive write lock on a blob
|
|
|
|
(not implemented yet.)
|
|
|
|
|
|
|
|
(2) When it requests a write, the blob it writes to is added to
|
|
|
|
a data structure that lists all dirty blobs by transaction,
|
|
|
|
and the page containing the blob entry is updated. (The fd
|
|
|
|
bit in the record is flipped, and the LSN is updated.) The
|
|
|
|
write to the blob store is not flushed to disk.
|
|
|
|
|
|
|
|
(3) All subsequent writes to the same blob just update the
|
|
|
|
backing file.
|
|
|
|
|
|
|
|
(4) On commit and rollback, the data structure containing the xid's
|
|
|
|
dirty blobs is destroyed.
|
|
|
|
|
|
|
|
(5) recovery2.c handles the restoration of the fd bits using
|
|
|
|
physical logging (this is automatic, since we use Tset()
|
|
|
|
calls to update the records.)
|
|
|
|
|
|
|
|
@todo Should the tripleHash be its own little support library?
|
2004-07-04 00:46:49 +00:00
|
|
|
@todo Set range??
|
|
|
|
|
|
|
|
@ingroup LLADD_CORE
|
2004-06-25 18:59:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2004-06-28 22:48:02 +00:00
|
|
|
Read the blob from the recordid rid into buf.
|
2004-06-25 18:59:24 +00:00
|
|
|
*/
|
2004-07-26 20:37:04 +00:00
|
|
|
void readBlob(int xid, Page * p, recordid rid, void * buf);
|
2004-06-28 21:10:10 +00:00
|
|
|
|
2004-06-25 18:59:24 +00:00
|
|
|
|
|
|
|
/**
|
2004-06-28 22:48:02 +00:00
|
|
|
Write the contents of buf to the blob in recordid rid.
|
2004-06-25 18:59:24 +00:00
|
|
|
*/
|
2004-07-26 20:37:04 +00:00
|
|
|
void writeBlob(int xid, Page * p, lsn_t lsn, recordid rid, const void * buf);
|
2004-06-28 21:10:10 +00:00
|
|
|
|
2004-06-25 18:59:24 +00:00
|
|
|
|
|
|
|
/**
|
2004-06-28 22:48:02 +00:00
|
|
|
Atomicly (with respect to recovery) make the dirty version of the
|
2004-06-25 18:59:24 +00:00
|
|
|
blob the primary copy and mark it not-dirty.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void commitBlobs(int xid);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Revert the blob to the last clean version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void abortBlobs(int xid);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned offset;
|
|
|
|
unsigned long size;
|
|
|
|
unsigned fd : 1;
|
|
|
|
} blob_record_t;
|
|
|
|
|
2004-06-30 01:09:57 +00:00
|
|
|
|
2004-07-06 01:22:18 +00:00
|
|
|
recordid preAllocBlob(int xid, long blobsize);
|
2005-01-28 03:32:17 +00:00
|
|
|
recordid preAllocBlobFromPage(int xid, long page, long blobsize);
|
2004-06-30 01:09:57 +00:00
|
|
|
|
2004-06-28 22:48:02 +00:00
|
|
|
/**
|
|
|
|
Allocate a blob of size blobSize.
|
|
|
|
|
|
|
|
@todo This function does not atomically allocate space in the blob
|
2004-07-04 00:46:49 +00:00
|
|
|
file. Instead of trusting the blob store length, upon recieving a
|
|
|
|
log entry, update a static file length variable in blobManager.
|
|
|
|
|
2004-06-28 22:48:02 +00:00
|
|
|
*/
|
2004-06-30 01:09:57 +00:00
|
|
|
|
2004-07-26 20:37:04 +00:00
|
|
|
void allocBlob(int xid, Page * p, lsn_t lsn, recordid rid);
|
2004-06-25 18:59:24 +00:00
|
|
|
void openBlobStore();
|
|
|
|
void closeBlobStore();
|
|
|
|
|
|
|
|
END_C_DECLS
|
|
|
|
|
|
|
|
#endif
|