Common interface to Query, Insert , Delete, Drop(but not coordinator commands).
@param sqlOrJsonQuery
@param namedParams
@param reqHeaders
@param printToConsole
@param queryMode
@return
765128
public Either<String, Either<Joiner4All, Mapper4All>> query(String sqlOrJsonQuery, NamedParameters namedParams, Map<String, String> reqHeaders, boolean printToConsole, String queryMode) {
        return query(sqlOrJsonQuery, namedParams, reqHeaders, printToConsole, queryMode, false);
    }
668440
public JSONObject multipleQueries(List<IndexQuery> queries, RequestOptions requestOptions) throws AlgoliaException {
    return multipleQueries(queries, "none", requestOptions);
  }
783980
public void deleteByQuery(String index, String type) throws IOException {
        logger.debug("deleteByQuery [{}]/[{}]", index, type);

        String deleteByQuery = "{\n" +
                "  \"query\": {\n" +
                "    \"match_all\": {}\n" +
                "  }\n" +
                "}";

        Request request = new Request("POST", "/" + index + "/" + type + "/_delete_by_query");
        request.setJsonEntity(deleteByQuery);
        Response restResponse = client.getLowLevelClient().performRequest(request);
        Map<String, Object> response = asMap(restResponse);
        logger.debug("reindex response: {}", response);
    }
1219519
public void execute(final TSDB tsdb, final HttpQuery query) {
    // only accept GET/POST
    if (query.method() != HttpMethod.GET && query.method() != HttpMethod.POST) {
      throw new BadRequestException(HttpResponseStatus.METHOD_NOT_ALLOWED, 
          "Method not allowed", "The HTTP method [" + query.method().getName() +
          "] is not permitted for this endpoint");
    }
    
    try {
      final String[] uri = query.explodeAPIPath();
      final String endpoint = uri.length > 1 ? uri[1].toLowerCase() : "";

      // Handle /threads and /regions.
      if ("threads".equals(endpoint)) {
        printThreadStats(query);
        return;
      } else if ("jvm".equals(endpoint)) {
        printJVMStats(tsdb, query);
        return;
      } else if ("query".equals(endpoint)) {
        printQueryStats(query);
        return;
      } else if ("region_clients".equals(endpoint)) {
        printRegionClientStats(tsdb, query);
        return;
      }
    } catch (IllegalArgumentException e) {
      // this is thrown if the url doesn't start with /api. To maintain backwards
      // compatibility with the /stats endpoint we can catch and continue here.
    }
    
    final boolean canonical = tsdb.getConfig().getBoolean("tsd.stats.canonical");
    
    // if we don't have an API request we need to respond with the 1.x version
    if (query.apiVersion() < 1) {
      final boolean json = query.hasQueryStringParam("json");
      final StringBuilder buf = json ? null : new StringBuilder(2048);
      final ArrayList<String> stats = json ? new ArrayList<String>(64) : null;
      final ASCIICollector collector = new ASCIICollector("tsd", buf, stats);
      doCollectStats(tsdb, collector, canonical);
      if (json) {
        query.sendReply(JSON.serializeToBytes(stats));
      } else {
        query.sendReply(buf);
      }
      return;
    }
    
    // we have an API version, so go newschool
    final List<IncomingDataPoint> dps = new ArrayList<IncomingDataPoint>(64);
    final SerializerCollector collector = new SerializerCollector("tsd", dps, 
        canonical);
    ConnectionManager.collectStats(collector);
    RpcHandler.collectStats(collector);
    RpcManager.collectStats(collector);
    tsdb.collectStats(collector);
    query.sendReply(query.serializer().formatStatsV1(dps));
  }
85855
private void printQueryStats(final HttpQuery query) {
    switch (query.apiVersion()) {
    case 0:
    case 1:
      query.sendReply(query.serializer().formatQueryStatsV1(
          QueryStats.getRunningAndCompleteStats()));
      break;
    default: 
      throw new BadRequestException(HttpResponseStatus.NOT_IMPLEMENTED, 
          "Requested API version not implemented", "Version " + 
          query.apiVersion() + " is not implemented");
    }
  }
949608
private QueryResponse getQueryResponse(JsonNode jsonNode) throws IOException {
		ObjectMapper mapper = new ObjectMapper();

		SimpleModule simpleModule = new SimpleModule("QueryResponseDeserializer", new Version(1, 0, 0, null));
		simpleModule.addDeserializer(QueryResponse.class, new QueryResponseDeserializer());

		mapper.registerModule(simpleModule);

		return mapper.treeToValue(jsonNode, QueryResponse.class);
	}
1370204
public JSONObject search(Query params, RequestOptions requestOptions) throws AlgoliaException {
    String paramsString = params.getQueryString();
    JSONObject body = new JSONObject();
    try {
      body.put("params", paramsString);
    } catch (JSONException e) {
      throw new RuntimeException(e);
    }
    return client.postRequest("/1/indexes/" + encodedIndexName + "/query", body.toString(), false, true, requestOptions);
  }
