Convert from MQ feedback values to Jetstream values.

@param fb An MQ feedback value
@return The equivalent Jetstream value
171793
@Override
    public Integer convertMQFeedbackToJS(Integer fb) {
        Integer result = null;

        // if fb is null, then the default result value of null is ok.
        if (fb != null)
            result = convertMQFeedbackToJS(fb.intValue());

        return result;
    }
280285
public static EnumMap<FacebookParam, CharSequence> extractFacebookParams(Map<CharSequence, CharSequence> reqParams) {
    if (null == reqParams)
      return null;

    EnumMap<FacebookParam, CharSequence> result =
      new EnumMap<FacebookParam, CharSequence>(FacebookParam.class);
    for (Map.Entry<CharSequence, CharSequence> entry: reqParams.entrySet()) {
      FacebookParam matchingFacebookParam = FacebookParam.get(entry.getKey().toString());
      if (null != matchingFacebookParam) {
        result.put(matchingFacebookParam, entry.getValue());
      }
    }
    return result;
  }
892253
public void setStaticPropertyValue(final String fqn, final String property, final JsonNode value) {
        ObjectNode req = makeRequest("sset");
        req.put("fqn", fqn);
        req.put("property", property);
        req.set("value", value);
        this.runtime.requestResponse(req);
    }
