send CQL query request using data from tuple
164858
private void cqlQueryFromTuple(Map<String, ByteBuffer> key, Tuple t, int offset) throws IOException
    {
        for (int i = offset; i < t.size(); i++)
        {
            if (t.getType(i) == DataType.TUPLE)
            {
                Tuple inner = (Tuple) t.get(i);
                if (inner.size() > 0)
                {
                    List<ByteBuffer> bindedVariables = bindedVariablesFromTuple(inner);
                    if (bindedVariables.size() > 0)
                        sendCqlQuery(key, bindedVariables);
                    else
                        throw new IOException("Missing binded variables");
                }
            }
            else
            {
                throw new IOException("Output type was not a tuple");
            }
        }
    }
240534
function Query(server, query, options, token) {
  this.server = server;
  this.query = query;
  // Used to track the presence of r.args (workaround)
  this.originalQuery = util.deepCopy(query);
  this.options = {};
  this.context = {};
  this.frames = [];
  this.nowValue = ReqlDate.now();
  this.complete = false;
  this.token = token;

}
527726
function runQuery(query, connection) {
  let incomplete = false;
  const rows = [];
  const port = connection.port || 8080;
  const prestoConfig = {
    url: `http://${connection.host}:${port}`,
    user: connection.username,
    catalog: connection.prestoCatalog,
    schema: connection.prestoSchema
  };
  return presto.send(prestoConfig, query).then(result => {
    if (!result) {
      throw new Error('No result returned');
    }
    let { data, columns } = result;
    if (data.length > connection.maxRows) {
      incomplete = true;
      data = data.slice(0, connection.maxRows);
    }
    for (let r = 0; r < data.length; r++) {
      const row = {};
      for (let c = 0; c < columns.length; c++) {
        row[columns[c].name] = data[r][c];
      }
      rows.push(row);
    }
    return { rows, incomplete };
  });
}
95790
def execute_prepared_cql_query(self, itemId, values):
    
    self._seqid += 1
    d = self._reqs[self._seqid] = defer.Deferred()
    self.send_execute_prepared_cql_query(itemId, values)
    return d
1010012
def as_cql_query(self):
        
        options = dict(self.index_options)
        index_target = options.pop("target")
        if self.kind != "CUSTOM":
            return "CREATE INDEX %s ON %s.%s (%s)" % (
                protect_name(self.name),
                protect_name(self.keyspace_name),
                protect_name(self.table_name),
                index_target)
        else:
            class_name = options.pop("class_name")
            ret = "CREATE CUSTOM INDEX %s ON %s.%s (%s) USING '%s'" % (
                protect_name(self.name),
                protect_name(self.keyspace_name),
                protect_name(self.table_name),
                index_target,
                class_name)
            if options:
                # PYTHON-1008: `ret` will always be a unicode
                opts_cql_encoded = _encoder.cql_encode_all_types(options, as_text_type=True)
                ret += " WITH OPTIONS = %s" % opts_cql_encoded
            return ret
890321
def send_query(self, query):
        ''' '''
        if self.__switched_on:
            return self.__solr_server_connector.send_query(query)
        else:
            msg = 'Not sending query'
            LOGGER.debug(msg)
            raise esgfpid.exceptions.SolrSwitchedOff(msg)
1315863
def query(self, query):
        
        if query is None:
            raise ValueError("Invalid value for `query`, must not be `None`")
        if query is not None and len(query) > 1000:
            raise ValueError("Invalid value for `query`, length must be less than or equal to `1000`")

        self._query = query
