@@ -18,7 +18,6 @@ import (
1818
1919// client is mostly used for testing the destination plugin.
2020type client struct {
21- schema.DefaultTransformer
2221 spec specs.Destination
2322 memoryDB map [string ][]arrow.Record
2423 tables map [string ]* arrow.Schema
@@ -87,8 +86,10 @@ func (c *client) overwrite(table *arrow.Schema, data arrow.Record) {
8786 }
8887 }
8988 if found {
89+ tmp := c.memoryDB [tableName ][i ]
9090 c .memoryDB [tableName ] = append (c .memoryDB [tableName ][:i ], c .memoryDB [tableName ][i + 1 :]... )
9191 c .memoryDB [tableName ] = append (c .memoryDB [tableName ], data )
92+ tmp .Release ()
9293 return
9394 }
9495 }
@@ -109,6 +110,11 @@ func (c *client) Migrate(_ context.Context, tables schema.Schemas) error {
109110 if changes == nil {
110111 continue
111112 }
113+ for _ , t := range c .memoryDB {
114+ for _ , row := range t {
115+ row .Release ()
116+ }
117+ }
112118 c .memoryDB [tableName ] = make ([]arrow.Record , 0 )
113119 c .tables [tableName ] = table
114120 }
@@ -198,6 +204,11 @@ func (*client) Metrics() destination.Metrics {
198204}
199205
200206func (c * client ) Close (context.Context ) error {
207+ for _ , table := range c .memoryDB {
208+ for _ , row := range table {
209+ row .Release ()
210+ }
211+ }
201212 c .memoryDB = nil
202213 return nil
203214}
@@ -219,6 +230,8 @@ func (c *client) deleteStaleTable(_ context.Context, table *arrow.Schema, source
219230 rowSyncTime := row .Column (syncColIndex ).(* array.Timestamp ).Value (0 ).ToTime (arrow .Microsecond ).UTC ()
220231 if ! rowSyncTime .Before (syncTime ) {
221232 filteredTable = append (filteredTable , c.memoryDB [tableName ][i ])
233+ } else {
234+ c.memoryDB [tableName ][i ].Release ()
222235 }
223236 }
224237 }
0 commit comments