databonk 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/column.d.ts +31 -1
- package/dist/core/column.d.ts.map +1 -1
- package/dist/core/dataframe.d.ts +40 -0
- package/dist/core/dataframe.d.ts.map +1 -1
- package/dist/core/index-cache.d.ts +44 -0
- package/dist/core/index-cache.d.ts.map +1 -0
- package/dist/index.esm.js +719 -119
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +719 -119
- package/dist/index.js.map +1 -1
- package/dist/operations/groupby.d.ts +8 -1
- package/dist/operations/groupby.d.ts.map +1 -1
- package/dist/operations/join.d.ts +3 -0
- package/dist/operations/join.d.ts.map +1 -1
- package/dist/utils/aggregation-engine.d.ts +84 -0
- package/dist/utils/aggregation-engine.d.ts.map +1 -0
- package/dist/utils/bitset.d.ts +18 -0
- package/dist/utils/bitset.d.ts.map +1 -1
- package/dist/utils/hash.d.ts +79 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/core/column.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DataType } from '../utils/types.js';
|
|
1
|
+
import { DataType, TypedArrayInstance } from '../utils/types.js';
|
|
2
|
+
import { BitSet } from '../utils/bitset.js';
|
|
2
3
|
export declare class Column<T = any> {
|
|
3
4
|
readonly name: string;
|
|
4
5
|
readonly dataType: DataType;
|
|
@@ -8,6 +9,24 @@ export declare class Column<T = any> {
|
|
|
8
9
|
constructor(name: string, values: T[], dataType?: DataType);
|
|
9
10
|
private createDataArray;
|
|
10
11
|
get(index: number): T | null;
|
|
12
|
+
/**
|
|
13
|
+
* Get a value without bounds checking or null handling.
|
|
14
|
+
* Use only when caller ensures valid index and handles nulls separately.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
getRaw(index: number): T;
|
|
18
|
+
/**
|
|
19
|
+
* Get direct reference to the underlying data array.
|
|
20
|
+
* Use for batch operations that need raw access.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
getDataRef(): TypedArrayInstance | any[];
|
|
24
|
+
/**
|
|
25
|
+
* Get direct reference to the null bitmap.
|
|
26
|
+
* Use for batch null checking.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
getNullBitmapRef(): BitSet;
|
|
11
30
|
isNull(index: number): boolean;
|
|
12
31
|
slice(start?: number, end?: number): Column<T>;
|
|
13
32
|
filter(predicate: (value: T | null, index: number) => boolean): Column<T>;
|
|
@@ -21,5 +40,16 @@ export declare class Column<T = any> {
|
|
|
21
40
|
values(): Iterator<T | null>;
|
|
22
41
|
toArray(): (T | null)[];
|
|
23
42
|
static from<T>(name: string, values: T[], dataType?: DataType): Column<T>;
|
|
43
|
+
/**
|
|
44
|
+
* Create a Column directly from raw data without copying.
|
|
45
|
+
* Use for optimized construction when data is already in the correct format.
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
static fromRaw<T>(name: string, data: TypedArrayInstance | any[], nullBitmap: BitSet, dataType: DataType): Column<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Select rows by indices with optimized batch copying.
|
|
51
|
+
* Much faster than calling get() for each index.
|
|
52
|
+
*/
|
|
53
|
+
selectIndices(indices: number[]): Column<T>;
|
|
24
54
|
}
|
|
25
55
|
//# sourceMappingURL=column.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column.d.ts","sourceRoot":"","sources":["../../src/core/column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"column.d.ts","sourceRoot":"","sources":["../../src/core/column.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAyC,MAAM,mBAAmB,CAAC;AACxG,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,qBAAa,MAAM,CAAC,CAAC,GAAG,GAAG;IAC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,CAAC,EAAE;IAQvB,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC;IAIzE;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,CAAC,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,kBAAkB,GAAG,GAAG,EAAE,EAChC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,QAAQ,GACjB,MAAM,CAAC,CAAC,CAAC;IAWZ;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;CAmC5C"}
|
package/dist/core/dataframe.d.ts
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
import { Column } from './column';
|
|
2
2
|
export type RowObject = Record<string, any>;
|
|
3
|
+
/**
|
|
4
|
+
* RowProxy provides zero-allocation row access for iteration.
|
|
5
|
+
* Reuses a single object while iterating, avoiding object creation per row.
|
|
6
|
+
*/
|
|
7
|
+
export declare class RowProxy {
|
|
8
|
+
private columnCache;
|
|
9
|
+
private index;
|
|
10
|
+
constructor(df: DataFrame);
|
|
11
|
+
/**
|
|
12
|
+
* Set the current row index.
|
|
13
|
+
* @returns this for chaining
|
|
14
|
+
*/
|
|
15
|
+
setIndex(i: number): this;
|
|
16
|
+
/**
|
|
17
|
+
* Get a value from the current row.
|
|
18
|
+
*/
|
|
19
|
+
get(col: string): any;
|
|
20
|
+
/**
|
|
21
|
+
* Get a value without null checking (faster for non-null columns).
|
|
22
|
+
*/
|
|
23
|
+
getRaw(col: string): any;
|
|
24
|
+
/**
|
|
25
|
+
* Check if a column value is null at the current row.
|
|
26
|
+
*/
|
|
27
|
+
isNull(col: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Get the current row index.
|
|
30
|
+
*/
|
|
31
|
+
getIndex(): number;
|
|
32
|
+
}
|
|
3
33
|
export declare class DataFrame {
|
|
4
34
|
private columns;
|
|
5
35
|
readonly length: number;
|
|
@@ -14,6 +44,16 @@ export declare class DataFrame {
|
|
|
14
44
|
filter(predicate: (row: RowObject, index: number) => boolean): DataFrame;
|
|
15
45
|
slice(start?: number, end?: number): DataFrame;
|
|
16
46
|
selectRows(indices: number[]): DataFrame;
|
|
47
|
+
/**
|
|
48
|
+
* Filter rows using a predicate function that receives a RowProxy.
|
|
49
|
+
* More efficient than filter() as it avoids creating a new object per row.
|
|
50
|
+
*/
|
|
51
|
+
filterByIndex(predicate: (index: number, proxy: RowProxy) => boolean): DataFrame;
|
|
52
|
+
/**
|
|
53
|
+
* Create a RowProxy for efficient iteration.
|
|
54
|
+
* Use this when you need to access multiple columns per row without allocation.
|
|
55
|
+
*/
|
|
56
|
+
createRowProxy(): RowProxy;
|
|
17
57
|
getRow(index: number): RowObject;
|
|
18
58
|
rows(): IterableIterator<RowObject>;
|
|
19
59
|
head(n?: number): DataFrame;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataframe.d.ts","sourceRoot":"","sources":["../../src/core/dataframe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE5C,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAkC;IACjD,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE;IAiBnD,IAAI,WAAW,IAAI,MAAM,EAAE,CAE1B;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAQ5B,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIhC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,S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AAM,EAAE,GAAG,EAAE,CAAC,GAAG,SAAS;CAS3D"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DataFrame } from './dataframe.js';
|
|
2
|
+
/**
|
|
3
|
+
* CachedIndex stores a hash index along with metadata about when it was created.
|
|
4
|
+
*/
|
|
5
|
+
export interface CachedIndex {
|
|
6
|
+
columns: string[];
|
|
7
|
+
index: Map<string, number[]>;
|
|
8
|
+
createdAt: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* IndexCache provides caching for hash indices used in join and groupBy operations.
|
|
12
|
+
* Uses WeakMap to allow garbage collection of DataFrames.
|
|
13
|
+
*/
|
|
14
|
+
export declare class IndexCache {
|
|
15
|
+
private cache;
|
|
16
|
+
private maxAge;
|
|
17
|
+
constructor(maxAge?: number);
|
|
18
|
+
/**
|
|
19
|
+
* Generate a cache key from column names.
|
|
20
|
+
*/
|
|
21
|
+
private getCacheKey;
|
|
22
|
+
/**
|
|
23
|
+
* Get a cached index for the given DataFrame and columns.
|
|
24
|
+
* Returns null if not cached or expired.
|
|
25
|
+
*/
|
|
26
|
+
getIndex(df: DataFrame, columns: string[]): Map<string, number[]> | null;
|
|
27
|
+
/**
|
|
28
|
+
* Store an index in the cache.
|
|
29
|
+
*/
|
|
30
|
+
setIndex(df: DataFrame, columns: string[], index: Map<string, number[]>): void;
|
|
31
|
+
/**
|
|
32
|
+
* Invalidate all cached indices for a DataFrame.
|
|
33
|
+
*/
|
|
34
|
+
invalidate(df: DataFrame): void;
|
|
35
|
+
/**
|
|
36
|
+
* Clear all cached indices.
|
|
37
|
+
*/
|
|
38
|
+
clear(): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Global index cache instance for shared use across operations.
|
|
42
|
+
*/
|
|
43
|
+
export declare const globalIndexCache: IndexCache;
|
|
44
|
+
//# sourceMappingURL=index-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-cache.d.ts","sourceRoot":"","sources":["../../src/core/index-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,KAAK,CAA+D;IAC5E,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,GAAE,MAAc;IAIlC;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;;OAGG;IACH,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAkBxE;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,IAAI;IAe9E;;OAEG;IACH,UAAU,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI;IAI/B;;OAEG;IACH,KAAK,IAAI,IAAI;CAId;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,YAAmB,CAAC"}
|