175400
public Map getSingleInfoServiceByRep(String sql,Map requestParamMap) throws Exception{
		List placeList=new ArrayList();
		sqlTemplateService(sql,requestParamMap,placeList);
		String realSql=sqlTemplateService(sql,requestParamMap,placeList);;
		Map retMap= getInnerDao().querySingleObjJoinByCondition(realSql,placeList.toArray());
		CheckModelTypeUtil.addMetaCols(retMap);
		CheckModelTypeUtil.changeNoStrCols(retMap);	
		return retMap;		
	}
844084
public ApiResponse<Integer> executeDeletePostWithHttpInfo(Query query) throws ApiException {
        com.squareup.okhttp.Call call = executeDeletePostValidateBeforeCall(query, null, null);
        Type localVarReturnType = new TypeToken<Integer>(){}.getType();
        return apiClient.execute(call, localVarReturnType);
    }
231532
public static Query toQuery(Object o, boolean duplicate) throws PageException {

	if (o instanceof Query) {
	    if (duplicate) {
		Query src = (Query) o;
		Query trg = new QueryImpl(src.getColumnNames(), src.getRowCount(), "query");

		Collection.Key[] keys = src.getColumnNames();
		QueryColumn[] columnsSrc = new QueryColumn[keys.length];
		for (int i = 0; i < columnsSrc.length; i++) {
		    columnsSrc[i] = src.getColumn(keys[i]);
		}

		keys = trg.getColumnNames();
		QueryColumn[] columnsTrg = new QueryColumn[keys.length];
		for (int i = 0; i < columnsTrg.length; i++) {
		    columnsTrg[i] = trg.getColumn(keys[i]);
		}

		int i;
		for (int row = trg.getRecordcount(); row > 0; row--) {
		    for (i = 0; i < columnsTrg.length; i++) {
			columnsTrg[i].set(row, columnsSrc[i].get(row, null));
		    }
		}
		return trg;
	    }
	    return (Query) o;
	}
	else if (o instanceof ObjectWrap) {
	    return toQuery(((ObjectWrap) o).getEmbededObject(), duplicate);
	}
	throw new CasterException(o, "query");
    }
871447
@RequirePOST
    public synchronized void doConfigSubmit(StaplerRequest req,
            StaplerResponse rsp) throws IOException, ServletException, FormException {
        checkPermission(CONFIGURE);

        description = req.getParameter("description");

        JSONObject json = req.getSubmittedForm();

        try {
            try (BulkChange bc = new BulkChange(this)) {
                setDisplayName(json.optString("displayNameOrNull"));

                logRotator = null;

                DescribableList<JobProperty<?>, JobPropertyDescriptor> t = new DescribableList<>(NOOP, getAllProperties());
                JSONObject jsonProperties = json.optJSONObject("properties");
                if (jsonProperties != null) {
                  t.rebuild(req,jsonProperties,JobPropertyDescriptor.getPropertyDescriptors(Job.this.getClass()));
                } else {
                  t.clear();
                }
                properties.clear();
                for (JobProperty p : t) {
                    p.setOwner(this);
                    properties.add(p);
                }

                submit(req, rsp);
                bc.commit();
            }
            ItemListener.fireOnUpdated(this);

            final ProjectNamingStrategy namingStrategy = Jenkins.getInstance().getProjectNamingStrategy();
                if(namingStrategy.isForceExistingJobs()){
                    namingStrategy.checkName(name);
                }
                FormApply.success(".").generateResponse(req, rsp, null);
        } catch (JSONException e) {
            LOGGER.log(Level.WARNING, "failed to parse " + json, e);
            sendError(e, req, rsp);
        }
    }
685608
@Override
    public QueryDefinition registerQuery(QueryDefinition queryDefinition) {
        QueryDefinition result = null;
        if (config.isRest()) {

            Map<String, Object> valuesMap = new HashMap<String, Object>();
            valuesMap.put(QUERY_NAME, queryDefinition.getName());

            result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + CREATE_QUERY_DEF_POST_URI, valuesMap), queryDefinition, QueryDefinition.class);

        } else {
            CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "registerQuery", serialize(queryDefinition), marshaller.getFormat().getType(), new Object[]{queryDefinition.getName()})));
            ServiceResponse<QueryDefinition> response = (ServiceResponse<QueryDefinition>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);

            throwExceptionOnFailure(response);
            if (shouldReturnWithNullResponse(response)) {
                return null;
            }
            result = response.getResult();
        }

        return result;
    }
