Skip to content

Commit

Permalink
update: runner
Browse files Browse the repository at this point in the history
  • Loading branch information
vpbs2 committed Sep 4, 2024
1 parent 0927c27 commit fa76345
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ParallelMemoryDBMProvider = ({
}: {
children: JSX.Element;
}) => {
const [dbm, setdbm] = useState<DBMParallel | null>(null);
const [dbm, setdbm] = useState<DBMParallel<SharedArrayBuffer> | null>(null);
const instanceManagerRef = useRef<InstanceManager>(new InstanceManager());
const fileManagerRef = useRef<ParallelMemoryFileManager>(
new ParallelMemoryFileManager({
Expand Down
14 changes: 9 additions & 5 deletions benchmarking/src/app/hooks/dbm-context.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { DBM, DBMParallel, FileManagerType } from '@devrev/meerkat-dbm';
import React from 'react';

export const DBMContext = React.createContext<{
dbm: DBM | DBMParallel;
export type DBMContextType<T> = {
dbm: DBM | DBMParallel<T>;
fileManager: FileManagerType;
}>(null as any);
};

export const DBMContext = React.createContext<DBMContextType<any> | undefined>(
undefined
);

export const useDBM = () => {
const context = React.useContext(DBMContext);
export const useDBM = <T,>() => {
const context = React.useContext(DBMContext) as DBMContextType<T> | undefined;
if (context === undefined) {
throw new Error('useDBM must be used within a DBMProvider');
}
Expand Down
5 changes: 3 additions & 2 deletions meerkat-browser-runner/src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
FileManagerType,
getMainAppName,
getRunnerAppName,
RunnerIndexedDBFileManager,
RunnerMemoryDBFileManager,
WindowCommunication,
} from '@devrev/meerkat-dbm';

Expand Down Expand Up @@ -72,7 +72,7 @@ export function App() {
}

if (!fileManagerRef.current) {
fileManagerRef.current = new RunnerIndexedDBFileManager({
fileManagerRef.current = new RunnerMemoryDBFileManager({
instanceManager: instanceManagerRef.current,
fetchTableFileBuffers: async () => [],
logger: log,
Expand All @@ -82,6 +82,7 @@ export function App() {
payload: event,
});
},
communication: communicationRef.current,
});
}

Expand Down
2 changes: 1 addition & 1 deletion meerkat-dbm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devrev/meerkat-dbm",
"version": "0.1.1",
"version": "0.1.2",
"dependencies": {
"tslib": "^2.3.0",
"@devrev/duckdb-wasm": "1.14.3",
Expand Down
6 changes: 3 additions & 3 deletions meerkat-dbm/src/dbm/dbm-parallel/dbm-parallel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const roundRobin = (counter: number, maxValue: number): number => {
return counter + 1;
};

export class DBMParallel {
private fileManager: FileManagerType<SharedArrayBuffer | Uint8Array>;
export class DBMParallel<BufferType = Uint8Array> {
private fileManager: FileManagerType<BufferType>;
private logger: DBMLogger;
private tableLockRegistry: Record<string, TableLock> = {};

Expand All @@ -42,7 +42,7 @@ export class DBMParallel {
instanceManager,
onDuckDBShutdown,
iFrameRunnerManager,
}: DBMConstructorOptions<SharedArrayBuffer | Uint8Array> & {
}: DBMConstructorOptions<BufferType> & {
iFrameRunnerManager: IFrameRunnerManager;
}) {
this.fileManager = fileManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export class IndexedDBFileManager implements FileManagerType {

async mountFileBufferByTables(tables: TableConfig[]): Promise<void> {
const tableData = await this.getFilesNameForTables(tables);
console.log('tableData', tableData);

/**
* Check if the file registered size is not more than the limit
* If it is more than the limit, then remove the files which are not needed while mounting this the tables
Expand All @@ -245,7 +245,7 @@ export class IndexedDBFileManager implements FileManagerType {
const filesList = _filesList.filter(
(fileName) => !this.fileRegisterer.isFileRegisteredInDB(fileName)
);
console.log('filesList', filesList);

const uniqueFileNames = Array.from(new Set(filesList));

const filesData = await this.indexedDB?.files.bulkGet(uniqueFileNames);
Expand All @@ -267,12 +267,12 @@ export class IndexedDBFileManager implements FileManagerType {
async getTableData(table: TableConfig): Promise<Table | undefined> {
const tableData = await this.indexedDB.tablesKey.get(table.name);

if (!tableData) return undefined;
if (!tableData) return undefined;

return {
...tableData,
files: getFilesByPartition(tableData?.files ?? [], table.partitions),
};
return {
...tableData,
files: getFilesByPartition(tableData?.files ?? [], table.partitions),
};
}

async setTableMetadata(tableName: string, metadata: object): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ export class RunnerIndexedDBFileManager
super(options);
}

override async initializeDB(): Promise<void> {
return;
}

override async bulkRegisterFileBuffer(
fileBuffers: FileBufferStore[]
): Promise<void> {
Expand Down

0 comments on commit fa76345

Please sign in to comment.