697850
public static SameDiff fromFlatBuffers(ByteBuffer bbIn) throws IOException {

        FlatGraph fg = FlatGraph.getRootAsFlatGraph(bbIn);

        int numOps = fg.nodesLength();
        int numVars = fg.variablesLength();
        List<FlatNode> ops = new ArrayList<>(numOps);
        for( int i=0; i<numOps; i++ ){
            ops.add(fg.nodes(i));
        }
        List<FlatVariable> vars = new ArrayList<>(numVars);
        for( int i = 0; i < numVars; i++) {
            vars.add(fg.variables(i));
        }

        FlatConfiguration conf = fg.configuration();

        /* Reconstruct the graph
        We'll do the reconstruction manually here, rather than using sd.var(...), so that we have more control
        over the final result.
         */

        SameDiff sd = SameDiff.create();

        //Reconstruct placeholders
        int numPlaceholders = fg.placeholdersLength();
        Set<String> ph = new LinkedHashSet<>();
        for(int i=0; i<numPlaceholders; i++ ){
            ph.add(fg.placeholders(i));
        }

        //Reconstruct variables:
        Map<Integer,SDVariable> varNodeIds = new HashMap<>();
        Map<Pair<Integer,Integer>, SDVariable> variablesByNodeAndOutNum = new HashMap<>();
        Map<String,List<SDVariable>> variablesByName = new HashMap<>();
        for(FlatVariable v : vars){
            int shapeLength = v.shapeLength();
            long[] shape = new long[shapeLength];
            for( int i = 0; i < shapeLength; i++) {
                shape[i] = v.shape(i);
            }

            String n = v.name();

            byte dtypeByte = v.dtype();
            org.nd4j.linalg.api.buffer.DataType dtype = FlatBuffersMapper.getDataTypeFromByte(dtypeByte);

            //TODO Infer this properly! Could be constant, etc.
            VariableType vt = VariableType.values()[v.variabletype()];
            SDVariable var = new SDVariable(n, vt, sd, shape, dtype, null);
            sd.variables.put(n, Variable.builder().name(n).variable(var).build());
            sd.variableNameToShape.put(n, shape);


            FlatArray fa = v.ndarray();
            if(fa != null && vt != VariableType.ARRAY){
                INDArray arr;
                try(MemoryWorkspace ws = Nd4j.getWorkspaceManager().scopeOutOfWorkspaces()) {
                    arr = Nd4j.createFromFlatArray(fa);
                }
                sd.setArrayForVariable(n, arr);
            }

            IntPair id = v.id();    //First value: node (op) id. Second: output number
            variablesByNodeAndOutNum.put(new Pair<>(id.first(), id.second()), var);

            if(!variablesByName.containsKey(n)){
                variablesByName.put(n, new ArrayList<SDVariable>());
            }

            List<SDVariable> list = variablesByName.get(n);
            list.add(var);
        }

        //Reconstruct ops:
        for(FlatNode fn : ops){
            DifferentialFunction df = FlatBuffersMapper.fromFlatNode(fn);
            String name = fn.name();
            df.setSameDiff(sd);
            df.setOwnName(name);
            if(sd.ops.containsKey(name)){
                sd.ops.get(name).setOp(df);
            } else {
                sd.ops.put(name, SameDiffOp.builder().name(name).op(df).build());
            }

            int outLength = fn.outputLength();
            int[] outs = new int[outLength];
            for( int i=0; i<outLength; i++ ){
                outs[i] = fn.output(i);
            }

            int opId = fn.id();

            //Work out inputs and outputs:
            int[] output = new int[fn.outputLength()];
            for (int i = 0; i < output.length; i++) {
                output[i] = fn.output(i);
            }
            int[] input = new int[fn.inputLength()];
            for (int i = 0; i < input.length; i++) {
                input[i] = fn.input(i);
            }
            IntPair[] inputPaired = new IntPair[fn.inputPairedLength()];
            List<Pair<Integer,Integer>> intPairList = new ArrayList<>();
            for (int i = 0; i < inputPaired.length; i++) {
                inputPaired[i] = fn.inputPaired(i);
                intPairList.add(new Pair<>(inputPaired[i].first(), inputPaired[i].second()));
            }

            String[] inputNames = new String[inputPaired.length];
            for(int i=0; i<inputPaired.length; i++ ){
                int nodeId = inputPaired[i].first();
                int nodeOutNum = inputPaired[i].second();
                SDVariable varIn = variablesByNodeAndOutNum.get(new Pair<>(nodeId, nodeOutNum));
                if(varIn == null){
                    //The variable corresponding to this op was not
                }
                inputNames[i] = varIn.getVarName();
            }
            sd.ops.get(df.getOwnName()).setInputsToOp(Arrays.asList(inputNames));

            //Record that input variables are input to this op
            for(String inName : inputNames) {
                Variable v = sd.getVariables().get(inName);
                if(v.getInputsForOp() == null){
                    v.setInputsForOp(new ArrayList<String>());
                }
                if(!v.getInputsForOp().contains(df.getOwnName())){
                    v.getInputsForOp().add(df.getOwnName());
                }
            }

            List<SDVariable> varsForOp = variablesByName.get(name);

            //Can't assume that variables for the op have all been defined. For example, if we export before execution in SameDiff
            //In theory, we can reconstruct the output variables (minus names) if we know the number of op outputs
            //And we can calculate the op outputs - in most cases - after the op has been created and parameters set
            int numOutputs = df.getNumOutputs();
            if(numOutputs <= 0){
                numOutputs = fn.outputLength();
            }

            String[] varNames = null;
            if(varsForOp != null && varsForOp.size() == numOutputs){
                varNames = new String[varsForOp.size()];
                for( int i=0; i<varNames.length; i++ ){
                    varNames[i] = varsForOp.get(i).getVarName();
                    sd.getVariables().get(varNames[i]).setOutputOfOp(df.getOwnName());
                }
                sd.ops.get(df.getOwnName()).setOutputsOfOp(Arrays.asList(varNames));
            } else {
                //We're missing some variables...
                int outputNamesLength = fn.outputNamesLength();
                varNames = new String[outputNamesLength];
                for( int i=0; i<outputNamesLength; i++ ){
                    String n = fn.outputNames(i);
                    varNames[i] = n;
                    if(!sd.variables.containsKey(n)){
                        //Need to create the variable - perhaps it wasn't exported. Note output of node -> can only be VARIABLE type
                        SDVariable var = new SDVariable(n, VariableType.VARIABLE, sd, null, null, null);
                        sd.variables.put(n, Variable.builder().name(n).variable(var).build());
                        variablesByNodeAndOutNum.put(new Pair<>(opId, i), var);
                    }
                    sd.getVariables().get(varNames[i]).setOutputOfOp(df.getOwnName());
                }
                sd.ops.get(df.getOwnName()).setOutputsOfOp(Arrays.asList(varNames));
            }

            //Check the op mapping int he variablesByNodeAndOutputNum
            //For multi-output ops, variables will have their own index, not related to the op index
            for( int i=0; i<varNames.length; i++ ){
                Pair<Integer,Integer> p = new Pair<>(opId, i);
                if(!variablesByNodeAndOutNum.containsKey(p)){
                    variablesByNodeAndOutNum.put(p, sd.getVariable(varNames[i]));
                }
            }
        }

        //Reconstruct loss variables
        if(fg.lossVariablesLength() > 0){
            for(int i=0; i<fg.lossVariablesLength(); i++ ){
                sd.addLossVariable(fg.lossVariables(i));
            }
        }

        return sd;
    }
