Skip to content

Commit

Permalink
Code reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
subramanian-elavathur committed Nov 5, 2021
1 parent b3a1f1f commit 6ad08a4
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 201 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "glitch-db",
"version": "0.12.1",
"version": "0.13.0",
"description": "A simple, file based key-value database",
"main": "./lib/src/index.js",
"exports": "./lib/src/index.js",
Expand Down
19 changes: 19 additions & 0 deletions src/GlitchBitemporalPartition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { UnitemporalVersion } from "./GlitchUnitemporalPartition";

interface BitemporalVersion extends UnitemporalVersion {
validFrom: number;
validTo: number;
}

interface BitemporallyVersionedData<Type> extends BitemporalVersion {
data: Type;
}

interface BitemporallyVersioned<Type> {
rangeMap: {
[validFrom: number]: number; // validFrom to version number map
};
data: {
[key: number]: BitemporallyVersionedData<Type>;
};
}
15 changes: 7 additions & 8 deletions src/GlitchDB.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import tar = require("tar");
import { DEFAULT_CACHE_SIZE } from "./constants";
import GlitchPartitionImpl, {
GlitchPartition,
GlitchUnitemporallyVersionedPartition,
} from "./GlitchPartition";
import GlitchPartitionImpl, { GlitchPartition } from "./GlitchPartition";
import GlitchUniTemporalPartitionImpl, {
GlitchUnitemporalPartition,
} from "./GlitchUnitemporalPartition";

export default class GlitchDB {
#baseDir: string;
Expand Down Expand Up @@ -69,19 +69,18 @@ export default class GlitchDB {
name: string,
indices?: string[],
cacheSize?: number
): GlitchUnitemporallyVersionedPartition<Type> {
): GlitchUnitemporalPartition<Type> {
const cacheSizeWithDefault = cacheSize ?? this.#defaultCacheSize;
this.#partitions[name] = {
name,
cache: cacheSizeWithDefault,
versioned: true,
};
return new GlitchPartitionImpl<Type>(
return new GlitchUniTemporalPartitionImpl<Type>(
this,
`${this.#baseDir}/${name}`,
cacheSizeWithDefault,
indices,
true
indices
);
}
}
Loading

0 comments on commit 6ad08a4

Please sign in to comment.