The Graql compute std query run method

@return a Answer object containing a Number that represents the answer
779591
private Stream<Numeric> runComputeStd(GraqlCompute.Statistics.Value query) {
        Map<String, Double> stdTuple = runComputeStatistics(query);
        if (stdTuple == null)  return Stream.empty();

        double squareSum = stdTuple.get(StdMapReduce.SQUARE_SUM);
        double sum = stdTuple.get(StdMapReduce.SUM);
        double count = stdTuple.get(StdMapReduce.COUNT);
        Double std = Math.sqrt(squareSum / count - (sum / count) * (sum / count));

        return Stream.of(new Numeric(std));
    }
458531
function(cb) {
      // For a basic match
      usableQueryKeys = [];
      Object.keys(query).forEach(function(k) {
        if (
          typeof query[k] === 'string' ||
          typeof query[k] === 'number' ||
          typeof query[k] === 'boolean' ||
          util.isDate(query[k]) ||
          query[k] === null
        ) {
          usableQueryKeys.push(k);
        }
      });
      usableQueryKeys = _.intersection(usableQueryKeys, indexNames);
      if (usableQueryKeys.length > 0) {
        return cb(null, self.indexes[usableQueryKeys[0]].getMatching(query[usableQueryKeys[0]]));
      }

      // For a $in match
      usableQueryKeys = [];
      Object.keys(query).forEach(function(k) {
        if (query[k] && query[k].hasOwnProperty('$in')) {
          usableQueryKeys.push(k);
        }
      });
      usableQueryKeys = _.intersection(usableQueryKeys, indexNames);
      if (usableQueryKeys.length > 0) {
        return cb(
          null,
          self.indexes[usableQueryKeys[0]].getMatching(query[usableQueryKeys[0]].$in),
        );
      }

      // For a comparison match
      usableQueryKeys = [];
      Object.keys(query).forEach(function(k) {
        if (
          query[k] &&
          (query[k].hasOwnProperty('$lt') ||
            query[k].hasOwnProperty('$lte') ||
            query[k].hasOwnProperty('$gt') ||
            query[k].hasOwnProperty('$gte'))
        ) {
          usableQueryKeys.push(k);
        }
      });
      usableQueryKeys = _.intersection(usableQueryKeys, indexNames);
      if (usableQueryKeys.length > 0) {
        return cb(
          null,
          self.indexes[usableQueryKeys[0]].getBetweenBounds(query[usableQueryKeys[0]]),
        );
      }

      // By default, return all the DB data
      return cb(null, self.getAllData());
    }
31560
function () {
            var self = this,
                count = 0,
                _queryMap,
                k;
            parseQuery(self);
            _queryMap = self._queryMap;
            for (k in _queryMap) {

                if (S.isArray(_queryMap[k])) {
                    count += _queryMap[k].length;
                } else {
                    count++;
                }

            }
            return count;
        }
28036
public com.google.api.ads.adwords.axis.v201809.cm.Operand getResult() {
        return result;
    }