850290
public void runQueries() throws Exception {

        System.out.println();
        System.out.println("Running Queries: ");
        System.out.println();

        // Specify, run and print the queries (and their results), one at a time
        runQuery("Select some login sessions - just a small portion of the data (limit results to 10):",
                 "SELECT username, json_data FROM user_session_table ORDER BY username LIMIT 10");
        runQuery("Select some login sessions that have been made to the VoltDB Forum, using 'field' (limit results to 10):",
                 "SELECT username, field(json_data,'site') AS site, json_data FROM user_session_table "
                 + "WHERE field(json_data, 'site')='VoltDB Forum' ORDER BY username LIMIT 10");

        runQuery("Select VoltDB Forum sessions that are moderators (at most 10), using 'field' multiple times:",
                 "SELECT username, field(json_data,'moderator') AS moderator, json_data FROM user_session_table "
                 + "WHERE field(json_data, 'site')='VoltDB Forum' AND field(json_data, 'moderator')='true' ORDER BY username LIMIT 10");
        runQuery("Change user 'voltdb' to be a moderator, using 'set_field':",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'moderator', 'true') "
                 + "WHERE username='voltdb'");
        runQuery("Select VoltDB Forum sessions that are moderators (again, after update):",
                 "SELECT username, field(json_data,'moderator') AS moderator, json_data FROM user_session_table "
                 + "WHERE field(json_data, 'site')='VoltDB Forum' AND field(json_data, 'moderator')='true' ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Forum) logins with a download_count larger than one:",
                 "SELECT username, field(json_data,'download_count') AS download_count, json_data FROM user_session_table "
                 + "WHERE cast(field(json_data,'download_count') AS INTEGER) > 1 ORDER BY username LIMIT 10");

        runQuery("User pattern matching (SQL LIKE) to look for records of (VoltDB Forum) logins who have downloaded version v2.x "
                 + "- the old way, using nested calls of 'field':",
                 "SELECT username, field(field(json_data,'props'), 'download_version') AS download_version, json_data FROM user_session_table "
                 + "WHERE field(field(json_data,'props'), 'download_version') LIKE 'v2%' ORDER BY username LIMIT 10");
        runQuery("Identical query (logins who have downloaded version v2.x), using newer, simpler dot notation, rather than 'field' twice:",
                 "SELECT username, field(json_data,'props.download_version') AS download_version, json_data FROM user_session_table "
                 + "WHERE field(json_data, 'props.download_version') LIKE 'v2%' ORDER BY username LIMIT 10");
        runQuery("Change several users to set 'props.download_version' to 'v2.9', using 'set_field' with dot notation:",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'props.download_version', '\"v2.9\"') "
                 + "WHERE username < 'user-10000'");
        runQuery("User pattern matching (SQL LIKE) to look for records of (VoltDB Forum??) logins who have downloaded "
                 + "version v2.x (again, after update):",
                 "SELECT username, field(json_data,'props.download_version') AS download_version, json_data FROM user_session_table "
                 + "WHERE field(json_data, 'props.download_version') LIKE 'v2%' ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Blog) logins whose first role is 'writer' - the old way, using 'array_element':",
                 "SELECT username, array_element(field(json_data,'roles'), 0) AS first_role, json_data FROM user_session_table "
                 + "WHERE array_element(field(json_data,'roles'), 0)='writer' ORDER BY username LIMIT 10");
        runQuery("Identical query (logins whose first role is 'writer'), using newer, simpler bracket notation, "
                 + "rather than 'array_element':",
                 "SELECT username, field(json_data,'roles[0]') AS first_role, json_data FROM user_session_table "
                 + "WHERE field(json_data,'roles[0]')='writer' ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Blog) logins that have more than one role, using 'array_length':",
                 "SELECT username, field(json_data,'roles[0]') AS first_role, field(json_data,'roles[1]') AS second_role, "
                 + "field(json_data,'roles[2]') AS third_role, json_data FROM user_session_table "
                 + "WHERE array_length(field(json_data,'roles')) > 1 ORDER BY username LIMIT 10");
        runQuery("Change user voltdb2's first role to be 'author' (to match the others), using 'set_field' with bracket notation:",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'roles[0]', '\"author\"') "
                 + "WHERE username='voltdb2'");
        runQuery("Add an additional role to user 'voltdb2': 'administrator', using 'set_field' with [-1] to mean beyond the last:",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'roles[-1]', '\"administrator\"') "
                 + "WHERE username='voltdb2'");
        runQuery("Select records of (VoltDB Blog) logins that have more than one role (again, after updates):",
                 "SELECT username, field(json_data,'roles[0]') AS first_role, field(json_data,'roles[1]') AS second_role, "
                 + "field(json_data,'roles[2]') AS third_role, json_data FROM user_session_table "
                 + "WHERE array_length(field(json_data,'roles')) > 1 ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Blog) logins whose last role is 'administrator', using 'field' with [-1] to mean the last:",
                 "SELECT username, field(json_data,'roles[-1]') AS last_role, json_data FROM user_session_table "
                 + "WHERE field(json_data,'roles[-1]')='administrator' ORDER BY username LIMIT 10");

        runQuery("Look deep into the JSON data for records of (VoltDB Forum) logins who have downloaded version v3.0 and "
                 + "have specified a (first) client language of Java (combines dot and bracket notation):",
                 "SELECT username, json_data FROM user_session_table "
                 + "WHERE field(json_data, 'props.download_version')='v3.0' and field(json_data, 'props.client_languages[0]')='Java' "
                 + "ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Forum) logins that have more than one client language (combines "
                 + "'array_length' and 'field' with dot notation):",
                 "SELECT username, field(json_data,'props.client_languages') AS client_languages, json_data FROM user_session_table "
                 + "WHERE array_length(field(json_data,'props.client_languages')) > 1 ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Forum) logins whose second client language is Java:",
                 "SELECT username, field(json_data,'props.client_languages') AS client_languages, json_data FROM user_session_table "
                 + "WHERE field(json_data,'props.client_languages[1]')='Java' ORDER BY username LIMIT 10");
        runQuery("Change user voltdb's second client language to be 'Java' (to match):",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'props.client_languages[1]', '\"Java\"') "
                 + "WHERE username='voltdb'");
        runQuery("Change user voltdb's third client language to be 'Ruby':",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'props.client_languages[2]', '\"Ruby\"') "
                 + "WHERE username='voltdb'");
        runQuery("Select records of (VoltDB Forum) logins whose second client language is Java (again, after updates):",
                 "SELECT username, field(json_data,'props.client_languages') AS client_languages, json_data FROM user_session_table "
                 + "WHERE field(json_data,'props.client_languages[1]')='Java' ORDER BY username LIMIT 10");
        runQuery("Add an additional client language to user 'voltdb': 'Python' (using 'set_field', combines dot and "
                 + "bracket notation, with [-1]):",
                 "UPDATE user_session_table SET json_data = set_field(json_data, 'props.client_languages[-1]', '\"Python\"') "
                 + "WHERE username='voltdb'");
        runQuery("Select records of (VoltDB Forum) logins whose second client language is Java (again, after one more update):",
                 "SELECT username, field(json_data,'props.client_languages') AS client_languages, json_data FROM user_session_table "
                 + "WHERE field(json_data,'props.client_languages[1]')='Java' ORDER BY username LIMIT 10");

        runQuery("Select records of (VoltDB Blog) logins whose last client language is 'Python' (using 'field', combines "
                 + "dot and bracket notation, with [-1]):",
                 "SELECT username, field(json_data,'props.client_languages') AS client_languages, json_data FROM user_session_table "
                 + "WHERE field(json_data,'props.client_languages[-1]')='Python' ORDER BY username LIMIT 10");

        // Display the whole query results as a JSON String
        String SQL = "SELECT json_data FROM user_session_table WHERE username='voltdb' OR username='voltdb2' ORDER BY username";
        VoltTable table = runQuery("Retrieve the JSON data for two particular logins. Treat the whole result set as JSON:", SQL);
        System.out.println("The whole result set as JSON:");
        System.out.println(table.toJSONString());
        System.out.println();

        // Display individual results as JSON
        table = runQuery("Retrieve the JSON data for two particular logins. Just grab a JSON value from the result:", SQL);
        table.advanceRow();
        System.out.println("JSON value from result's first tuple:");
        System.out.println(table.get("json_data", VoltType.STRING));
        System.out.println();
        table.advanceRow();
        System.out.println("JSON value from result's second tuple:");
        System.out.println(table.get("json_data", VoltType.STRING));
        System.out.println();
    }
1212213
@Deprecated
  public void deleteByQuery(Query query, RequestOptions requestOptions) throws AlgoliaException {
    this.deleteByQuery(query, 100000, requestOptions);
  }
559538
public static <T> T query(Connection conn, String sql, RsHandler<T> rsh, Map<String, Object> paramMap) throws SQLException {
		final NamedSql namedSql = new NamedSql(sql, paramMap);
		return query(conn, namedSql.getSql(), rsh, namedSql.getParams());
	}
787599
private void addWhere4QueryPrint(final QueryPrint _print)
        throws CacheReloadException
    {
        final Filter filter = _print.getFilter();
        filter.append2SQLSelect(sqlSelect);
    }
498207
protected CmsAlias internalReadAlias(ResultSet resultset) throws SQLException {

        String siteRoot = resultset.getString(1);
        String path = resultset.getString(2);
        int mode = resultset.getInt(3);
        String structId = resultset.getString(4);
        return new CmsAlias(new CmsUUID(structId), siteRoot, path, CmsAliasMode.fromInt(mode));
    }