Returns the query result set iterator, executing the query if needed
352328
private function _resultSet()
    {
        if (!isset($this->_resultSet)) {
            foreach ($this->_before as $callback) {
                $callback($this->_query);
            }
            $this->_resultSet = $this->_query->execute();
        }

        return $this->_resultSet;
    }
1335592
def query(self):
        
        query = QueryBuilder(self, self._query_grammar, self._post_processor)

        return query
605564
function ResultSet(conn, query, values, options, rs) {
  this.query = query;
  this.metadata = rs.metadata;
  this.rows = rs.rows;
  this._conn = conn;
  this._values = values;
  this._options = options;
}
1213521
public ResultSet execute(String keyspace, @NotNull String query) {
        getMetricsFactory().getCounter(MetricsType.CASSANDRA_QUERIES_COUNT.name()).inc();

        Timer time = getMetricsFactory().getTimer(MetricsType.CASSANDRA_EXECUTE.name());

        ResultSet resultSet = getOrCreateSession(keyspace).execute(query);
        time.stop();

        return resultSet;
    }
586320
def fetch_result_sets(cls, db, datasource_type):
        
        result_set_df = db.get_df(
            """SELECT table_schema, table_name FROM INFORMATION_SCHEMA.{}S
               ORDER BY concat(table_schema, '.', table_name)""".format(
                datasource_type.upper(),
            ),
            None)
        result_sets = []
        for unused, row in result_set_df.iterrows():
            result_sets.append('{}.{}'.format(
                row['table_schema'], row['table_name']))
        return result_sets
1105379
@Override
    public Iterator iterate()
    {
        EntityMetadata m = getEntityMetadata();
        Client client = persistenceDelegeator.getClient(m);
        return new ResultIterator((MongoDBClient) client, m,
                createMongoQuery(m, getKunderaQuery().getFilterClauseQueue()), getOrderByClause(m),
                getKeys(m, getKunderaQuery().getResult()), persistenceDelegeator,
                getFetchSize() != null ? getFetchSize() : this.maxResult);
    }
314121
public Iterator<QueryParameters> iterator() {
        final QueryParametersLazyList source = this;

        return new Iterator<QueryParameters>() {
            private LazyCacheIterator<QueryParameters> lazyCacheIterator = source.getLazyCacheIterator(-1);

            public boolean hasNext() {
                return lazyCacheIterator.hasNext();
            }

            public QueryParameters next() {
                return lazyCacheIterator.getNext();
            }

            public void remove() {
                source.remove(currentIndex);
            }
        };
    }
186937
def _get_query_result(query, raw_result, **kwargs):
        
        if raw_result:
            return query(**kwargs)
        if kwargs:
            return QueryResult(query, **kwargs)

        return query.result
1030389
private ResultSet getNextResultSet() throws SQLException {
        ResultSet result = null;

        while (stmt.getMoreResults() == true) {

            // when gerMoreResults are returned - some drivers close previous ResultSets - therefore we cannot read them again.
            if (this.type == Type.UPDATE_SCROLL || this.type == Type.READ_ONLY_SCROLL) {
                throw new MjdbcSQLException("Lazy cache scroll does not support Multiple ResultSets. Pleae use" +
                        "non-scrollable lazy handlers or cached output handlers.");
            }

            if (closedResultSet.contains(result) == false) {
                result = stmt.getResultSet();
                break;
            }
        }

        return result;
    }
766434
public ResultSet getResultSet(int iType)
    {
        switch (iType)
        {
            case DBConstants.SQL_SEEK_TYPE:
                if (!SHARE_STATEMENTS)
                    return m_seekResultSet;
            case DBConstants.SQL_SELECT_TYPE:
            case DBConstants.SQL_CREATE_TYPE:
                return m_selectResultSet;
            case DBConstants.SQL_AUTOSEQUENCE_TYPE:
                return m_autoSequenceResultSet;
            case DBConstants.SQL_UPDATE_TYPE:
            case DBConstants.SQL_INSERT_TABLE_TYPE:
            case DBConstants.SQL_DELETE_TYPE:
            default:  // Never
                break;
        }
        return null;
    }
394735
def get(self, limit=None, page=None):
        
        has_more = False
        self.bounds.paginate = True
        limit_paginate, offset = self.bounds.get(limit, page)
        self.default_val = []
        results = self._query('get')

        if limit_paginate:
            self.bounds.paginate = False
            if len(results) == limit_paginate:
                has_more = True
                results.pop(-1)

        it = ResultsIterator(results, orm_class=self.orm_class, has_more=has_more, query=self)
        return self.iterator_class(it)
668790
@Override
    public synchronized List<Map<String, ResultColumn>> query(final String query) throws DatabaseEngineException {
        return processResultIterator(iterator(query));
    }
1071660
def iter_query(query):
    """"""
    try:
        itr = click.open_file(query).readlines()
    except IOError:
        itr = [query]
    return itr