1012375
public final QueryParser.value_return value() throws RecognitionException {
        QueryParser.value_return retval = new QueryParser.value_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token String78=null;
        Token INT82=null;
        Token FLOAT83=null;
        QueryParser.t_return t79 = null;

        QueryParser.f_return f80 = null;

        QueryParser.nil_return nil81 = null;


        CommonTree String78_tree=null;
        CommonTree INT82_tree=null;
        CommonTree FLOAT83_tree=null;

        try {
            // src/riemann/Query.g:69:7: ( ( String | t | f | nil | INT | FLOAT ) )
            // src/riemann/Query.g:69:10: ( String | t | f | nil | INT | FLOAT )
            {
            root_0 = (CommonTree)adaptor.nil();

            // src/riemann/Query.g:69:10: ( String | t | f | nil | INT | FLOAT )
            int alt30=6;
            switch ( input.LA(1) ) {
            case String:
                {
                alt30=1;
                }
                break;
            case 27:
                {
                alt30=2;
                }
                break;
            case 28:
                {
                alt30=3;
                }
                break;
            case 29:
            case 30:
                {
                alt30=4;
                }
                break;
            case INT:
                {
                alt30=5;
                }
                break;
            case FLOAT:
                {
                alt30=6;
                }
                break;
            default:
                NoViableAltException nvae =
                    new NoViableAltException("", 30, 0, input);

                throw nvae;
            }

            switch (alt30) {
                case 1 :
                    // src/riemann/Query.g:69:11: String
                    {
                    String78=(Token)match(input,String,FOLLOW_String_in_value523); 
                    String78_tree = (CommonTree)adaptor.create(String78);
                    adaptor.addChild(root_0, String78_tree);


                    }
                    break;
                case 2 :
                    // src/riemann/Query.g:69:20: t
                    {
                    pushFollow(FOLLOW_t_in_value527);
                    t79=t();

                    state._fsp--;

                    adaptor.addChild(root_0, t79.getTree());

                    }
                    break;
                case 3 :
                    // src/riemann/Query.g:69:24: f
                    {
                    pushFollow(FOLLOW_f_in_value531);
                    f80=f();

                    state._fsp--;

                    adaptor.addChild(root_0, f80.getTree());

                    }
                    break;
                case 4 :
                    // src/riemann/Query.g:69:28: nil
                    {
                    pushFollow(FOLLOW_nil_in_value535);
                    nil81=nil();

                    state._fsp--;

                    adaptor.addChild(root_0, nil81.getTree());

                    }
                    break;
                case 5 :
                    // src/riemann/Query.g:69:34: INT
                    {
                    INT82=(Token)match(input,INT,FOLLOW_INT_in_value539); 
                    INT82_tree = (CommonTree)adaptor.create(INT82);
                    adaptor.addChild(root_0, INT82_tree);


                    }
                    break;
                case 6 :
                    // src/riemann/Query.g:69:40: FLOAT
                    {
                    FLOAT83=(Token)match(input,FLOAT,FOLLOW_FLOAT_in_value543); 
                    FLOAT83_tree = (CommonTree)adaptor.create(FLOAT83);
                    adaptor.addChild(root_0, FLOAT83_tree);


                    }
                    break;

            }


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
574731
public ExecutionResult toExecutionResult() {
        ExecutionResult executionResult = new ExecutionResultImpl(this);
        if (!this.getUnderlyingErrors().isEmpty()) {
            executionResult = new ExecutionResultImpl(this.getUnderlyingErrors());
        }
        return executionResult;
    }
709534
public int run() {
		try {
			
			if ( compile )
			{
				compile();
			}
			
			
			String separator = "/";
			String cpseperator = ":";
			if (System.getProperty("os.name").contains("indows")){
				separator = "\\";
				cpseperator = ";";
			}
			String s = fileName.replace(separator, ".");
			if ( ".java".equals(s.substring(s.length()-5)))
			{
				s = s.substring(0, s.length()-5); // .java Entfernen
			}
			else
			{
				s = s.substring(0, s.length() - 6); // .class entfernen
			}
			
			
			String localClasspath = classpath;
			if (compileFolder != null)
				localClasspath = localClasspath + cpseperator + compileFolder;
			String command = "java -cp "+localClasspath;
			if (libraryPath != null && libraryPath!= "")
				command += "-Djava.library.path="+libraryPath;
			command = command + " de.kopeme.testrunner.PerformanceTestRunner " + s;
			
//			System.out.println(command);
			Process p = Runtime.getRuntime().exec(command);
			BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
			String line;
			
			BufferedWriter bw = null;
//			System.out.println("ExternalOutputFile: " + externalOutputFile);
			if ( externalOutputFile != null && externalOutputFile != "")
			{
				File output = new File(externalOutputFile);
				try {
					bw = new BufferedWriter( new FileWriter(output));
				} catch (IOException e1) {
					// TODO Automatisch generierter Erfassungsblock
					e1.printStackTrace();
				}
			}
			
			
			while ( (line = br.readLine()) != null )
			{
				if ( bw == null)
				{
					System.out.println(line);
				}
				else
				{
					bw.write(line+"\n");
				}
			}
			
			br = new BufferedReader(new InputStreamReader(p.getErrorStream()));
			while ( (line = br.readLine()) != null )
			{
				if ( bw == null)
				{
					System.out.println(line);
				}
				else
				{
					bw.write(line+"\n");
				}
			}
			if ( bw != null )
				bw.close();
			int returnValue = p.waitFor();
//			System.out.println("Returnvalue: " + returnValue);
			return returnValue;
		} catch (IOException e) {
			// TODO Automatisch generierter Erfassungsblock
			e.printStackTrace();
		} catch (InterruptedException e) {
			// TODO Automatisch generierter Erfassungsblock
			e.printStackTrace();
		}
		return 1;
	}
9548
public <T> T get(String queryString, List<FieldAccumulator> accumulators, Object queryTypeDiscriminator, QueryCreator<T> queryCreator) {
      QueryCacheKey key = new QueryCacheKey(queryString, accumulators, queryTypeDiscriminator);
      return (T) getCache().computeIfAbsent(key, (k) -> queryCreator.create(k.queryString, k.accumulators));
   }
201484
public Number getNumber ()
    {
        String valstr = getText().length() == 0 ? "0" : getText();
        return _allowFloatingPoint ? (Number)(new Double(valstr)) : (Number)(new Long(valstr));
    }
244568
public DomainQueryResult execute() {
		DomainQueryResult ret = new DomainQueryResult(this);
		Object so = this.queryExecutor.getMappingInfo().getInternalDomainAccess().getSyncObject();
		if (so != null) {
			synchronized (so) {
				this.queryExecutor.execute();
			}
		} else
			this.queryExecutor.execute();
		return ret;
	}
933045
public void run() throws IllegalArgumentException {
        List<List<ResultEntry>> groups = null;

        for (int i = 0; i < this.repeatedRuns; ++i) {
            this.solver.getResult().clearResults();
            this.solver.run();
            Result result = this.solver.getResult();

            if (groups == null) {
                // create empty groups
                groups = new ArrayList<List<ResultEntry>>(result.getResultEntries().size());
                // allocate space in every group
                for (int j = 0; j < result.getResultEntries().size(); ++j) {
                    groups.add(new ArrayList<ResultEntry>(this.repeatedRuns));
                }
            }

            if (result.getResultEntries().size() != groups.size())
                throw new IllegalArgumentException(String.format(
                        "Wrapped solver must return result with identical number of elements each run, " +
                        "given %d in run %d, expected %d",
                        result.getResultEntries().size(), i, groups.size()));

            for (int j = 0; j < result.getResultEntries().size(); j++) {
                ResultEntry resultEntry = result.getResultEntries().get(j);

                groups.get(j).add(resultEntry);
            }
        }

        int middleIndex = this.repeatedRuns / 2;

        for (List<ResultEntry> group : groups) {
            Collections.sort(group, new ResultEntryFitnessComparator());

            if (this.logger.isDebugEnabled()) {
                this.logger.debug("Sorted result entries, dump:");
                for (int i = 0; i < group.size(); i++) {
                    ResultEntry resultEntry = group.get(i);
                    this.logger.debug(i + ". " + resultEntry.getBestFitness());
                }
            }

            this.getResult().addEntry(group.get(middleIndex));
        }


        if (this.file != null) {
            try {
                PrintStream printStream = new PrintStream(file);
                for (List<ResultEntry> group : groups) {
                    printStream.printf("Sorted entries for %s/%s\n", group.get(0).getAlgorithm(), group.get(0).getProblem());
                    for (int i = 0; i < group.size(); i++) {
                        printStream.printf("%03d. %.5f\n", i, group.get(i).getBestFitness());
                    }
                }
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
897608
@OperationsPerInvocation(SIZE)
	@Benchmark
	public int mseq_get() {
		int sum = 0;
		for (int i = 0; i < SIZE; ++i) {
			sum += mseq.get(i);
		}
		return sum;
	}
501745
public QueryHits evaluate(Query query) throws IOException
   {
      return evaluate(query, new Sort(), Integer.MAX_VALUE);
   }
245828
private Query computeQuery()
  {
    if (dataSource instanceof QueryDataSource) {
      // If there is a subquery then the outer query must be a groupBy.
      final GroupByQuery outerQuery = toGroupByQuery();

      if (outerQuery == null) {
        // Bug in the planner rules. They shouldn't allow this to happen.
        throw new IllegalStateException("Can't use QueryDataSource without an outer groupBy query!");
      }

      return outerQuery;
    }

    final TimeseriesQuery tsQuery = toTimeseriesQuery();
    if (tsQuery != null) {
      return tsQuery;
    }

    final TopNQuery topNQuery = toTopNQuery();
    if (topNQuery != null) {
      return topNQuery;
    }

    final GroupByQuery groupByQuery = toGroupByQuery();
    if (groupByQuery != null) {
      return groupByQuery;
    }

    final ScanQuery scanQuery = toScanQuery();
    if (scanQuery != null) {
      return scanQuery;
    }

    throw new CannotBuildQueryException("Cannot convert query parts into an actual query");
  }
887547
public String getAnswer() {
    if (OutputElement_Type.featOkTst && ((OutputElement_Type)jcasType).casFeat_answer == null)
      jcasType.jcas.throwFeatMissing("answer", "edu.cmu.lti.oaqa.framework.types.OutputElement");
    return jcasType.ll_cas.ll_getStringValue(addr, ((OutputElement_Type)jcasType).casFeatCode_answer);}
409473
public String run()
    {
		String locale = getLocale().getLanguage();

		SystemUnderTest sut = SystemUnderTest.newInstance(sutName);
		sut.setProject(Project.newInstance(sutProjectName));
		sut.setRunner(Runner.newInstance(""));

		Specification spec = Specification.newInstance(getPage().getTitle());

		try
		{
			spec.setRepository(gpUtil.getHomeRepository(spaceKey));

        	execution = gpUtil.getGPServerService().runSpecification(sut, spec, implemented, locale);
        } 
        catch (GreenPepperServerException e) 
        {
            execution = Execution.error(spec, sut, null, e.getId());
        }
        catch (Exception e) 
        {
            execution = Execution.error(spec, sut, null, ExceptionUtils.stackTrace(e, "<br>", 15));
        }
        
        return SUCCESS;
    }
739381
public int count() {
		Integer result = null;
		if (result == null) {
			SimpleQuery q = this.isKeysOnly()? this : this.clone().keysOnly();
			result = getDatastoreService().prepare(q.getQuery()).countEntities(fetchOptions);
		}
		return result;
	}