arcengine 查询 Recyle参数测试

本文探讨了Recycling参数在GIS查询中的作用,特别是在只读访问场景下。通过对比实验表明,设置Recycling为True能显著提升查询速度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

助中有如此论述,指出recycling参数的主要性:

TheRecyclingparameter controls feature object allocation behavior. Recycling cursors rehydrate a single feature object on each fetch and can be used to optimize read-only access, for example, when drawing. It is illegal to maintain a reference on a feature object returned by a recycling cursor across multiple calls to NextFeature on the cursor. Feature objects returned by a recycling cursor should not be modified.

Non-recycling cursors return a separate feature object on each fetch. The objects returned by a non-recycling cursor may be modified and stored with polymorphic behavior. The geodatabase guarantees 'unique instance semantics' on non-recycling feature objects fetched during an edit session.

Recycling cursors should be used only for drawing and read-only access to object state. Use non-recycling search cursors to fetch objects that are to be updated.

通过下面的函数可以测试该参数的重要性:

Const N = 100000

Sub TestRecycle()
Dim amap As IMxDocument
Set amap = ThisDocument

  Dim lyr As IFeatureLayer
  Set lyr = amap.FocusMap.Layer(0)
  Dim fc As IFeatureCursor
 
  Dim qr As IQueryFilter
  Set qr = New QueryFilter
  qr.WhereClause = "objectID < " & N
  Dim dt As Date
 
  Debug.Print "Recyle: False"
  dt = Now
  Set fc = lyr.Search(qr, False)
  While Not fc.NextFeature Is Nothing
 
  Wend
Debug.Print "Seconds: " & DateDiff("s", dt, Now)
 
  dt = Now
  Debug.Print "Recyle: True"
  Set fc = lyr.Search(qr, True)
  While Not fc.NextFeature Is Nothing
 
  Wend
Debug.Print "Seconds: " & DateDiff("s", dt, Now)
 
End Sub

结果如下:

N=100000

Recyle: False
Seconds: 3
Recyle: True
Seconds: 1

N=500000

Recyle: False
Seconds: 12
Recyle: True
Seconds: 8

说明在只读查询中,将Recycling参数设为true可以提高函数效率。

来自:http://www.gisall.com/?uid-5999-action-viewspace-itemid-74

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值