1062592
@Override
    public Iterator<Row<K, C>> iterator() {
        return new Iterator<Row<K, C>>() {
            private KeyRange range;
            private org.apache.cassandra.thrift.KeySlice lastRow;
            private List<org.apache.cassandra.thrift.KeySlice> list = null;
            private Iterator<org.apache.cassandra.thrift.KeySlice> iter = null;
            private boolean bContinueSearch = true;
            private boolean bIgnoreTombstones = true;

            {
	            String startToken = query.getStartToken() == null ? partitioner.getMinToken() : query.getStartToken();
	            String endToken = query.getEndToken() == null ? partitioner.getMaxToken() : query.getEndToken();

                range = new KeyRange()
                        .setCount(query.getBlockSize())
                        .setStart_token(startToken)
                        .setEnd_token(endToken);
                
                if (query.getIncludeEmptyRows() == null) {
                    if (query.getPredicate().isSetSlice_range() && query.getPredicate().getSlice_range().getCount() == 0) {
                        bIgnoreTombstones = false;
                    }
                }
                else {
                    bIgnoreTombstones = !query.getIncludeEmptyRows();
                }
            }

            @Override
            public boolean hasNext() {
                // Get the next block
                while (iter == null || (!iter.hasNext() && bContinueSearch)) {
                    if (lastRow != null) {
                        // Determine the start token for the next page
                        String token = partitioner.getTokenForKey(ByteBuffer.wrap(lastRow.getKey()));
                        if (query.getRepeatLastToken()) {
                            // Start token is non-inclusive
                            range.setStart_token(partitioner.getTokenMinusOne(token));
                        }
                        else {
                            range.setStart_token(token);
                        }
                    }

                    // Get the next block of rows from cassandra, exit if none returned
                    list = query.getNextBlock(range);
                    if (list == null || list.isEmpty()) {
                        return false;
                    }
                    
                    // Since we may trim tombstones set a flag indicating whether a complete
                    // block was returned so we can know to try to fetch the next one
                    bContinueSearch = (list.size() == query.getBlockSize());

                    // Trim the list from tombstoned rows, i.e. rows with no columns
                    iter = list.iterator();
                    if (iter == null || !iter.hasNext()) {
                        return false;
                    }

                    KeySlice previousLastRow = lastRow;
                    lastRow = Iterables.getLast(list);
                    
                    if (query.getRepeatLastToken() && previousLastRow != null) {
                        iter.next();
                        iter.remove();
                    }
                    
                    if (iter.hasNext() && bIgnoreTombstones) {
                        // Discard any tombstones
                        while (iter.hasNext()) {
                            KeySlice row = iter.next();
                            if (row.getColumns().isEmpty()) {
                                iter.remove();
                            }
                        }
                        
                        // Get the iterator again
                        iter = list.iterator();
                    }
                }
                return iter.hasNext();
            }

            @Override
            public Row<K, C> next() {
                org.apache.cassandra.thrift.KeySlice row = iter.next();
                return new ThriftRowImpl<K, C>(columnFamily.getKeySerializer().fromBytes(row.getKey()),
                        ByteBuffer.wrap(row.getKey()), new ThriftColumnOrSuperColumnListImpl<C>(row.getColumns(),
                                columnFamily.getColumnSerializer()));
            }

            @Override
            public void remove() {
                throw new IllegalStateException();
            }
        };
    }
649908
protected void iterateResult(ResultSet resSet, QueryResultTO resultTO, StatementTO statementTO) {
		
		try {
			if (resSet != null && !resSet.isClosed()) {
	    		ResultSetMetaData metaData = resSet.getMetaData();
			    int cols = metaData.getColumnCount();
			    Map<Integer, Integer> type = new HashMap<Integer, Integer>();
			    
			    List<String> columnsNames = new ArrayList<>();
			    
			    for (int i = 1; i < (cols+1); i++)
			    {
			    	String colName = metaData.getColumnName(i);
			    	columnsNames.add(colName);
			    	type.put(i, metaData.getColumnType(i));
			    }
			   
			    List<List<String>> tableResult = new ArrayList<>();
			    String clobEncoding = statementTO.getClobEncoding() != null ? statementTO.getClobEncoding() : DEFAULT_CLOB_ENCODING;
		        while (resSet.next())
			    {
		        	List<String> row = new ArrayList<>();
		        	for (int i = 1; i < (cols+1); i++)
		    	    {
		            	if (type.get(i) != null && type.get(i) == Types.BLOB) {
		            		if (statementTO.isShowBlobs()) {
		            			row.add(String.valueOf(new String(resSet.getBytes(i))));
			                } else {
			                	row.add(String.valueOf(resSet.getObject(i)));
			                }
		            	} else if (type.get(i) != null && type.get(i) == Types.CLOB) {
		            		if (statementTO.isShowClobs()) {
		            			row.add(getClobString(resSet.getClob(i), clobEncoding ));
		            		} else {
		            			row.add("CLOB content");
		            		}
		            	} else {
		            		row.add(String.valueOf(resSet.getObject(i)));
		            	}
		    	    }
		        	tableResult.add(row);
			    }
		        
		        resultTO.setSqlWarnings(null != resSet.getWarnings() ? resSet.getWarnings().toString() : null);
		        
		        resultTO.setAffectedRows(tableResult.size());
		        resultTO.setColumnsNames(columnsNames);
		        resultTO.setTableResult(tableResult);
	    	} else {
	    		resultTO.setSqlWarnings("resultSet was " + (null != resSet ? "closed already" : "null"));
	    	}
	        resultTO.setSelect(true);
	        
		} catch (Exception e) {
			resultTO.setExceptionMessage(e.getMessage());
			resultTO.setExceptionCause(null != e.getCause() ? e.getCause().toString() : null);
			resultTO.setExceptionTrace(printException(e));
		}
	}
492821
def query(self, query, fetchall=False, **params):
        

        # Execute the given query.
        cursor = self._conn.execute(text(query), **params) # TODO: PARAMS GO HERE

        # Row-by-row Record generator.
        row_gen = (Record(cursor.keys(), row) for row in cursor)

        # Convert psycopg2 results to RecordCollection.
        results = RecordCollection(row_gen)

        # Fetch all results if desired.
        if fetchall:
            results.all()

        return results
478774
public Iterator getReportQueryIteratorByQuery(Query query) throws PersistenceBrokerException
    {
        ClassDescriptor cld = getClassDescriptor(query.getSearchClass());
        return getReportQueryIteratorFromQuery(query, cld);
    }