539019
public void getMFOrder(KiteConnect kiteConnect) throws KiteException, IOException {
        System.out.println("mf order: "+ kiteConnect.getMFOrder("106580291331583").tradingsymbol);
    }
945729
@Override
    protected JsJmsMessage getMsgReference() throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "getMsgReference");

        // If the body is read only, the contents should already be in the
        // JS message, so only do the copy over if we are in write mode.
        // SIB0121: ... and if the producer might modify the payload after it's been set
        if (!isBodyReadOnly() && !producerWontModifyPayloadAfterSet) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                SibTr.debug(this, tc, "Body is writeable & producer hasn't promised not to modify the payload - attempt encoding");

            try {
                int encoding = integerEncoding | floatEncoding; // NB bitwise or (|), not logical or (||)
                // check if JMS_IBM_Encoding has been set
                if (propertyExists(ApiJmsConstants.ENCODING_PROPERTY)) {
                    encoding = getIntProperty(ApiJmsConstants.ENCODING_PROPERTY);
                }

                if (bodySetInJsMsg && (encoding == lastEncoding)) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                        SibTr.debug(this, tc, "Body cached - encoding not necessary");
                }
                else {
                    // flatten and encode the data streams
                    byte[] encodedBody = _exportBody(encoding);
                    // and set it into the Jetstream message
                    jsBytesMsg.setBytes(encodedBody);
                    lastEncoding = encoding;
                    bodySetInJsMsg = true;
                }
            }

            catch (JMSException e) {
                // No FFDC code needed

                // d222942 review JMSException could be thrown by _exportBody if passed an unknown
                // value for encoding, or if there was an IO error handling the streams. These already
                // have good nls messages, so we should simply pass on, not wrap with a generic message.
                // Similarly, getIntProperty can throw a JMSException which can also be passed on.
                throw e;
            }

        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "getMsgReference", jsBytesMsg);
        return jsBytesMsg;
    }
592656
@Override
    public <U> MonadicBinding<U> flatMap(
            Function<? super T, ? extends ObservableValue<U>> f) {
        return EasyBind.flatMap(delegate, f);
    }
489754
@Override
    public Integer convertJSFeedbackToMQ(Integer fb) {
        Integer result = null;

        if (SIApiConstants.REPORT_COA.equals(fb)) {
            result = Integer.valueOf(ApiJmsConstants.MQFB_COA);
        }
        else if (SIApiConstants.REPORT_COD.equals(fb)) {
            result = Integer.valueOf(ApiJmsConstants.MQFB_COD);
        }
        else if (SIApiConstants.REPORT_EXPIRY.equals(fb)) {
            result = Integer.valueOf(ApiJmsConstants.MQFB_EXPIRATION);
        }
        else if (SIApiConstants.REPORT_PAN.equals(fb)) {
            result = Integer.valueOf(ApiJmsConstants.MQFB_PAN);
        }
        else if (SIApiConstants.REPORT_NAN.equals(fb)) {
            result = Integer.valueOf(ApiJmsConstants.MQFB_NAN);
        }
        else {
            // All other values passed unchanged
            result = fb;
        }

        return result;
    }
