Skip to content

Commit 3989d23

Browse files
committed
finalizers
1 parent 0e964f4 commit 3989d23

28 files changed

+1467
-2081
lines changed

api/src/DuckDBAppender.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ export class DuckDBAppender {
1414
constructor(appender: duckdb.Appender) {
1515
this.appender = appender;
1616
}
17-
public dispose() {
18-
duckdb.appender_destroy(this.appender);
19-
}
2017
public close() {
2118
duckdb.appender_close(this.appender);
2219
}

api/src/DuckDBConnection.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ export class DuckDBConnection {
1515
): Promise<DuckDBConnection> {
1616
return instance.connect();
1717
}
18-
public dispose(): Promise<void> {
19-
return duckdb.disconnect(this.connection);
20-
}
2118
public interrupt() {
2219
duckdb.interrupt(this.connection);
2320
}
@@ -38,15 +35,11 @@ export class DuckDBConnection {
3835
const { extracted_statements, statement_count } =
3936
await duckdb.extract_statements(this.connection, sql);
4037
if (statement_count === 0) {
41-
try {
42-
throw new Error(
43-
`Failed to extract statements: ${duckdb.extract_statements_error(
44-
extracted_statements
45-
)}`
46-
);
47-
} finally {
48-
duckdb.destroy_extracted(extracted_statements);
49-
}
38+
throw new Error(
39+
`Failed to extract statements: ${duckdb.extract_statements_error(
40+
extracted_statements
41+
)}`
42+
);
5043
}
5144
return new DuckDBExtractedStatements(
5245
this.connection,

api/src/DuckDBDataChunk.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ export class DuckDBDataChunk {
99
public static create(logical_types: duckdb.LogicalType[]): DuckDBDataChunk {
1010
return new DuckDBDataChunk(duckdb.create_data_chunk(logical_types));
1111
}
12-
public dispose() {
13-
duckdb.destroy_data_chunk(this.chunk);
14-
}
1512
public reset() {
1613
duckdb.data_chunk_reset(this.chunk);
1714
}

api/src/DuckDBExtractedStatements.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ export class DuckDBExtractedStatements {
1414
this.extracted_statements = extracted_statements;
1515
this.statement_count = statement_count;
1616
}
17-
public dispose() {
18-
duckdb.destroy_extracted(this.extracted_statements);
19-
}
2017
public get count(): number {
2118
return this.statement_count;
2219
}

api/src/DuckDBInstance.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,15 @@ export class DuckDBInstance {
1212
): Promise<DuckDBInstance> {
1313
if (options) {
1414
const config = duckdb.create_config();
15-
try {
16-
for (const optionName in options) {
17-
const optionValue = String(options[optionName]);
18-
duckdb.set_config(config, optionName, optionValue);
19-
}
20-
return new DuckDBInstance(await duckdb.open(path, config));
21-
} finally {
22-
duckdb.destroy_config(config);
15+
for (const optionName in options) {
16+
const optionValue = String(options[optionName]);
17+
duckdb.set_config(config, optionName, optionValue);
2318
}
19+
return new DuckDBInstance(await duckdb.open(path, config));
2420
} else {
2521
return new DuckDBInstance(await duckdb.open(path));
2622
}
2723
}
28-
public dispose(): Promise<void> {
29-
return duckdb.close(this.db);
30-
}
3124
public async connect(): Promise<DuckDBConnection> {
3225
return new DuckDBConnection(await duckdb.connect(this.db));
3326
}

api/src/DuckDBLogicalType.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export class DuckDBLogicalType {
4848
static consumeAsType(logical_type: duckdb.LogicalType): DuckDBType {
4949
const logicalType = DuckDBLogicalType.create(logical_type);
5050
const type = logicalType.asType();
51-
logicalType.dispose();
5251
return type;
5352
}
5453
static create(logical_type: duckdb.LogicalType): DuckDBLogicalType {
@@ -145,9 +144,6 @@ export class DuckDBLogicalType {
145144
duckdb.create_union_type(member_types, member_names)
146145
);
147146
}
148-
public dispose() {
149-
duckdb.destroy_logical_type(this.logical_type);
150-
}
151147
public get typeId(): DuckDBTypeId {
152148
return duckdb.get_type_id(this.logical_type) as number as DuckDBTypeId;
153149
}

api/src/DuckDBPendingResult.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ export class DuckDBPendingResult {
1313
constructor(pending_result: duckdb.PendingResult) {
1414
this.pending_result = pending_result;
1515
}
16-
public dispose() {
17-
duckdb.destroy_pending(this.pending_result);
18-
}
1916
public runTask(): DuckDBPendingResultState {
2017
const pending_state = duckdb.pending_execute_task(this.pending_result);
2118
switch (pending_state) {

api/src/DuckDBPreparedStatement.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ export class DuckDBPreparedStatement {
1616
constructor(prepared_statement: duckdb.PreparedStatement) {
1717
this.prepared_statement = prepared_statement;
1818
}
19-
public dispose() {
20-
duckdb.destroy_prepare(this.prepared_statement);
21-
}
2219
public get statementType(): StatementType {
2320
return duckdb.prepared_statement_type(this.prepared_statement);
2421
}

api/src/DuckDBResult.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ export class DuckDBResult {
1010
constructor(result: duckdb.Result) {
1111
this.result = result;
1212
}
13-
public dispose() {
14-
duckdb.destroy_result(this.result);
15-
}
1613
public get returnType(): ResultReturnType {
1714
return duckdb.result_return_type(this.result);
1815
}

0 commit comments

Comments
 (0)