1
1
import { InstanceManagerType } from '../dbm/instance-manager' ;
2
+ import { DBMEvent , DBMLogger } from '../logger' ;
2
3
import { Table , TableWiseFiles } from '../types' ;
3
4
5
+ export interface FileManagerConstructorOptions {
6
+ /**
7
+ * @description
8
+ * It manages the lifecycle of the DuckDB database instance.
9
+ * It provides methods for obtaining an initialized DuckDB instance and terminating the instance.
10
+ */
11
+ instanceManager : InstanceManagerType ;
12
+
13
+ /**
14
+ * @description
15
+ * Represents an logger instance, which will be used for logging messages throughout the File Manager's execution.
16
+ */
17
+ logger ?: DBMLogger ;
18
+
19
+ /**
20
+ * @description
21
+ * A callback function that handles events emitted by the File Manager.
22
+ */
23
+ onEvent ?: ( event : DBMEvent ) => void ;
24
+
25
+ /**
26
+ * @description
27
+ * Configuration options for the File Manager.
28
+ */
29
+ options ?: {
30
+ /**
31
+ * Maximum size of the file in DB in bytes
32
+ */
33
+ maxFileSize ?: number ;
34
+ } ;
35
+
36
+ fetchTableFileBuffers : ( tableName : string ) => Promise < FileBufferStore [ ] > ;
37
+ }
38
+
4
39
export interface FileManagerType {
5
40
/**
6
41
* @description
@@ -16,6 +51,15 @@ export interface FileManagerType {
16
51
*/
17
52
registerFileBuffer : ( props : FileBufferStore ) => Promise < void > ;
18
53
54
+ /**
55
+ * @description
56
+ * Registers a single JSON file in the file manager.
57
+ * It converts a JSON object to a Uint8Array by writing it to a Parquet file in a DuckDB database and registers it.
58
+ * Also emits an event with the time taken for the conversion.
59
+ * @param props - The FileJsonStore object to register.
60
+ */
61
+ registerJSON : ( props : FileJsonStore ) => Promise < void > ;
62
+
19
63
/**
20
64
* @description
21
65
* Retrieves the file buffer associated with a given file name.
@@ -73,24 +117,18 @@ export interface FileManagerType {
73
117
onDBShutdownHandler : ( ) => Promise < void > ;
74
118
}
75
119
76
-
77
- export interface FileBufferStore {
120
+ export type BaseFileStore = {
78
121
tableName : string ;
79
122
fileName : string ;
80
- buffer : Uint8Array ;
81
123
staleTime ?: number ;
82
124
cacheTime ?: number ;
83
125
metadata ?: object ;
84
- }
126
+ } ;
85
127
86
- export interface FileManagerConstructorOptions {
87
- fetchTableFileBuffers : ( tableName : string ) => Promise < FileBufferStore [ ] > ;
88
- instanceManager : InstanceManagerType ;
89
- options ?: {
90
- /**
91
- * Maximum size of the file in DB in bytes
92
- */
93
- maxFileSize ?: number ;
94
- } ;
95
- }
128
+ export type FileBufferStore = BaseFileStore & {
129
+ buffer : Uint8Array ;
130
+ } ;
96
131
132
+ export type FileJsonStore = BaseFileStore & {
133
+ json : object ;
134
+ } ;
0 commit comments