欢迎您来到GIS动力

加入收藏 免费注册 用户登陆 帮助中心
首页 新闻动态 技术专栏 银杏树下 学习考研 软件下载 求职招聘 许愿瓶 节日祝福 用户中心 精彩推荐 资源搜索 地图
专栏导航: AO开发 | SO开发 | ArcGIS桌面 | 超图桌面 | 开发语言 | 数据库 | WebGIS | 银杏文学 | 研究生考题 | FreeMap FreeTalk
   您现在位于: 首页技术专栏ArcGIS应用与开发AO开发 → 正文
IFeatureLayer Search函数参数测试
08-05-26 08:33:00 作者:王者之魂 出处:wall.cnblogs.com

帮助中有如此论述,指出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

9 7 3 1 2 4 8 :

(本文已被浏览 次)
发布人:admin
推荐给好友:发送给好友
上篇新闻:
下篇新闻:
相关评论
发表我的评论
  • 尊重网上道德,遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他各项有关法律法;
  • 本站有权保留或删除您发表的任何评论内容;
  •   相关文章  
    IFeatureLayer Search函数参数测试

    关于我们友情链接 ┋ 与我在线 ┋ 管理 ┋ TOP
     
    网站当前版本:GisPower CMS V3.0
    『GIS 动力』- http://www.gispower.org/
    联系我们:webmaster#gispower.org
    Copyright (c) 2003-2007 GisPOwer.Org. All Rights Reserved.
     

                   滇ICP备05006901号