posts - 40,  comments - 18,  trackbacks - 0

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

The Recycling parameter 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可以提高函数效率。

posted on 2008-05-07 09:06 王者之魂 阅读(101) 评论(1)  编辑 收藏

FeedBack:
2008-05-26 20:13 | 3echo      

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2008-07-18 12:55 编辑过
 
另存  打印
 

众 万
志 众
成 一
城 心

诚 心
祝 愿
中 震
国 区
人 百
民 姓
幸 安
福 康

QQ:13945133
MSN:yangguanjunmeteor@hotmail.com


<2008年5月>
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

与我联系

常用链接

留言簿(1)

我参与的团队

我的标签

随笔档案(40)

友情链接

搜索

  •  

最新评论

阅读排行榜

评论排行榜

60天内阅读排行