Add or Replace a list of synonyms

@param rules              the list of rules to add/replace
@param forwardToReplicas  Forward this operation to the replica indices
@param clearExistingRules Replace the existing query rules with this batch
324571
public JSONObject batchRules(List<JSONObject> rules, boolean forwardToReplicas, boolean clearExistingRules) throws AlgoliaException {
    return this.batchRules(rules, forwardToReplicas, clearExistingRules, RequestOptions.empty);
  }
1339978
public static void removeRule( TerminalNode tn, Collection<InternalWorkingMemory> wms, InternalKnowledgeBase kBase) {
        if (log.isTraceEnabled()) {
            log.trace("Removing Rule {}", tn.getRule().getName());
        }

        boolean hasProtos = kBase.hasSegmentPrototypes();
        boolean hasWms = !wms.isEmpty();

        if (!hasProtos && !hasWms) {
            return;
        }

        RuleImpl      rule       = tn.getRule();
        LeftTupleNode firstSplit = getNetworkSplitPoint(tn);
        PathEndNodes pathEndNodes = getPathEndNodes(kBase, firstSplit, tn, rule, hasProtos, hasWms);

        for (InternalWorkingMemory wm : wms) {
            wm.flushPropagations();

            PathEndNodeMemories tnms = getPathEndMemories(wm, pathEndNodes);

            if ( !tnms.subjectPmems.isEmpty() ) {
                if (NodeTypeEnums.LeftInputAdapterNode == firstSplit.getType() && firstSplit.getAssociationsSize() == 1) {
                    if (tnms.subjectPmem != null) {
                        flushStagedTuples(firstSplit, tnms.subjectPmem, wm);
                    }

                    processLeftTuples(firstSplit, wm, false, tn.getRule());

                    removeNewPaths(wm, tnms.subjectPmems);
                } else {
                    flushStagedTuples(tn, tnms.subjectPmem, pathEndNodes, wm);

                    processLeftTuples(firstSplit, wm, false, tn.getRule());

                    removeNewPaths(wm, tnms.subjectPmems);

                    Map<PathMemory, SegmentMemory[]> prevSmemsLookup = reInitPathMemories(tnms.otherPmems, tn);

                    // must collect all visited SegmentMemories, for link notification
                    Set<SegmentMemory> smemsToNotify = handleExistingPaths(tn, prevSmemsLookup, tnms.otherPmems, wm, ExistingPathStrategy.REMOVE_STRATEGY);

                    notifySegments(smemsToNotify, wm);
                }
            }

            if (tnms.subjectPmem != null && tnms.subjectPmem.isInitialized() && tnms.subjectPmem.getRuleAgendaItem().isQueued()) {
                // SubjectPmem can be null, if it was never initialized
                tnms.subjectPmem.getRuleAgendaItem().dequeue();
            }
        }
    }
1248709
private void changeReplicas(PrimaryTerm term) {
    threadContext.execute(() -> {
      if (this.term == null || term.term() > this.term.term()) {
        this.term = term;
        consumer.register(term.primary().memberId());
      }
    });
  }
288415
def clear_rules_from_all_proxies(self):
        
        self._queue = []        
        if self.debug:
            print 'Clearing rules'
        for service in self.app.get_services():
            for instance in self.app.get_service_instances(service):
                if self.debug:
                    print 'Clearing rules for %s - instance %s' % (service, instance)
                resp = requests.delete("http://{}/gremlin/v1/rules".format(instance))
                if resp.status_code != 200:
                    print 'Failed to clear rules for %s - instance %s' % (service, instance)
510427
public void setRules(java.util.Collection<ScalingRule> rules) {
        if (rules == null) {
            this.rules = null;
            return;
        }

        this.rules = new com.amazonaws.internal.SdkInternalList<ScalingRule>(rules);
    }
1365938
public JSONObject batchSynonyms(List<JSONObject> objects, boolean forwardToReplicas, boolean replaceExistingSynonyms) throws AlgoliaException {
    return this.batchSynonyms(objects, forwardToReplicas, replaceExistingSynonyms, RequestOptions.empty);
  }
295690
void processNames(Collection<String> namesToResolve) {
        for (String name : namesToResolve) {
            SampleResource sample = sampleIndex.get(name.toLowerCase());
            if (sample != null) {
                // Found a sample, add it and any required features
                samplesToInstall.add(sample);
                if (sample.getRequireFeature() != null) {
                    featureNamesToResolve.addAll(sample.getRequireFeature());
                }
            } else {
                // Name didn't match any samples, assume it's a feature name
                NameAndVersion nameAndVersion = splitRequestedNameAndVersion(name);
                if (nameAndVersion.version != null) {
                    resolverRepository.setPreferredVersion(nameAndVersion.name, nameAndVersion.version);
                }

                featureNamesToResolve.add(nameAndVersion.name);
                requestedFeatureNames.add(nameAndVersion.name);
            }
        }
    }
770950
def _drop_remaining_rules(self, *rules):
        
        if rules:
            for rule in rules:
                try:
                    self._remaining_rules.remove(rule)
                except ValueError:
                    pass
        else:
            self._remaining_rules = []
990020
def addRule( self, rule ):
        
        self._rules[rule.term()] = rule
        self.updateRules()
381224
public void setRules(Collection<ServerSideEncryptionRule> rules) {
        if (rules == null) {
            this.rules = null;
            return;
        }

        this.rules = new ArrayList<ServerSideEncryptionRule>(rules);
    }
532929
public void setRules(java.util.Collection<TopicRuleListItem> rules) {
        if (rules == null) {
            this.rules = null;
            return;
        }

        this.rules = new java.util.ArrayList<TopicRuleListItem>(rules);
    }
37863
@Override
	public void cacheResult(List<CommerceDiscountRule> commerceDiscountRules) {
		for (CommerceDiscountRule commerceDiscountRule : commerceDiscountRules) {
			if (entityCache.getResult(
						CommerceDiscountRuleModelImpl.ENTITY_CACHE_ENABLED,
						CommerceDiscountRuleImpl.class,
						commerceDiscountRule.getPrimaryKey()) == null) {
				cacheResult(commerceDiscountRule);
			}
			else {
				commerceDiscountRule.resetOriginalValues();
			}
		}
	}
376785
def replace_all_synonyms(synonyms, request_options = {})
      forward_to_replicas = request_options[:forwardToReplicas] || request_options['forwardToReplicas'] || false
      batch_synonyms(synonyms, forward_to_replicas, true, request_options)
    end
417160
def updateRules( self ):
        
        terms = sorted(self._rules.keys())
        for child in self.lineWidgets():
            child.setTerms(terms)
97465
public void addRuleParserAt(IRuleParser parser, Class<? extends IRuleParser> atParser) {
        int index = getIndexOfClass(ruleParsers, atParser);
        if (index == -1) {
            throw new ParserAddException("parser " + atParser.getSimpleName() + " has not been added");
        }
        ruleParsers.remove(index);
        ruleParsers.add(index, parser);
    }
4629
private void updateRuleIndexes(CQIE rule) {
		Function head = rule.getHead();
		ruleIndex.put(head.getFunctionSymbol(), rule);
		updateRuleIndexByBodyPredicate(rule);
	}
938050
public void setPatchRules(java.util.Collection<PatchRule> patchRules) {
        if (patchRules == null) {
            this.patchRules = null;
            return;
        }

        this.patchRules = new com.amazonaws.internal.SdkInternalList<PatchRule>(patchRules);
    }