private void RestoreFromProfile(TransformProfile profile) { if (profile == null) { throw new InvalidOperationException(); } CapsuleColliderProfile maybeCapsule = profile as CapsuleColliderProfile; if (maybeCapsule != null) { CapsuleCollider c = capsulePool.TakeComponent(); maybeCapsule.RestoreSelfToCollider(c); return; } BoxColliderProfile maybeBox = profile as BoxColliderProfile; if (maybeBox != null) { BoxCollider c = boxPool.TakeComponent(); maybeBox.RestoreSelfToCollider(c); return; } SphereColliderProfile maybeSphere = profile as SphereColliderProfile; if (profile != null) { SphereCollider c = spherePool.TakeComponent(); maybeSphere.RestoreSelfToCollider(c); return; } throw new InvalidOperationException("howdafuq do we have an invalid collider profile? got: " + profile.GetType().ToString() + " maybeCapsule: " + maybeCapsule + " maybeBox: " + maybeBox); }
internal void TakeSnapshot() { //hacked together queue int snapIdx = ++currentSnapshot % snapMemoryCount; LinkedList <TransformProfile> profiles = new LinkedList <TransformProfile>(); savedGameObjectStates[snapIdx].Clear(); //snapshot all the network transforms LinkedListNode <NetworkTransform> node = objectsToWatch.First; while (node != null) { LinkedListNode <NetworkTransform> next = node.Next; NetworkTransform transform = node.Value; //clear out any "destroyed" nodes if (transform == null) { objectsToWatch.Remove(node); } else { //snapshot the transform savedGameObjectStates [snapIdx] [transform.gameObjectId] = new TransformProfile(transform.gameObject); //iterate through every collider foreach (Collider collider in transform.watchedColliders) { profiles.AddFirst(TransformProfile.ProfileFromCollider(collider)); } } node = next; } //clear linkedlist in O(1) time while s******g on the garbage collector savedColliderStates[snapIdx] = profiles; if (currentSnapshot == 0) { //figure out what 0 time is zeroTickTime = Utils.Timestamp; } }
public async Task ProfileTest() { var Table = CreateProfileTestData(); var profiles = new List <TransformFunction> { GetProfileReference(true, "BestDataType", "StringColumn"), GetProfileReference(true, "BestDataType", "IntColumn"), GetProfileReference(true, "BestDataType", "DecimalColumn"), GetProfileReference(true, "BestDataType", "DateColumn"), GetProfileReference(true, "Nulls", "NullsBlanksColumn"), GetProfileReference(true, "Blanks", "NullsBlanksColumn"), GetProfileReference(true, "Zeros", "ZerosColumn"), GetProfileReference(true, "MaxLength", "MaxLengthColumn"), GetProfileReference(true, "MaxValue", "MaxValueColumn"), GetProfileReference(true, "DistinctValues", "DistinctValuesColumn"), GetProfileReference(true, "Patterns", "PatternsColumn") }; var transformProfile = new TransformProfile(Table, profiles); //read all records in the tranform profile var count = 0; while (await transformProfile.ReadAsync()) { count++; } Assert.Equal(10, count); //confirm profile hasn't impacted the read. var profileResults = transformProfile.GetProfileResults(); count = 0; var detailCount = 0; while (await profileResults.ReadAsync()) { if ((bool)profileResults["IsSummary"] == true) { switch ((string)profileResults["ColumnName"]) { case "StringColumn": Assert.Equal("String", (string)profileResults["Value"]); break; case "IntColumn": Assert.Equal("Integer", (string)profileResults["Value"]); break; case "DecimalColumn": Assert.Equal("Double", (string)profileResults["Value"]); break; case "DateColumn": Assert.Equal("DateTime", (string)profileResults["Value"]); break; case "NullsBlanksColumn": var value = decimal.Parse(((string)profileResults["Value"]).TrimEnd(new char[] { '%', ' ' })) / 100M; if ((string)profileResults["Profile"] == "Nulls") { Assert.Equal(0.2M, value); } else { Assert.Equal(0.4M, value); } break; case "MaxLengthColumn": Assert.Equal("5", (string)profileResults["Value"]); break; case "MaxValueColumn": Assert.Equal("4.1", (string)profileResults["Value"]); break; case "DistinctValuesColumn": Assert.Equal("3", (string)profileResults["Value"]); break; case "PatternsColumn": // assert failed due to different percentage formatting, so simplified test added. // Assert.Equal("Pattern Count=3, Most common(50.00%): 99999", ((string)profileResults["Value"]).Replace(" %", "%")); Assert.Equal("Pattern Count=3", ((string)profileResults["Value"]).Substring(0, 15)); break; } count++; } else { detailCount++; } } Assert.Equal(11, count); Assert.Equal(25, detailCount); }
public InterpolateStep(TransformProfile prof, long ts) { profile = prof; timestamp = ts; }
public (Transform sourceTransform, Table sourceTable) CreateRunPlan(DexihHub hub, DexihDatalink hubDatalink, InputColumn[] inputColumns, long?maxDatalinkTransformKey, object maxIncrementalValue, TransformWriterOptions transformWriterOptions) //Last datatransform key is used to preview the output of a specific transform in the series. { try { _logger?.LogTrace($"CreateRunPlan {hubDatalink.Name} started."); var timer = Stopwatch.StartNew(); if (transformWriterOptions == null) { transformWriterOptions = new TransformWriterOptions(); } var primaryTransformResult = GetSourceTransform(hub, hubDatalink.SourceDatalinkTable, inputColumns, transformWriterOptions); var primaryTransform = primaryTransformResult.sourceTransform; var sourceTable = primaryTransformResult.sourceTable; var updateStrategy = hubDatalink.UpdateStrategy; //add a filter for the incremental column (if there is one) TableColumn incrementalCol = null; if (updateStrategy == EUpdateStrategy.AppendUpdateDeletePreserve || updateStrategy == EUpdateStrategy.AppendUpdatePreserve) { incrementalCol = primaryTransform.CacheTable?.GetColumn(EDeltaType.ValidFromDate); } else { incrementalCol = primaryTransform.CacheTable?.Columns.SingleOrDefault(c => c.IsIncrementalUpdate); } if (transformWriterOptions.ResetIncremental) { maxIncrementalValue = transformWriterOptions.ResetIncrementalValue; } if (maxDatalinkTransformKey == null && transformWriterOptions.IsEmptyTarget() == false && !(updateStrategy == EUpdateStrategy.Reload || updateStrategy == EUpdateStrategy.AppendUpdateDelete || updateStrategy == EUpdateStrategy.AppendUpdateDeletePreserve) && incrementalCol != null && maxIncrementalValue != null && maxIncrementalValue.ToString() != "") { var mappings = new Mappings() { new MapFilter(incrementalCol, maxIncrementalValue, ECompare.GreaterThan) }; var filterTransform = new TransformFilter(primaryTransform, mappings) { Name = $"Prefilter maxIncremental {maxIncrementalValue}" }; filterTransform.SetInTransform(primaryTransform); primaryTransform = filterTransform; } DexihTable targetTable = null; var target = hubDatalink.DexihDatalinkTargets.FirstOrDefault(c => c.NodeDatalinkColumnKey == null); if (target != null) { targetTable = hub.GetTableFromKey(target.TableKey); } _logger?.LogTrace($"CreateRunPlan {hubDatalink.Name}. Added incremental filter. Elapsed: {timer.Elapsed}"); //loop through the transforms to create the chain. foreach (var datalinkTransform in hubDatalink.DexihDatalinkTransforms.OrderBy(c => c.Position).Where(c => c.IsValid)) { //if this is an empty transform, then ignore it. if (datalinkTransform.DexihDatalinkTransformItems.Count == 0) { if (datalinkTransform.TransformType == ETransformType.Filter || datalinkTransform.TransformType == ETransformType.Mapping && datalinkTransform.PassThroughColumns) { if (datalinkTransform.Key == maxDatalinkTransformKey) { break; } continue; } } //if contains a join table, then add it in. Transform referenceTransform = null; if (datalinkTransform.JoinDatalinkTable != null) { var joinTransformResult = GetSourceTransform(hub, datalinkTransform.JoinDatalinkTable, null, transformWriterOptions); referenceTransform = joinTransformResult.sourceTransform; } var transform = datalinkTransform.GetTransform(hub, hubDatalink, transformWriterOptions.GlobalSettings, _transformSettings, primaryTransform, referenceTransform, targetTable, _logger); _logger?.LogTrace($"CreateRunPlan {hubDatalink.Name}, adding transform {datalinkTransform.Name}. Elapsed: {timer.Elapsed}"); primaryTransform = transform; if (datalinkTransform.Key == maxDatalinkTransformKey) { break; } } //if the maxDatalinkTransformKey is null (i.e. we are not doing a preview), and there are profiles add a profile transform. if (maxDatalinkTransformKey == null && hubDatalink.DexihDatalinkProfiles != null && hubDatalink.DexihDatalinkProfiles.Count > 0 && targetTable != null) { var profileRules = new Mappings(); foreach (var profile in hubDatalink.DexihDatalinkProfiles) { foreach (var column in targetTable.DexihTableColumns.Where(c => c.IsSourceColumn)) { var profileFunction = GetProfileFunction(profile.FunctionAssemblyName, profile.FunctionClassName, profile.FunctionMethodName, column.Name, profile.DetailedResults, transformWriterOptions.GlobalSettings); profileRules.Add(profileFunction); } } var transform = new TransformProfile(primaryTransform, profileRules) { Name = "User defined profiles" }; primaryTransform = transform; _logger?.LogTrace($"CreateRunPlan {hubDatalink.Name}, adding profiling. Elapsed: {timer.Elapsed}"); } if (transformWriterOptions.SelectQuery != null) { var transform = new TransformQuery(primaryTransform, transformWriterOptions.SelectQuery) { Name = "Select Query Filter" }; primaryTransform = transform; } _logger?.LogTrace($"CreateRunPlan {hubDatalink.Name}, completed. Elapsed: {timer.Elapsed}"); return(primaryTransform, sourceTable); } catch (Exception ex) { throw new TransformManagerException($"Create run plan failed. {ex.Message}", ex); } }
private void LerpAllTheThings(TransformProfile from, TransformProfile to, float lerpAmt) { transform.position = Vector3.Lerp(from.position, to.position, lerpAmt); transform.rotation = Quaternion.Lerp(from.rotation, to.rotation, lerpAmt); transform.localScale = Vector3.Lerp(from.localScale, to.localScale, lerpAmt); }