1150368
@SuppressWarnings({"checkstyle:cyclomaticcomplexity",
		"checkstyle:booleanexpressioncomplexity", "checkstyle:npathcomplexity"})
	public static String toDefaultValue(JvmTypeReference type) {
		final String id = type.getIdentifier();
		if (!"void".equals(id)) { //$NON-NLS-1$
			if (Strings.equal(Boolean.class.getName(), id) || Strings.equal(Boolean.TYPE.getName(), id)) {
				return "False"; //$NON-NLS-1$
			}
			if (Strings.equal(Float.class.getName(), id) || Strings.equal(Float.TYPE.getName(), id)
				|| Strings.equal(Double.class.getName(), id) || Strings.equal(Double.TYPE.getName(), id)) {
				return "0.0"; //$NON-NLS-1$
			}
			if (Strings.equal(Integer.class.getName(), id) || Strings.equal(Integer.TYPE.getName(), id)
				|| Strings.equal(Long.class.getName(), id) || Strings.equal(Long.TYPE.getName(), id)
				|| Strings.equal(Byte.class.getName(), id) || Strings.equal(Byte.TYPE.getName(), id)
				|| Strings.equal(Short.class.getName(), id) || Strings.equal(Short.TYPE.getName(), id)) {
				return "0"; //$NON-NLS-1$
			}
			if (Strings.equal(Character.class.getName(), id) || Strings.equal(Character.TYPE.getName(), id)) {
				return "\"\\0\""; //$NON-NLS-1$
			}
		}
		return "None"; //$NON-NLS-1$
	}
803395
public static FloatBinding nextDown(final ObservableFloatValue f) {
        return createFloatBinding(() -> Math.nextDown(f.get()), f);
    }
927998
public void sendQuickReplyPayload(String payload) {
		MessageEnvelope envelope = new MessageEnvelope();
		QuickReply quickReply = new QuickReply("Sample", payload);

		ReceivedMessage message = new ReceivedMessage();
		message.setQuickReply(quickReply);
		envelope.setMessage(message);
		envelope.setSender(new User(facebookMockId));

		System.out.println("Sending quick reply: [" + message + "] as user : ["
				+ facebookMockId + "].");
		forward(envelope);
		System.out.println("Sent!");
	}
63692
Stream<String> writeFunctionCounter(FunctionCounter counter) {
        double count = counter.count();
        if (Double.isFinite(count)) {
            return Stream.of(writeMetric(counter.getId(), config().clock().wallTime(), count));
        }
        return Stream.empty();
    }
1093453
@Override
	public FbBotMillResponse createResponse(MessageEnvelope envelope) {
		FbBotMillResponse response = null;

		switch (attachmentType) {
		case FILE:
			response = ReplyFactory.addFileAttachment(url).build(envelope);
			break;
		case IMAGE:
			response = ReplyFactory.addImageAttachment(url).build(envelope);
			break;
		case AUDIO:
			response = ReplyFactory.addAudioAttachment(url).build(envelope);
			break;
		case VIDEO:
			response = ReplyFactory.addVideoAttachment(url).build(envelope);
			break;
		default:
			String message = "Illegal attachment of type [ " + attachmentType.name() + " ] for AttachmentAutoReply";
			logger.error(message);
			throw new BotMillIllegalAttachmentException(message);
		}
		return response;
	}
1146550
public ServiceCall<Void> deleteFeedback(DeleteFeedbackOptions deleteFeedbackOptions) {
    Validator.notNull(deleteFeedbackOptions, "deleteFeedbackOptions cannot be null");
    String[] pathSegments = { "v1/feedback" };
    String[] pathParameters = { deleteFeedbackOptions.feedbackId() };
    RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments,
        pathParameters));
    builder.query("version", versionDate);
    Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("compare-comply", "v1", "deleteFeedback");
    for (Entry<String, String> header : sdkHeaders.entrySet()) {
      builder.header(header.getKey(), header.getValue());
    }
    builder.header("Accept", "application/json");
    if (deleteFeedbackOptions.model() != null) {
      builder.query("model", deleteFeedbackOptions.model());
    }
    return createServiceCall(builder.build(), ResponseConverterUtils.getVoid());
  }
57142
def fb_get(self, quant, fb=16):
        """"""

        raw_number = self.s_get(quant)

        if quant == 1:
            # special case, just return that unsigned value
            return raw_number

        return raw_number / (1 << fb)
1184504
@Nonnull
    public PMessageBuilder<T, F> addTo(@Nonnull F field, Object value) {
        return addTo(field.getId(), value);
    }
169073
protected List getConvertedFRP() {

        List theList = null;
        StringArrayWrapper saw = (StringArrayWrapper) properties.get(FORWARD_ROUTING_PATH);
        if (saw != null) {
            // This list is the forward routing path for the message.
            theList = saw.getMsgForwardRoutingPath();
        }
        return theList;
    }