Hello all,
I am trying to update a single attribute on 100 different features of at most 4 different layers, with the same value. In my case I have 100 features that need a "comments" field updated.
I used the Inspector class to modify multiple features, since it seems to be the preferred method on the ProSnippets documentation. However I noticed something odd when it took nearly 20 seconds to complete. I ran Fiddler to look at all the network calls to ArcGIS Server that were made during the process and saw that "applyEdits" was called once for each feature that I loaded into the inspector (see below screenshot, under code snippet), this resulted in 100 applyEdits calls and 100 queryFeature calls, 200 in total. I was expecting at most 1 call per layer.
I recorded some timings based on larger feature counts for my EditOperation to finish the "ExecuteAsync" method.
Is there a way for me to configure Inspector to only make at most 1 call per updated layer? Or is there a better method through the SDK?
| Feature Count | Duration (in seconds) |
|---|
104 | 20 |
210 | 54 |
306 | 70 |
500 | 109 |
650 | 113 |
1100 | 247 |
1200 | 276 |
<SPAN class="keyword token">public</SPAN> <SPAN class="keyword token">static</SPAN> <SPAN class="keyword token">async</SPAN> <SPAN class="keyword token">void</SPAN> <SPAN class="token function">ApplyUpdateUsingInspector</SPAN><SPAN class="punctuation token">(</SPAN>IDictionary<SPAN class="operator token"><</SPAN>Layer<SPAN class="punctuation token">,</SPAN> List<SPAN class="operator token"><</SPAN>FeatureObject<SPAN class="operator token">></SPAN><SPAN class="operator token">></SPAN> layerAttributes<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">object</SPAN> <SPAN class="keyword token">value</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">string</SPAN> fieldName<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">await</SPAN> QueuedTask<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Run</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">async</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">=</SPAN><SPAN class="operator token">></SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> editOperation <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">EditOperation</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
editOperation<SPAN class="punctuation token">.</SPAN>Name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Changing attribute..."</SPAN><SPAN class="punctuation token">;</SPAN>
editOperation<SPAN class="punctuation token">.</SPAN>ProgressMessage <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Working..."</SPAN><SPAN class="punctuation token">;</SPAN>
editOperation<SPAN class="punctuation token">.</SPAN>ShowProgressor <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">true</SPAN><SPAN class="punctuation token">;</SPAN>
editOperation<SPAN class="punctuation token">.</SPAN>CancelMessage <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Operation canceled"</SPAN><SPAN class="punctuation token">;</SPAN>
editOperation<SPAN class="punctuation token">.</SPAN>ErrorMessage <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Error updating attributes"</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">foreach</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">var</SPAN> layer <SPAN class="keyword token">in</SPAN> layerAttributes<SPAN class="punctuation token">.</SPAN>Keys<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> features <SPAN class="operator token">=</SPAN> layerAttributes<SPAN class="punctuation token">[</SPAN>layer<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> objectIds <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">from</SPAN> feature <SPAN class="keyword token">in</SPAN> features
<SPAN class="keyword token">from</SPAN> attribute <SPAN class="keyword token">in</SPAN> feature<SPAN class="punctuation token">.</SPAN>Attributes
<SPAN class="keyword token">where</SPAN> attribute<SPAN class="punctuation token">.</SPAN>Key <SPAN class="operator token">==</SPAN> <SPAN class="string token">"ObjectID"</SPAN>
<SPAN class="keyword token">select</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">long</SPAN><SPAN class="punctuation token">)</SPAN>attribute<SPAN class="punctuation token">.</SPAN>Value<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> inspector <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">Inspector</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
inspector<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Load</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">,</SPAN> objectIds<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ToArray</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
inspector<SPAN class="punctuation token">[</SPAN>fieldName<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">value</SPAN><SPAN class="punctuation token">;</SPAN>
editOperation<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Modify</SPAN><SPAN class="punctuation token">(</SPAN>inspector<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>editOperation<SPAN class="punctuation token">.</SPAN>IsEmpty<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
editOperation<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Abort</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">else</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">await</SPAN> editOperation<SPAN class="punctuation token">.</SPAN><SPAN class="token function">ExecuteAsync</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>