Esempio n. 1
0
static void CheckForPrimableJoins(
  void *theEnv,
  EXEC_STATUS,
  struct defrule *tempRule,
  struct joinNode *joinPtr)
  {   
   /*========================================*/
   /* Loop through each of the rule's joins. */
   /*========================================*/

   for (;
        joinPtr != NULL;
        joinPtr = joinPtr->lastLevel)
     {
      /*===============================*/
      /* Update the join if necessary. */
      /*===============================*/

      if ((joinPtr->initialize) && (! joinPtr->marked))
        {
         if (joinPtr->firstJoin == TRUE)
           {
			if (joinPtr->joinFromTheRight == FALSE)
              {
               if ((joinPtr->rightSideEntryStructure == NULL) ||
                   (joinPtr->patternIsNegated) ||
                   (((struct patternNodeHeader *) joinPtr->rightSideEntryStructure)->initialize == FALSE))
                 {
                  PrimeJoinFromLeftMemory(theEnv,execStatus,joinPtr);
                  joinPtr->marked = TRUE;
                 }
              }
            else
              {
               PrimeJoinFromRightMemory(theEnv,execStatus,joinPtr);
               joinPtr->marked = TRUE;
              }
           }
         else if (joinPtr->lastLevel->initialize == FALSE)
           { 
            PrimeJoinFromLeftMemory(theEnv,execStatus,joinPtr); 
            joinPtr->marked = TRUE;
           }
         else if ((joinPtr->joinFromTheRight) &&
                (((struct joinNode *) joinPtr->rightSideEntryStructure)->initialize == FALSE))
           {
            PrimeJoinFromRightMemory(theEnv,execStatus,joinPtr);
            joinPtr->marked = TRUE;
           }
        }
        
      if (joinPtr->joinFromTheRight)
        { CheckForPrimableJoins(theEnv,execStatus,tempRule,(struct joinNode *) joinPtr->rightSideEntryStructure); }
     }
  }
Esempio n. 2
0
globle void IncrementalReset(
  void *theEnv,
  struct defrule *tempRule)
  {
#if (MAC_MCW || WIN_MCW) && (RUN_TIME || BLOAD_ONLY)
#pragma unused(theEnv,tempRule)
#endif

#if (! RUN_TIME) && (! BLOAD_ONLY)
   struct defrule *tempPtr;
   struct patternParser *theParser;

   /*================================================*/
   /* If incremental reset is disabled, then return. */
   /*================================================*/

   if (! EnvGetIncrementalReset(theEnv)) return;

   /*=====================================================*/
   /* Mark the pattern and join network data structures   */
   /* associated with the rule being incrementally reset. */
   /*=====================================================*/

   MarkNetworkForIncrementalReset(theEnv,tempRule,TRUE);

   /*==========================*/
   /* Begin incremental reset. */
   /*==========================*/

   EngineData(theEnv)->IncrementalResetInProgress = TRUE;

   /*============================================================*/
   /* If the new rule shares patterns or joins with other rules, */
   /* then it is necessary to update its join network based on   */
   /* existing partial matches it shares with other rules.       */
   /*============================================================*/

   for (tempPtr = tempRule;
        tempPtr != NULL;
        tempPtr = tempPtr->disjunct)
     { CheckForPrimableJoins(theEnv,tempPtr,tempPtr->lastJoin); }

   /*===============================================*/
   /* Filter existing data entities through the new */
   /* portions of the pattern and join networks.    */
   /*===============================================*/

   for (theParser = PatternData(theEnv)->ListOfPatternParsers;
        theParser != NULL;
        theParser = theParser->next)
     {
      if (theParser->incrementalResetFunction != NULL)
        { (*theParser->incrementalResetFunction)(theEnv); }
     }

   /*========================*/
   /* End incremental reset. */
   /*========================*/

   EngineData(theEnv)->IncrementalResetInProgress = FALSE;

   /*====================================================*/
   /* Remove the marks in the pattern and join networks. */
   /*====================================================*/

   MarkNetworkForIncrementalReset(theEnv,tempRule,FALSE);
#endif
  }