/*
Compute the message that gets passed from startFactor to destFactor.
183010
private void passMessage(CliqueTree cliqueTree, int startFactor, int destFactor, boolean useSumProduct) {
    VariableNumMap sharedVars = cliqueTree.getFactor(startFactor).getVars().intersection(cliqueTree.getFactor(destFactor).getVars());

    // Find the factors which have yet to be merged into the marginal
    // distribution of factor, but are necessary for computing the 
    // specified message.
    Set<Integer> factorIndicesToCombine = Sets.newHashSet(cliqueTree.getNeighboringFactors(startFactor));
    factorIndicesToCombine.removeAll(cliqueTree.getFactorsInMarginal(startFactor));

    // If this is the upstream round of message passing, we might not have
    // received a message from destFactor yet. However, if we have received the 
    // message, we should include it in the product as it will increase sparsity 
    // and thereby improve efficiency.
    if (cliqueTree.getMessage(destFactor, startFactor) == null) {
      factorIndicesToCombine.remove(destFactor);
    }

    List<Factor> factorsToCombine = new ArrayList<Factor>();
    for (Integer adjacentFactorNum : factorIndicesToCombine) {
      factorsToCombine.add(cliqueTree.getMessage(adjacentFactorNum, startFactor));
    }

    // Update the marginal distribution of startFactor in the clique tree.
    Factor updatedMarginal = cliqueTree.getMarginal(startFactor).product(factorsToCombine);
    if (cliqueTree.getOutboundFactors(startFactor).size() == 0) {
      // If this factor has yet to send any outbound messages, we can 
      // use it to renormalize the probability distribution to avoid
      // possible numerical overflow issues. Updating the marginal
      // at this point is equivalent to multiplying the original factor
      // by some constant value, which doesn't affect the probability
      // distribution.
      if (renormalize) {
        updatedMarginal = updatedMarginal.product(1.0 / updatedMarginal.getTotalUnnormalizedProbability());
      }
      
      // Can also prune this marginal if a pruning strategy was provided.
      if (pruningStrategy != null) {
        updatedMarginal = pruningStrategy.apply(updatedMarginal);
      }
    }
    cliqueTree.setMarginal(startFactor, updatedMarginal);
    cliqueTree.addFactorsToMarginal(startFactor, factorIndicesToCombine);

    // The message from startFactor to destFactor is the marginal of
    // productFactor, divided by the message from destFactor to
    // startFactor, if it exists.
    Factor messageFactor = null;
    if (useSumProduct) {
      messageFactor = updatedMarginal.marginalize(updatedMarginal.getVars().removeAll(sharedVars).getVariableNums());
    } else {
      messageFactor = updatedMarginal.maxMarginalize(updatedMarginal.getVars().removeAll(sharedVars).getVariableNums());
    }

    // Divide out the destFactor -> startFactor message if necessary.
    if (cliqueTree.getFactorsInMarginal(startFactor).contains(destFactor)) {
      messageFactor = messageFactor.product(cliqueTree.getMessage(destFactor, startFactor).inverse());
    }

    cliqueTree.addMessage(startFactor, destFactor, messageFactor);
  }
65691
@Override
    public void processMessage() {
        VectorAggregation aggregation = new VectorAggregation(rowIndex, (short) voidConfiguration.getNumberOfShards(),
                        getShardIndex(), storage.getArray(key).getRow(rowIndex).dup());
        aggregation.setOriginatorId(this.getOriginatorId());

        clipboard.pin(aggregation);

        DistributedVectorMessage dvm = new DistributedVectorMessage(key, rowIndex);
        dvm.setOriginatorId(this.originatorId);

        if (voidConfiguration.getNumberOfShards() > 1)
            transport.sendMessageToAllShards(dvm);
        else {
            aggregation.extractContext(this);
            aggregation.processMessage();
        }
    }
619549
@Override
    public void beginTranslation(Object obj, Code dest) {
        if (constrType == INVOKESPECIAL) {
            dest.emit(NEW, new ClassRef(type));
            dest.emit(DUP);
            // save reference that remains on the stack
            // when object() is finished
        }
    }
355593
private MsgFormat init()
        throws EFapsException
    {
        if (!this.initialized) {
            for (final Class<?> clazz : new EsjpScanner().scan(EFapsFormatFactory.class)) {
                try {
                    final FormatFactory factory = (FormatFactory) clazz.newInstance();
                    final EFapsFormatFactory ano = clazz.getAnnotation(EFapsFormatFactory.class);
                    this.registry.put(ano.name(), factory);
                } catch (final InstantiationException | IllegalAccessException e) {
                    MsgFormat.LOG.error("Catched error on instantiotion", e);
                }
            }
            MsgFormat.LOG.info("registered FormatFactories: {}", this.registry);
            this.initialized = true;
        }
        return this;
    }
231053
protected int marshalMessagesToSameDestination(Address dest, Message[] buf,
                                                   int start_index, final int end_index, int max_bundle_size) throws Exception {
        int num_msgs=0, bytes=0;
        for(;;) {
            Message msg=buf[start_index];
            if(msg != null && Objects.equals(dest, msg.dest())) {
                long size=msg.size();
                if(bytes + size > max_bundle_size)
                    break;
                bytes+=size;
                num_msgs++;
                buf[start_index]=null;
                msg.writeToNoAddrs(msg.src(), output, transport.getId());
            }
            if(start_index == end_index)
                break;
            start_index=advance(start_index);
        }
        return num_msgs;
    }
204782
function (input, readCallback) {
    if (compileStandard !== null) {
      return compileStandard(input, readCallback);
    }

    function formatFatalError (message) {
      return JSON.stringify({
        errors: [
          {
            'type': 'SOLCError',
            'component': 'dsolcjs',
            'severity': 'error',
            'message': message,
            'formattedMessage': 'Error: ' + message
          }
        ]
      });
    }

    if (readCallback !== undefined && typeof readCallback !== 'function') {
      return formatFatalError('Invalid import callback supplied');
    }

    try {
      input = JSON.parse(input);
    } catch (e) {
      return formatFatalError('Invalid JSON supplied: ' + e.message);
    }

    if (input['language'] !== 'Solidity') {
      return formatFatalError('Only Solidity sources are supported');
    }

    // NOTE: this is deliberately `== null`
    if (input['sources'] == null || input['sources'].length === 0) {
      return formatFatalError('No input specified');
    }

    // Bail out early
    if ((input['sources'].length > 1) && (compileJSONMulti === null)) {
      return formatFatalError('Multiple sources provided, but compiler only supports single input');
    }

    function isOptimizerEnabled (input) {
      return input['settings'] && input['settings']['optimizer'] && input['settings']['optimizer']['enabled'];
    }

    function translateSources (input) {
      var sources = {};
      for (var source in input['sources']) {
        if (input['sources'][source]['content'] !== null) {
          sources[source] = input['sources'][source]['content'];
        } else {
          // force failure
          return null;
        }
      }
      return sources;
    }

    function librariesSupplied (input) {
      if (input['settings'] !== null) {
        return input['settings']['libraries'];
      }
    }

    function translateOutput (output, libraries) {
      try {
        output = JSON.parse(output);
      } catch (e) {
        return formatFatalError('Compiler returned invalid JSON: ' + e.message);
      }
      output = translate.translateJsonCompilerOutput(output, libraries);
      if (output == null) {
        return formatFatalError('Failed to process output');
      }
      return JSON.stringify(output);
    }

    var sources = translateSources(input);
    if (sources === null || Object.keys(sources).length === 0) {
      return formatFatalError('Failed to process sources');
    }

    // Try linking if libraries were supplied
    var libraries = librariesSupplied(input);

    // Try to wrap around old versions
    if (compileJSONCallback !== null) {
      return translateOutput(compileJSONCallback(JSON.stringify({ 'sources': sources }), isOptimizerEnabled(input), readCallback), libraries);
    }

    if (compileJSONMulti !== null) {
      return translateOutput(compileJSONMulti(JSON.stringify({ 'sources': sources }), isOptimizerEnabled(input)), libraries);
    }

    // Try our luck with an ancient compiler
    if (compileJSON !== null) {
      return translateOutput(compileJSON(sources[Object.keys(sources)[0]], isOptimizerEnabled(input)), libraries);
    }

    return formatFatalError('Compiler does not support any known interface.');
  }
796043
@Override
	public void processMessage(WebSocketMessage webSocketData) throws FrameworkException {

		setDoTransactionNotifications(true);

		final String mode                     = webSocketData.getNodeDataStringValue("mode");		// default: list    start | pause | resume | cancel | abort
		final Long jobId                      = webSocketData.getNodeDataLongValue("jobId");

		final JobQueueManager mgr = JobQueueManager.getInstance();

		final List<GraphObject> result = new LinkedList<>();

		switch (mode) {

			case "start":
				mgr.startJob(jobId);
				break;

			case "pause":
				mgr.pauseRunningJob(jobId);
				break;

			case "resume":
				mgr.resumePausedJob(jobId);
				break;

			case "abort":
				mgr.abortActiveJob(jobId);
				break;

			case "cancel":
				mgr.cancelQueuedJob(jobId);
				break;

			case "list":
			default:
				final GraphObjectMap importsContainer = new GraphObjectMap();

				importsContainer.put(importJobsProperty, mgr.listJobs());
				result.add(importsContainer);
		}

			webSocketData.setResult(result);
			webSocketData.setRawResultCount(1);
			getWebSocket().send(webSocketData, true);

	}
513650
private static final Tensor getFactorMessage(int curVarNum, Tensor logFactorWeights,
      List<Tensor> variableMarginals, IndexedList<Integer> variableNums) {
    Tensor factorMessage = logFactorWeights;
    // Each message is the outer product of all variable marginals, except
    // variable i, elementwise multiplied by the log factor weights.
    int[] weightVariableNums = factorMessage.getDimensionNumbers();
    List<Integer> variablesToMarginalize = Lists.newArrayList();
    for (int j = 0; j < weightVariableNums.length; j++) {
      if (weightVariableNums[j] == curVarNum) {
        continue;
      }

      Tensor variableMarginal = variableMarginals.get(variableNums.getIndex(weightVariableNums[j]));
      factorMessage = factorMessage.elementwiseProduct(variableMarginal);
      variablesToMarginalize.add(weightVariableNums[j]);
    }
    return factorMessage.sumOutDimensions(variablesToMarginalize);
  }
470918
public void registerProcessForMessage(BaseMessageFilter messageFilter, String strProcessClass, Map<String,Object> properties)
    {
        new TrxMessageListener(messageFilter, (Application)this.getTask().getApplication(), strProcessClass, properties);   // This listener was added to the filter
        ((MessageInfoApplication)this.getTask().getApplication()).getThickMessageManager().addMessageFilter(messageFilter);
        // Note: No need to worry about cleanup... Freeing the message manager will free all these listeners.
        if (properties != null)
            if (properties.get(MessageInfoApplication.AUTOSTART) != null)
                ((MessageInfoApplication)this.getTask().getApplication()).getThickMessageManager().sendMessage(new MapMessage(new BaseMessageHeader(messageFilter.getQueueName(), messageFilter.getQueueType(), this, null), properties));
    }
591238
function getDefinedMessage(unusedVar) {
            const defType = unusedVar.defs && unusedVar.defs[0] && unusedVar.defs[0].type;
            let type;
            let pattern;

            if (defType === "CatchClause" && config.caughtErrorsIgnorePattern) {
                type = "args";
                pattern = config.caughtErrorsIgnorePattern.toString();
            } else if (defType === "Parameter" && config.argsIgnorePattern) {
                type = "args";
                pattern = config.argsIgnorePattern.toString();
            } else if (defType !== "Parameter" && config.varsIgnorePattern) {
                type = "vars";
                pattern = config.varsIgnorePattern.toString();
            }

            const additional = type ? ` Allowed unused ${type} must match ${pattern}.` : "";

            return `'{{name}}' is defined but never used.${additional}`;
        }
1108397
function getRoutedMessageHandler(params, onMessage, onError, isRetryPatchMode) {
  var expectedBatchMessageCount = 0;
  var numBatchesDetermined = false;
  var messageBatchBuffer = [];
  var lastSeenDataTime = 0;
  var lastSeenDataBatchTime = 0;

  function composeDataBatches(dataArray) {
    if (dataArray.length === 0) {
      if (messageBatchBuffer.length > 0) {
        console.error('Composed an empty data batch despite having data in the buffer!');
      }
      return null;
    }

    var errorOccurred = false;
    var basisData = dataArray[0];
    var expectedTimeStamp = basisData.logicalTimestampMs;
    lastSeenDataBatchTime = expectedTimeStamp;
    dataArray.slice(1).forEach(function (batch) {
      if (batch.logicalTimestampMs !== expectedTimeStamp) {
        errorOccurred = true;
      } else {
        basisData.data = basisData.data.concat(batch.data);
      }
    });

    if (errorOccurred) {
      console.error('Bad timestamp pairs when flushing data batches!  Inconsistent data!');
      return null;
    }
    return basisData;
  }

  function flushBuffer() {
    if (numBatchesDetermined && messageBatchBuffer.length === expectedBatchMessageCount && messageBatchBuffer.length > 0) {
      onMessage(composeDataBatches(messageBatchBuffer));
      messageBatchBuffer = [];
    }
  }

  return {
    getLatestBatchTimeStamp: function () {
      return lastSeenDataBatchTime;
    },
    onMessage: function messageReceived(msg) {
      if (!msg.type && msg.hasOwnProperty('error')) {
        onMessage(msg);
        return;
      }
      switch (msg.type) {
        case 'data':
          if (lastSeenDataTime && lastSeenDataTime !== msg.logicalTimestampMs) {
            // if zero time series are encountered, then no metadata arrives, but data batches arrive with differing
            // timestamp as the only evidence of a stream block
            numBatchesDetermined = true;
          }
          lastSeenDataTime = msg.logicalTimestampMs;
          messageBatchBuffer.push(msg);
          if (!numBatchesDetermined) {
            expectedBatchMessageCount++;
          } else if (messageBatchBuffer.length === expectedBatchMessageCount) {
            flushBuffer();
          }
          break;
        case 'message':
          if (msg.message && msg.message.messageCode === 'JOB_RUNNING_RESOLUTION') {
            numBatchesDetermined = true;
            flushBuffer();
          }
          onMessage(msg);
          break;
        case 'metadata':
        case 'event':
          onMessage(msg);
          break;
        case 'control-message':
          if (isRetryPatchMode && !numBatchesDetermined) {
            break;
          }
          onMessage(msg);
          break;
        case 'error':
          if (onError) {
            onError(msg);
          }
          break;
        default:
          console.log('Unrecognized message type.');
          break;
      }
      flushBuffer();
    }
  };
}
1252714
private ExecutionMessage createTerminatedExecutionMessage(Execution nextStepExecution) {
        Payload payload = converter.createPayload(nextStepExecution); //we need the payload
        ExecutionMessage finalMessage = (ExecutionMessage) executionMessage.clone();
        finalMessage.setStatus(ExecStatus.TERMINATED); //in queue it is checked and finish flow is called
        finalMessage.incMsgSeqId();
        finalMessage.setPayload(payload);
        return finalMessage;
    }
1158899
@SuppressWarnings("unchecked")
    // The warning 'unchecked cast' being suppressed here comes from the build() formally returning
    // a MessageLite-derived class that cannot be statically guaranteed to be the MessageType.
    private void deserializeMessage(ByteBuffer buff) throws Exception {
        MessageType msg = (MessageType) prototype.newBuilderForType().mergeFrom(ByteString.copyFrom(buff)).build();
        resetTimeout();
        handler.messageReceived(this, msg);
    }
1052195
function finishMessage() {
    if (parser.tag_ < Parser.PADDING_TAG_) {
      var message = {};
      message[parser.tag_] = parser.messageBuffer_;
      parser.result_.push(message);
    }
    parser.state_ = Parser.State_.INIT;
  }
1147015
private String getMessageFromCode(final int messageCode) {
        String res = "";
        switch (messageCode) {
            case 100:
                res = "Initializing";
                break;
            case 200:
                res = "";// Provisioned for custom pre-init task
                break;
            case 300:
                res = "";// Provisioned for custom pre-init task
                break;
            case 400:
                res = "Loading Messages Properties";
                break;
            case 500:
                res = "Loading Parameters Properties";
                break;
            case 600:
                res = "Preparing Core Engine";
                break;
            case 700:
                res = "Preloading Resources";
                break;
            case 800:
                res = "Preloading Modules";
                break;
            case 900:
                res = "";// Provisioned for custom post-init task
                break;
            case 1000:
                res = "Starting";
                break;
            default:
        }
        return res;
    }
303517
public static DynamicMessage parseFrom(final Descriptor type, final ByteString data,
      final ExtensionRegistry extensionRegistry) throws InvalidProtocolBufferException {
    return wrap(com.google.protobuf.DynamicMessage.parseFrom(type, data, extensionRegistry));
  }
886246
function processImportDefaultSpecifier() {
                    if (
                        secondSpecifier &&
                        secondSpecifier.type === "ImportNamespaceSpecifier"
                    ) {
                        // There is a pattern:
                        //     import Foo, * as foo from "foo"
                        tokens.push(
                            sourceCode.getFirstToken(firstSpecifier), // Foo
                            sourceCode.getTokenAfter(firstSpecifier), // comma
                            sourceCode.getFirstToken(secondSpecifier), // *
                            sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
                            sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
                        )
                    } else {
                        // There are 3 patterns:
                        //     import Foo from "foo"
                        //     import Foo, {} from "foo"
                        //     import Foo, {a} from "foo"
                        const idToken = sourceCode.getFirstToken(firstSpecifier)
                        const nextToken = sourceCode.getTokenAfter(
                            firstSpecifier
                        )
                        if (isComma(nextToken)) {
                            const leftBrace = sourceCode.getTokenAfter(
                                nextToken
                            )
                            const rightBrace = sourceCode.getLastToken(
                                node,
                                hasSemi ? 3 : 2
                            )
                            setOffsetToToken(
                                [idToken, nextToken],
                                1,
                                importToken
                            )
                            setOffsetToToken(leftBrace, 0, idToken)
                            processNodeList(
                                node.specifiers.slice(1),
                                leftBrace,
                                rightBrace,
                                1
                            )
                            tokens.push(
                                sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
                                sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
                            )
                        } else {
                            tokens.push(
                                idToken,
                                nextToken, // from
                                sourceCode.getTokenAfter(nextToken) // "foo"
                            )
                        }
                    }
                }