@@ -55,7 +55,8 @@ namespace Harmony.Core.FileIO.Queryable
55
55
public readwrite property Context, @object
56
56
private DrivingBuffers, @List<QueryBuffer.TypeBuffer>
57
57
public readwrite property FailedDueToNetwork, boolean, false
58
-
58
+ public readwrite property Disposed, boolean, false
59
+ internal readwrite property MemoryHandleArena, @MemoryHandleArena, new MemoryHandleArena()
59
60
public method GetTop, long?
60
61
targetBufferIndex, int
61
62
proc
@@ -151,6 +152,7 @@ namespace Harmony.Core.FileIO.Queryable
151
152
buf, @QueryBuffer.TypeBuffer
152
153
dataObjectProvider, @IDataObjectProvider
153
154
bufferMap, @Dictionary<QueryBuffer.TypeBuffer, QueryBuffer.TypeBuffer>
155
+ handleArena, @MemoryHandleArena
154
156
proc
155
157
data madeBuffer, @QueryBuffer.TypeBuffer
156
158
if(bufferMap != ^null && bufferMap.TryGetValue(buf,madeBuffer)) then
@@ -164,15 +166,15 @@ namespace Harmony.Core.FileIO.Queryable
164
166
& ParentFieldName = buf.ParentFieldName,
165
167
& DataObjectType = buf.DataObjectType,
166
168
& JoinOn = buf.JoinOn,
167
- & JoinedBuffers = buf.JoinedBuffers.Select(lambda(jBuf) { MakeTypeBuffer(jBuf, dataObjectProvider, bufferMap) }).ToList(),
169
+ & JoinedBuffers = buf.JoinedBuffers.Select(lambda(jBuf) { MakeTypeBuffer(jBuf, dataObjectProvider, bufferMap, handleArena ) }).ToList(),
168
170
& IsInnerJoin = buf.IsInnerJoin,
169
171
& OrderBy = buf.OrderBy,
170
172
& SelectResult = buf.SelectResult,
171
173
& Top = buf.Top,
172
174
& Skip = buf.Skip
173
175
& }
174
176
175
- newTypeBuf.MemoryHandle = buf.Metadata.GetBuffer( )
177
+ newTypeBuf.MemoryHandle = handleArena.GetMemoryHandle( buf.Metadata.RPSStructureSize )
176
178
data fileInfo = dataObjectProvider.GetFileInfo(buf.DataObjectType)
177
179
;;this is read only, performance is significantly improved by using an input channel
178
180
data fileOpenMode = fileInfo.Item2
@@ -209,7 +211,7 @@ namespace Harmony.Core.FileIO.Queryable
209
211
if(buf.MemoryHandle != ^null || buf.IOChannel != ^null )
210
212
throw new InvalidOperationException("TypeBuffer should not have its MemoryHandle member set during QueryBuffer construction")
211
213
212
- TypeBuffers.Add(MakeTypeBuffer(buf, dataObjectProvider, protoBufferMap))
214
+ TypeBuffers.Add(MakeTypeBuffer(buf, dataObjectProvider, protoBufferMap, this.MemoryHandleArena ))
213
215
end
214
216
endmethod
215
217
@@ -229,6 +231,9 @@ namespace Harmony.Core.FileIO.Queryable
229
231
isFinalizer, boolean
230
232
endparams
231
233
proc
234
+ if(Disposed)
235
+ mreturn
236
+
232
237
data buf, @QueryBuffer.TypeBuffer
233
238
data allBuffers, @IEnumerable<QueryBuffer.TypeBuffer>, TypeBuffers
234
239
if(DrivingBuffers != ^null)
@@ -243,13 +248,12 @@ namespace Harmony.Core.FileIO.Queryable
243
248
data ch, int
244
249
ch = tempbuf.IOChannel
245
250
DataObjectProvider.ChannelManager.AbandonOpenChannels(ch)
251
+ tempbuf.IOChannel = ^null
246
252
end
247
253
end
248
254
249
255
foreach buf in allBuffers
250
256
begin
251
- if(buf.MemoryHandle != ^null)
252
- buf.Metadata.ReturnBuffer(buf.MemoryHandle)
253
257
buf.MemoryHandle = ^null
254
258
if(DataObjectProvider != ^null && buf.IOChannel != ^null)
255
259
begin
@@ -265,6 +269,7 @@ namespace Harmony.Core.FileIO.Queryable
265
269
TypeBuffers.Clear()
266
270
DataObjectProvider = ^null
267
271
DrivingBuffers = ^null
272
+ Disposed = true
268
273
endmethod
269
274
270
275
endclass
0 commit comments