📄 incrrset.c
字号:
EPMDrive(theEnv,notParent,joinPtr); } else { for (listOfHashNodes = ((struct patternNodeHeader *) joinPtr->rightSideEntryStructure)->firstHash; listOfHashNodes != NULL; listOfHashNodes = listOfHashNodes->nextHash) { for (theList = listOfHashNodes->alphaMemory; theList != NULL; theList = theList->nextInMemory) { NetworkAssert(theEnv,theList,joinPtr); } } } return; } /*========================================*/ /* Find another beta memory from which we */ /* can retrieve the partial matches. */ /*========================================*/ tempLink = joinPtr->lastLevel->nextLinks; while (tempLink != NULL) { if ((tempLink->join != joinPtr) && (tempLink->join->initialize == FALSE)) { break; } tempLink = tempLink->next; } if (tempLink == NULL) return; if (tempLink->enterDirection == LHS) { theMemory = tempLink->join->leftMemory; } else { theMemory = tempLink->join->rightMemory; } /*============================================*/ /* Send all partial matches from the selected */ /* beta memory to the new join. */ /*============================================*/ for (b = 0; b < theMemory->size; b++) { for (theList = theMemory->beta[b]; theList != NULL; theList = theList->nextInMemory) { linker = CopyPartialMatch(theEnv,theList); if (joinPtr->leftHash != NULL) { hashValue = BetaMemoryHashValue(theEnv,joinPtr->leftHash,linker,NULL,joinPtr,NULL); } else { hashValue = 0; } UpdateBetaPMLinks(theEnv,linker,theList->leftParent,theList->rightParent,joinPtr,hashValue,LHS); NetworkAssertLeft(theEnv,linker,joinPtr); } } } /****************************************************************************//* PrimeJoinFromRightMemory: Updates a join in a rule for an incremental *//* reset. Joins are updated by "priming" them only if the join (or its *//* associated pattern) is shared with other rules that have already been *//* incrementally reset. A join for a new rule will be updated if it is *//* marked for initialization and either its parent join or its associated *//* entry pattern node has not been marked for initialization. *//****************************************************************************/static void PrimeJoinFromRightMemory( void *theEnv, struct joinNode *joinPtr) { struct partialMatch *theList, *linker; unsigned long b; struct betaMemory *theMemory; unsigned long hashValue; struct joinLink *tempLink; struct partialMatch *notParent = NULL; /*=======================================*/ /* This should be a join from the right. */ /*=======================================*/ if (joinPtr->joinFromTheRight == FALSE) { return; } /*========================================*/ /* Find another beta memory from which we */ /* can retrieve the partial matches. */ /*========================================*/ tempLink = ((struct joinNode *) joinPtr->rightSideEntryStructure)->nextLinks; while (tempLink != NULL) { if ((tempLink->join != joinPtr) && (tempLink->join->initialize == FALSE)) { break; } tempLink = tempLink->next; } if (tempLink == NULL) { if (joinPtr->firstJoin && (joinPtr->rightMemory->beta[0] == NULL) && (! joinPtr->patternIsExists)) { notParent = joinPtr->leftMemory->beta[0]; if (joinPtr->secondaryNetworkTest != NULL) { if (EvaluateSecondaryNetworkTest(theEnv,notParent,joinPtr) == FALSE) { return; } } EPMDrive(theEnv,notParent,joinPtr); } return; } if (tempLink->enterDirection == LHS) { theMemory = tempLink->join->leftMemory; } else { theMemory = tempLink->join->rightMemory; } /*============================================*/ /* Send all partial matches from the selected */ /* beta memory to the new join. */ /*============================================*/ for (b = 0; b < theMemory->size; b++) { for (theList = theMemory->beta[b]; theList != NULL; theList = theList->nextInMemory) { linker = CopyPartialMatch(theEnv,theList); if (joinPtr->rightHash != NULL) { hashValue = BetaMemoryHashValue(theEnv,joinPtr->rightHash,linker,NULL,joinPtr,NULL); } else { hashValue = 0; } UpdateBetaPMLinks(theEnv,linker,theList->leftParent,theList->rightParent,joinPtr,hashValue,RHS); NetworkAssert(theEnv,linker,joinPtr); } } if (joinPtr->firstJoin && (joinPtr->rightMemory->beta[0] == NULL) && (! joinPtr->patternIsExists)) { notParent = joinPtr->leftMemory->beta[0]; if (joinPtr->secondaryNetworkTest != NULL) { if (EvaluateSecondaryNetworkTest(theEnv,notParent,joinPtr) == FALSE) { return; } } EPMDrive(theEnv,notParent,joinPtr); } } /*********************************************************************//* MarkPatternForIncrementalReset: Given a pattern node and its type *//* (fact, instance, etc.), calls the appropriate function to mark *//* the pattern for an incremental reset. Used to mark the pattern *//* nodes both before and after an incremental reset. *//*********************************************************************/static void MarkPatternForIncrementalReset( void *theEnv, int rhsType, struct patternNodeHeader *theHeader, int value) { struct patternParser *tempParser; tempParser = GetPatternParser(theEnv,rhsType); if (tempParser != NULL) { if (tempParser->markIRPatternFunction != NULL) { (*tempParser->markIRPatternFunction)(theEnv,theHeader,value); } } }#endif/********************************************//* EnvGetIncrementalReset: C access routine *//* for the get-incremental-reset command. *//********************************************/globle intBool EnvGetIncrementalReset( void *theEnv) { return(EngineData(theEnv)->IncrementalResetFlag); }/********************************************//* EnvSetIncrementalReset: C access routine *//* for the set-incremental-reset command. *//********************************************/globle intBool EnvSetIncrementalReset( void *theEnv, int value) { int ov; struct defmodule *theModule; SaveCurrentModule(theEnv); for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule)) { EnvSetCurrentModule(theEnv,(void *) theModule); if (EnvGetNextDefrule(theEnv,NULL) != NULL) { RestoreCurrentModule(theEnv); return(-1); } } RestoreCurrentModule(theEnv); ov = EngineData(theEnv)->IncrementalResetFlag; EngineData(theEnv)->IncrementalResetFlag = value; return(ov); }/****************************************************//* SetIncrementalResetCommand: H/L access routine *//* for the set-incremental-reset command. *//****************************************************/globle int SetIncrementalResetCommand( void *theEnv) { int oldValue; DATA_OBJECT argPtr; struct defmodule *theModule; oldValue = EnvGetIncrementalReset(theEnv); /*============================================*/ /* Check for the correct number of arguments. */ /*============================================*/ if (EnvArgCountCheck(theEnv,"set-incremental-reset",EXACTLY,1) == -1) { return(oldValue); } /*=========================================*/ /* The incremental reset behavior can't be */ /* changed when rules are loaded. */ /*=========================================*/ SaveCurrentModule(theEnv); for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule)) { EnvSetCurrentModule(theEnv,(void *) theModule); if (EnvGetNextDefrule(theEnv,NULL) != NULL) { RestoreCurrentModule(theEnv); PrintErrorID(theEnv,"INCRRSET",1,FALSE); EnvPrintRouter(theEnv,WERROR,"The incremental reset behavior cannot be changed with rules loaded.\n"); SetEvaluationError(theEnv,TRUE); return(oldValue); } } RestoreCurrentModule(theEnv); /*==================================================*/ /* The symbol FALSE disables incremental reset. Any */ /* other value enables incremental reset. */ /*==================================================*/ EnvRtnUnknown(theEnv,1,&argPtr); if ((argPtr.value == EnvFalseSymbol(theEnv)) && (argPtr.type == SYMBOL)) { EnvSetIncrementalReset(theEnv,FALSE); } else { EnvSetIncrementalReset(theEnv,TRUE); } /*=======================*/ /* Return the old value. */ /*=======================*/ return(oldValue); }/****************************************************//* GetIncrementalResetCommand: H/L access routine *//* for the get-incremental-reset command. *//****************************************************/globle int GetIncrementalResetCommand( void *theEnv) { int oldValue; oldValue = EnvGetIncrementalReset(theEnv); if (EnvArgCountCheck(theEnv,"get-incremental-reset",EXACTLY,0) == -1) { return(oldValue); } return(oldValue); }#endif /* DEFRULE_CONSTRUCT */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -