public Blittable WriteOpsIntoMemory( SystemLevelRuleNativeData dataArray, SymbolSeriesMatcherNativeDataWriter dataWriter) { var structExpressionsSpace = new JaggedIndexing { index = dataWriter.indexInStructExpressionMemory, length = (ushort)evaluators.Length }; var totalOperations = 0; for (int i = 0; i < evaluators.Length; i++) { var opSize = evaluators[i].OperatorSpaceNeeded; dataArray.structExpressionMemorySpace[i + structExpressionsSpace.index] = evaluators[i].WriteIntoOpDataArray( dataArray.dynamicOperatorMemory, new JaggedIndexing { index = dataWriter.indexInOperatorMemory + totalOperations, length = opSize }); totalOperations += opSize; } dataWriter.indexInOperatorMemory += totalOperations; dataWriter.indexInStructExpressionMemory += structExpressionsSpace.length; return(blittable = new Blittable { structExpressionSpace = structExpressionsSpace, replacementSymbol = targetSymbol }); }
public void WriteIntoMemory( SystemLevelRuleNativeData dataArray, SymbolSeriesMatcherNativeDataWriter dataWriter) { var replacementSymbolSpace = new JaggedIndexing { index = dataWriter.indexInReplacementSymbolsMemory, length = (ushort)replacementSymbols.Length }; for (int i = 0; i < replacementSymbols.Length; i++) { var blittableReplacement = replacementSymbols[i].WriteOpsIntoMemory(dataArray, dataWriter); dataArray.replacementsSymbolMemorySpace[i + replacementSymbolSpace.index] = blittableReplacement; } dataWriter.indexInReplacementSymbolsMemory += replacementSymbolSpace.length; blittable = new Blittable { probability = probability, replacementSymbolSize = (ushort)replacementSymbols.Length, replacementParameterCount = replacementParameterCount, replacementSymbols = replacementSymbolSpace }; }
public SymbolSeriesSuffixMatcher BuildIntoManagedMemory( SystemLevelRuleNativeData nativeData, SymbolSeriesMatcherNativeDataWriter dataWriter, Allocator allocator = Allocator.Persistent) { var matcher = new SymbolSeriesSuffixMatcher(); matcher.graphNodeMemSpace = new JaggedIndexing { index = dataWriter.indexInSuffixNodes, length = (ushort)RequiredGraphNodeMemSpace }; dataWriter.indexInSuffixNodes += RequiredGraphNodeMemSpace; for (int i = 0; i < nodes.Count; i++) { var sourceNode = nodes[i]; nativeData.suffixMatcherGraphNodeData[i + matcher.graphNodeMemSpace.index] = new SymbolMatcherGraphNode { parentIndex = sourceNode.parentIndex, myIndexInParentChildren = sourceNode.myIndexInParentChildren, mySymbol = targetSymbolSeries[i].AsBlittable() }; } matcher.childrenOfRoot = new JaggedIndexing { index = dataWriter.indexInSuffixChildren, length = (ushort)rootChildren.Count }; var childrenAsArray = nodes.Select(x => x.childrenIndexes.ToArray()).ToArray(); var tmpIndexInChildren = 0; foreach (var rootChild in rootChildren) { nativeData.suffixMatcherChildrenDataArray[tmpIndexInChildren + dataWriter.indexInSuffixChildren] = rootChild; tmpIndexInChildren++; } JaggedNativeArray <int> .WriteJaggedIndexing( (indexInJagged, jaggedIndexing) => { var node = nativeData.suffixMatcherGraphNodeData[indexInJagged + matcher.graphNodeMemSpace.index]; node.childrenIndexing = jaggedIndexing; nativeData.suffixMatcherGraphNodeData[indexInJagged + matcher.graphNodeMemSpace.index] = node; }, childrenAsArray, nativeData.suffixMatcherChildrenDataArray, dataWriter.indexInSuffixChildren + tmpIndexInChildren ); dataWriter.indexInSuffixChildren += RequiredChildrenMemSpace; matcher.HasGraphIndexes = true; matcher.IsCreated = true; return(matcher); }
public DepthFirstSearchState( SymbolSeriesSuffixMatcher source, int currentIndex, SystemLevelRuleNativeData nativeDataPointer) { this.source = source; this.currentIndex = currentIndex; nativeData = nativeDataPointer; }
public IEnumerable <int> GetDepthFirstEnumerator(SystemLevelRuleNativeData nativeData) { var currentState = GetImmutableDepthFirstIterationState(nativeData); while (currentState.Next(out var nextState)) { yield return(nextState.currentIndex); currentState = nextState; } }
private JaggedIndexing ChildrenForNode(int nodeIndex, SystemLevelRuleNativeData nativeData) { if (nodeIndex >= 0) { var node = nativeData.suffixMatcherGraphNodeData[nodeIndex + graphNodeMemSpace.index]; return(node.childrenIndexing); } else if (nodeIndex == -1) { return(childrenOfRoot); } throw new Exception("invalid node index: " + nodeIndex); }
public SymbolStringBranchingCache( int open, int close, ISet <int>[] includedSymbolsByRuleSetIndex, SystemLevelRuleNativeData nativeRuleData, Allocator allocator = Allocator.Persistent) { branchOpenSymbol = open; branchCloseSymbol = close; includeSymbols = new NativeMultipleHashSets(includedSymbolsByRuleSetIndex, allocator); this.nativeRuleData = nativeRuleData; branchingJumpIndexes = default; }
public SymbolSeriesPrefixMatcher BuildIntoManagedMemory( SystemLevelRuleNativeData nativeData, SymbolSeriesMatcherNativeDataWriter dataWriter) { var matcher = new SymbolSeriesPrefixMatcher(); matcher.graphNodeMemSpace = new JaggedIndexing { index = dataWriter.indexInPrefixNodes, length = (ushort)RequiredNodeMemorySpace }; dataWriter.indexInPrefixNodes += RequiredNodeMemorySpace; for (int i = 0; i < targetSymbolSeries.Length; i++) { var symbol = targetSymbolSeries[i].AsBlittable(); nativeData.prefixMatcherSymbols[i + matcher.graphNodeMemSpace.index] = symbol; } matcher.IsValid = targetSymbolSeries.Length > 0; return(matcher); }
public void WriteDataIntoMemory( SystemLevelRuleNativeData dataArray, SymbolSeriesMatcherNativeDataWriter dataWriter) { ContextSuffix = forwardsMatchBuilder.BuildIntoManagedMemory(dataArray, dataWriter); ContextPrefix = backwardsMatchBuilder.BuildIntoManagedMemory(dataArray, dataWriter); foreach (var outcome in possibleOutcomes) { outcome.WriteIntoMemory(dataArray, dataWriter); } possibleOutcomeIndexing = new JaggedIndexing { index = dataWriter.indexInRuleOutcomes, length = (ushort)possibleOutcomes.Length }; for (int i = 0; i < possibleOutcomeIndexing.length; i++) { var possibleOutcome = possibleOutcomes[i]; dataArray.ruleOutcomeMemorySpace[i + dataWriter.indexInRuleOutcomes] = possibleOutcome.AsBlittable(); } dataWriter.indexInRuleOutcomes += possibleOutcomeIndexing.length; if (conditionalChecker != null) { var opSize = conditionalChecker.OperatorSpaceNeeded; conditionalCheckerBlittable = conditionalChecker.WriteIntoOpDataArray( dataArray.dynamicOperatorMemory, new JaggedIndexing { index = dataWriter.indexInOperatorMemory, length = opSize }); dataWriter.indexInOperatorMemory += opSize; } }
public DepthFirstSearchState GetImmutableDepthFirstIterationState(SystemLevelRuleNativeData nativeData) { return(new DepthFirstSearchState(this, -1, nativeData)); }
public SymbolStringBranchingCache(int branchOpen, int branchClose, SystemLevelRuleNativeData nativeRuleData) : this(branchOpen, branchClose, new HashSet <int> [0], nativeRuleData) { }