File DBFileImpl.Mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited by:
MBrown on February 22, 1983 11:59 am
Willie-sue, April 25, 1985 12:47:16 pm PST
Cattell, September 14, 1983 12:17 pm
Wert, July 26, 1984 4:37:08 pm PDT
Widom, August 15, 1985 10:37:37 am PDT
Donahue, November 13, 1985 11:25:04 am PST
DIRECTORY
AlpineEnvironment,
AlpTransaction USING [Handle],
DBCommon,
DBFile,
DBFileAlpine,
Rope;
DBFileImpl: CEDAR PROGRAM
IMPORTS
DBFileAlpine, Rope
EXPORTS
DBFile
= BEGIN
ROPE: TYPE = Rope.ROPE;
OpenFileHandle: TYPE = DBCommon.OpenFileHandle;
AlpTrans: TYPE = AlpTransaction.Handle;
SegmentIndex: TYPE = DBCommon.SegmentIndex;
VersionOptions: TYPE = DBCommon.VersionOptions;
DBPage: TYPE = DBCommon.DBPage;
NullDBPage: DBPage = DBCommon.NullDBPage;
PagesFromBytes: PUBLIC PROC [bytes: INT]
RETURNS [pages: CARDINAL] = {
IF bytes < 0 OR bytes > LONG[CARDINAL.LAST - 1]*DBCommon.BytesPerPage THEN
ERROR;
RETURN [(bytes+DBCommon.BytesPerPage-1)/DBCommon.BytesPerPage];
};
BytesFromPages: PUBLIC PROC [pages: CARDINAL]
RETURNS [bytes: INT] = {
RETURN [pages*DBCommon.BytesPerPage];
};
CreateTransaction: PUBLIC PROC [server: ROPE] RETURNS [t: AlpTrans] = {
RETURN [NARROW[DBFileAlpine.CreateTransaction[server], AlpTrans]] };
FinishTransaction: PUBLIC PROC [t: AlpTrans, abort: BOOL, continue: BOOL] = {
DBFileAlpine.FinishTransaction[t, abort, continue];
};
OpenFile: PUBLIC PROC [t: AlpTrans, file: ROPE, version: VersionOptions,
discardFileContents: BOOL, nPagesInitial: INT, lock: AlpineEnvironment.LockOption, readOnly: BOOL]
RETURNS [f: OpenFileHandle, createdFile: BOOL] = {
flatFile: Rope.Text = Rope.Flatten[file];
[f, createdFile] ← DBFileAlpine.OpenFile[t, flatFile, version, discardFileContents, nPagesInitial, lock, readOnly];
};
Close: PUBLIC PROC [f: OpenFileHandle] ~ { DBFileAlpine.Close[f] };
ReadFilePage: PUBLIC PROC [
f: OpenFileHandle, p: CARDINAL, corePage: LONG POINTER] = {
DBFileAlpine.ReadFilePage[NARROW[f], p, corePage];
};
WriteFilePage: PUBLIC PROC [
f: OpenFileHandle, p: CARDINAL, corePage: LONG POINTER] = {
DBFileAlpine.WriteFilePage[NARROW[f], p, corePage];
};
GetSize: PUBLIC PROC [f: OpenFileHandle] RETURNS [nPages: CARDINAL] = {
RETURN[DBFileAlpine.GetSize[NARROW[f]]];
};
SetSize: PUBLIC PROC [f: OpenFileHandle, nPages: CARDINAL] = {
DBFileAlpine.SetSize[NARROW[f], nPages];
};
END.