Skip to content

Commit

Permalink
Agis speed improvement (#3527)
Browse files Browse the repository at this point in the history
* don't add already existing layers

* speed up check for existing datasets

* only search for existing Tables if Feature Class wasn't already deleted

* don't subscribe to unnecessary MapMember events
  • Loading branch information
KatKatKateryna authored Jun 20, 2024
1 parent cc81dc2 commit a184d0c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,34 @@ private void GetIdsForStandaloneTablesAddedEvent(StandaloneTableEventArgs args)

private void GetIdsForMapMemberPropertiesChangedEvent(MapMemberPropertiesChangedEventArgs args)
{
foreach (MapMember member in args.MapMembers)
// don't subscribe to all events (e.g. expanding group, changing visibility etc.)
bool validEvent = false;
foreach (var hint in args.EventHints)
{
ChangedObjectIds.Add(member.URI);
if (
hint == MapMemberEventHint.DataSource
|| hint == MapMemberEventHint.DefinitionQuery
|| hint == MapMemberEventHint.LabelClasses
|| hint == MapMemberEventHint.LabelVisibility
|| hint == MapMemberEventHint.Name
|| hint == MapMemberEventHint.Renderer
|| hint == MapMemberEventHint.SceneLayerType
|| hint == MapMemberEventHint.URL
)
{
validEvent = true;
break;
}
}

if (validEvent)
{
foreach (MapMember member in args.MapMembers)
{
ChangedObjectIds.Add(member.URI);
}
RunExpirationChecks(false);
}
RunExpirationChecks(false);
}

public List<ISendFilter> GetSendFilters() => _sendFilters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ CancellationToken cancellationToken
// add layer URI to bakedIds
bakedObjectIds.Add(trackerItem.MappedLayerURI == null ? "" : trackerItem.MappedLayerURI);

// mark dataset as already created
bakedMapMembers[trackerItem.DatasetId] = mapMember;

// add report item
AddResultsFromTracker(trackerItem, results);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,28 @@ private void CreateDatasetInDatabase(string featureClassName, List<ACG.Geometry>
List<FieldDescription> fields = new(); // _fieldsUtils.GetFieldsFromSpeckleLayer(target);

// delete FeatureClass if already exists
foreach (FeatureClassDefinition fClassDefinition in geodatabase.GetDefinitions<FeatureClassDefinition>())
try
{
FeatureClassDefinition fClassDefinition = geodatabase.GetDefinition<FeatureClassDefinition>(featureClassName);
FeatureClassDescription existingDescription = new(fClassDefinition);
schemaBuilder.Delete(existingDescription);
schemaBuilder.Build();
}
catch (Exception ex) when (!ex.IsFatal()) //(GeodatabaseTableException)
{
// will cause GeodatabaseCatalogDatasetException if doesn't exist in the database
if (fClassDefinition.GetName() == featureClassName)
// "The table was not found."
// delete Table if already exists
try
{
FeatureClassDescription existingDescription = new(fClassDefinition);
TableDefinition fClassDefinition = geodatabase.GetDefinition<TableDefinition>(featureClassName);
TableDescription existingDescription = new(fClassDefinition);
schemaBuilder.Delete(existingDescription);
schemaBuilder.Build();
}
catch (Exception ex2) when (!ex2.IsFatal()) //(GeodatabaseTableException)
{
// "The table was not found.", do nothing
}
}

// Create FeatureClass
Expand Down

0 comments on commit a184d0c

Please sign in to comment.