645378
def query(self, query, num=0, silent=False):
        
        if self.srv is None:
            raise KrnlException('no endpoint defined')

        # Add to the query all predefined SPARQL prefixes
        if self.cfg.pfx:
            prefix = '\n'.join(('PREFIX {} {}'.format(*v)
                                for v in self.cfg.pfx.items()))
            query = prefix + '\n' + query

        # Prepend to the query all predefined Header entries
        # The header should be before the prefix and other sparql commands
        if self.cfg.hdr:
            query = '\n'.join(self.cfg.hdr) + '\n' + query

        if self.log.isEnabledFor(logging.DEBUG):
            self.log.debug("\n%50s%s", query, '...' if len(query) > 50 else '')

        # Select requested format
        if self.cfg.fmt is not None:
            fmt_req = self.cfg.fmt
        elif re.search(r'\bselect\b', query, re.I):
            fmt_req = SPARQLWrapper.JSON
        elif re.search(r'\b(?:describe|construct)\b', query, re.I):
            fmt_req = SPARQLWrapper.N3
        else:
            fmt_req = False

        # Set the query
        self.srv.resetQuery()
        if self.cfg.aut:
            self.srv.setHTTPAuth(self.cfg.aut[0])
            self.srv.setCredentials(*self.cfg.aut[1:])
        else:
            self.srv.setCredentials(None, None)
        self.log.debug(u'request-format: %s  display: %s', fmt_req, self.cfg.dis)
        if fmt_req:
            self.srv.setReturnFormat(fmt_req)
        if self.cfg.grh:
            self.srv.addParameter("default-graph-uri", self.cfg.grh)
        for p in self.cfg.par.items():
            self.srv.addParameter(*p)
        self.srv.setQuery(query)

        if not silent or self.cfg.out:
            try:
                # Launch query
                start = datetime.datetime.utcnow()
                res = self.srv.query()
                now = datetime.datetime.utcnow()
                self.log.debug(u'response elapsed=%s', now-start)
                start = now

                # See what we got
                info = res.info()
                self.log.debug(u'response info: %s', info)
                fmt_got = info['content-type'].split(';')[0] if 'content-type' in info else None

                # Check we received a MIME type according to what we requested
                if fmt_req and fmt_got not in mime_type[fmt_req]:
                    raise KrnlException(u'Unexpected response format: {} (requested: {})', fmt_got, fmt_req)

                # Get the result
                data = b''.join((line for line in res))

            except KrnlException:
                raise
            except SPARQLWrapperException as e:
                raise KrnlException(u'SPARQL error: {}', touc(e))
            except Exception as e:
                raise KrnlException(u'Query processing error: {!s}', e)

            # Write the raw result to a file
            if self.cfg.out:
                try:
                    outname = self.cfg.out % num
                except TypeError:
                    outname = self.cfg.out
                with io.open(outname, 'wb') as f:
                    f.write(data)

            # Render the result into the desired display format
            try:
                # Data format we will render
                fmt = (fmt_req if fmt_req else
                       SPARQLWrapper.JSON if fmt_got in mime_type[SPARQLWrapper.JSON] else
                       SPARQLWrapper.N3 if fmt_got in mime_type[SPARQLWrapper.N3] else
                       SPARQLWrapper.XML if fmt_got in mime_type[SPARQLWrapper.XML] else
                       'text/plain' if self.cfg.dis == 'raw' else
                       fmt_got if fmt_got in ('text/plain', 'text/html') else
                       'text/plain')
                #self.log.debug(u'format: req=%s got=%s rend=%s',fmt_req,fmt_got,fmt)

                # Can't process? Just write the data as is
                if fmt in ('text/plain', 'text/html'):
                    out = data.decode('utf-8') if isinstance(data, bytes) else data
                    r = {'data': {fmt: out}, 'metadata': {}}
                else:
                    f = render_json if fmt == SPARQLWrapper.JSON else render_xml if fmt == SPARQLWrapper.XML else render_graph
                    r = f(data, self.cfg, format=fmt_got)
                    now = datetime.datetime.utcnow()
                    self.log.debug(u'response formatted=%s', now-start)
                if not silent:
                    return r

            except Exception as e:
                raise KrnlException(u'Response processing error: {}', touc(e))
1373543
def _send_queries(self):
        

        res = 0

        addrs = _resolve_addrs(self.addresses, self.port, self.ignore_senderrors, [self._sock.family])
        for addr in addrs:
            try:
                self._send_query(addr[1])
                res += 1
            except:
                if not self.ignore_senderrors:
                    raise

        return res
522245
def coords_from_query(query):
    """"""
    try:
        coords = json.loads(query)
    except ValueError:
        query = query.replace(',', ' ')
        vals = query.split()
        coords = [float(v) for v in vals]
    return tuple(coords[:2])
784149
def gql(query_string, *args, **kwds):
  
  qry = _gql(query_string)
  if args or kwds:
    qry = qry._bind(args, kwds)
  return qry
421112
def query(query, args_or_dbname, params = {})
      query = transmute_data(query)
      args = args_or_dbname.is_a?(String) ? [db_alias(args_or_dbname)] : args_or_dbname
      args = transmute_data(args)
      get root_url("api/query"), params.merge(:q => query, :args => args)
    end
803049
def query_value(stmt, args=(), default=None):
    
    for row in query(stmt, args, TupleFactory):
        return row[0]
    return default
575667
def prepare_cql3_query(self, query, compression):
    
    self._seqid += 1
    d = self._reqs[self._seqid] = defer.Deferred()
    self.send_prepare_cql3_query(query, compression)
    return d
440384
async def _request(self, method: str, url: str, headers: Mapping[str, str],
                       body: bytes = b'') -> Tuple[int, Mapping[str, str], bytes]:
        """"""
266161
def _gql(cls, query_string, *args, **kwds):
    """"""
    from .query import gql  # Import late to avoid circular imports.
    return gql('SELECT * FROM %s %s' % (cls._class_name(), query_string),
               *args, **kwds)
258840
def send_request_if_needed(request, relation='ceph'):
    
    if is_request_sent(request, relation=relation):
        log('Request already sent but not complete, not sending new request',
            level=DEBUG)
    else:
        for rid in relation_ids(relation):
            log('Sending request {}'.format(request.request_id), level=DEBUG)
            relation_set(relation_id=rid, broker_req=request.request)