Returns a CQL batch query wrapping the given statements.

@param statements the list of statements to use to generate the batch statement.
@return the batch statement.
507778
public static String batchQueryGenerator(List<String> statements) {
        StringBuilder sb = new StringBuilder("BEGIN BATCH \n");

        for (String statement : statements) {
            sb.append(statement).append("\n");
        }

        sb.append(" APPLY BATCH;");

        return sb.toString();
    }
997630
public static <E> OqlBuilder<E> hql(final String hql) {
    OqlBuilder<E> query = new OqlBuilder<E>();
    query.statement = hql;
    return query;
  }
1020138
public static String parseDescribeStatement(String statement) {
        Matcher matcher = DescribeToken.matcher(statement);
        if (matcher.matches()) {
            String commandWordTerminator = matcher.group(1);
            if (OneWhitespace.matcher(commandWordTerminator).matches()) {
                String trailings = matcher.group(3) + ";" + matcher.group(4);
                // In a valid command, both "trailings" groups should be empty.
                if (trailings.equals(";")) {
                    // Return the subcommand keyword -- possibly a valid one.
                    return matcher.group(2);
                }
                // For an invalid form of the command,
                // return an approximation of the garbage input.
                return matcher.group(2) + " " + trailings;
            }
            if (commandWordTerminator.equals("") || commandWordTerminator.equals(";")) {
                return commandWordTerminator; // EOL or ; reached before subcommand
            }
        }
        return null;
    }
671435
public static BoundStatement bind(PreparedStatement statement, Object[] params) {
        if(CQL_LOGGER.isDebugEnabled()) {
            CQL_LOGGER.debug("{} parameters ({})", statement.getQueryString(), StringUtils.join(params, ","));
        }
        return statement.bind(params);
    }
59974
protected static Map<String, List<Statement>> addStatementToGroups(Statement statement, Map<String, List<Statement>> claims) {
		Map<String, List<Statement>> newGroups = new HashMap<>(claims);
		String pid = statement.getMainSnak().getPropertyId().getId();
		if(newGroups.containsKey(pid)) {
			List<Statement> newGroup = new ArrayList<>(newGroups.get(pid).size());
			boolean statementReplaced = false;
			for(Statement existingStatement : newGroups.get(pid)) {
				if(existingStatement.getStatementId().equals(statement.getStatementId()) &&
						!existingStatement.getStatementId().isEmpty()) {
					statementReplaced = true;
					newGroup.add(statement);
				} else {
					newGroup.add(existingStatement);
				}
			}
			if(!statementReplaced) {
				newGroup.add(statement);
			}
			newGroups.put(pid, newGroup);
		} else {
			newGroups.put(pid, Collections.singletonList(statement));
		}
		return newGroups;
	}
1100426
@Procedure(mode = Mode.WRITE)
    @Description("apoc.periodic.iterate('statement returning items', 'statement per item', {batchSize:1000,iterateList:true,parallel:false,params:{},concurrency:50,retries:0}) YIELD batches, total - run the second statement for each item returned by the first statement. Returns number of batches and total processed rows")
    public Stream<BatchAndTotalResult> iterate(
            @Name("cypherIterate") String cypherIterate,
            @Name("cypherAction") String cypherAction,
            @Name("config") Map<String,Object> config) {

        long batchSize = Util.toLong(config.getOrDefault("batchSize", 10000));
        int concurrency = Util.toInteger(config.getOrDefault("concurrency", 50));
        boolean parallel = Util.toBoolean(config.getOrDefault("parallel", false));
        boolean iterateList = Util.toBoolean(config.getOrDefault("iterateList", true));
        long retries = Util.toLong(config.getOrDefault("retries", 0)); // todo sleep/delay or push to end of batch to try again or immediate ?
        Map<String,Object> params = (Map)config.getOrDefault("params", Collections.emptyMap());
        int failedParams = Util.toInteger(config.getOrDefault("failedParams", -1));
        try (Result result = db.execute(slottedRuntime(cypherIterate),params)) {
            Pair<String,Boolean> prepared = prepareInnerStatement(cypherAction, iterateList, result.columns(), "_batch");
            String innerStatement = prepared.first();
            iterateList=prepared.other();
            log.info("starting batching from `%s` operation using iteration `%s` in separate thread", cypherIterate,cypherAction);
            return iterateAndExecuteBatchedInSeparateThread((int)batchSize, parallel, iterateList, retries, result, (p) -> db.execute(innerStatement, merge(params, p)).close(), concurrency, failedParams);
        }
    }
309536
public final hqlParser.statement_return statement() throws RecognitionException {
		hqlParser.statement_return retval = new hqlParser.statement_return();
		retval.start = input.LT(1);

		CommonTree root_0 = null;

		Token EOF5=null;
		ParserRuleReturnScope updateStatement1 =null;
		ParserRuleReturnScope deleteStatement2 =null;
		ParserRuleReturnScope selectStatement3 =null;
		ParserRuleReturnScope insertStatement4 =null;

		CommonTree EOF5_tree=null;

		try {
			// hql.g:161:2: ( ( updateStatement | deleteStatement | selectStatement | insertStatement ) EOF !)
			// hql.g:161:4: ( updateStatement | deleteStatement | selectStatement | insertStatement ) EOF !
			{
			root_0 = (CommonTree)adaptor.nil();


			// hql.g:161:4: ( updateStatement | deleteStatement | selectStatement | insertStatement )
			int alt1=4;
			switch ( input.LA(1) ) {
			case UPDATE:
				{
				alt1=1;
				}
				break;
			case DELETE:
				{
				alt1=2;
				}
				break;
			case EOF:
			case CLOSE:
			case FROM:
			case GROUP:
			case HAVING:
			case ORDER:
			case SELECT:
			case SKIP:
			case TAKE:
			case UNION:
			case WHERE:
				{
				alt1=3;
				}
				break;
			case INSERT:
				{
				alt1=4;
				}
				break;
			default:
				NoViableAltException nvae =
					new NoViableAltException("", 1, 0, input);
				throw nvae;
			}
			switch (alt1) {
				case 1 :
					// hql.g:161:6: updateStatement
					{
					pushFollow(FOLLOW_updateStatement_in_statement599);
					updateStatement1=updateStatement();
					state._fsp--;

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

					}
					break;
				case 2 :
					// hql.g:161:24: deleteStatement
					{
					pushFollow(FOLLOW_deleteStatement_in_statement603);
					deleteStatement2=deleteStatement();
					state._fsp--;

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

					}
					break;
				case 3 :
					// hql.g:161:42: selectStatement
					{
					pushFollow(FOLLOW_selectStatement_in_statement607);
					selectStatement3=selectStatement();
					state._fsp--;

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

					}
					break;
				case 4 :
					// hql.g:161:60: insertStatement
					{
					pushFollow(FOLLOW_insertStatement_in_statement611);
					insertStatement4=insertStatement();
					state._fsp--;

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

					}
					break;

			}

			EOF5=(Token)match(input,EOF,FOLLOW_EOF_in_statement615);
			}

			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 {
			// do for sure before leaving
		}
		return retval;
	}
806765
@NonNull
  public BatchStatementBuilder addStatement(@NonNull BatchableStatement<?> statement) {
    if (statementsCount >= 0xFFFF) {
      throw new IllegalStateException(
          "Batch statement cannot contain more than " + 0xFFFF + " statements.");
    }
    statementsCount += 1;
    statementsBuilder.add(statement);
    return this;
  }
53697
public void setStatements(java.util.Collection<ApplicationPolicyStatement> statements) {
        if (statements == null) {
            this.statements = null;
            return;
        }

        this.statements = new java.util.ArrayList<ApplicationPolicyStatement>(statements);
    }
1176576
public void executeStatements(String... statements) throws SQLException {
    Preconditions.checkNotNull(this.conn, "The Hive connection must be set before any queries can be run");

    for (String statement : statements) {
      if (isSimulate) {
        LOG.info("[SIMULATE MODE] STATEMENT NOT RUN: " + choppedStatementNoLineChange(statement));
      } else {
        LOG.info("RUNNING STATEMENT: " + choppedStatementNoLineChange(statement));
        try (Statement stmt = this.conn.createStatement()) {
          try {
            stmt.execute(statement);
          } catch (SQLException sqe) {
            LOG.error("Failed statement: " + choppedStatementNoLineChange(statement));
            throw sqe;
          }
        }
      }
    }
  }
421122
def create_many(self, statements):
        
        Statement = self.get_model('statement')
        Tag = self.get_model('tag')

        tag_cache = {}

        for statement in statements:

            statement_data = statement.serialize()
            tag_data = statement_data.pop('tags', [])

            statement_model_object = Statement(**statement_data)

            if not statement.search_text:
                statement_model_object.search_text = self.tagger.get_bigram_pair_string(statement.text)

            if not statement.search_in_response_to and statement.in_response_to:
                statement_model_object.search_in_response_to = self.tagger.get_bigram_pair_string(statement.in_response_to)

            statement_model_object.save()

            tags_to_add = []

            for tag_name in tag_data:
                if tag_name in tag_cache:
                    tag = tag_cache[tag_name]
                else:
                    tag, _ = Tag.objects.get_or_create(name=tag_name)
                    tag_cache[tag_name] = tag
                tags_to_add.append(tag)

            statement_model_object.tags.add(*tags_to_add)
1140997
private Statements createSequencesStatements(Iterable<Sequence> sequences) {
		Statements statements = new Statements();
		for ( Sequence sequence : sequences ) {
			addSequence( statements, sequence );
		}
		return statements;
	}
212659
public ResultSetAndStatement executeQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
    {
        if (logger.isDebugEnabled())
        {
            logger.debug("executeQuery: " + query);
        }
        /*
		 * MBAIRD: we should create a scrollable resultset if the start at
		 * index or end at index is set
		 */
        boolean scrollable = ((query.getStartAtIndex() > Query.NO_START_AT_INDEX) || (query.getEndAtIndex() > Query.NO_END_AT_INDEX));
        /*
		 * OR if the prefetching of relationships is being used.
		 */
        if (query != null && query.getPrefetchedRelationships() != null && !query.getPrefetchedRelationships().isEmpty())
        {
            scrollable = true;
        }
        final StatementManagerIF sm = broker.serviceStatementManager();
        final SelectStatement sql = broker.serviceSqlGenerator().getPreparedSelectStatement(query, cld);
        PreparedStatement stmt = null;
        ResultSet rs = null;
        try
        {
            final int queryFetchSize = query.getFetchSize();
            final boolean isStoredProcedure = isStoredProcedure(sql.getStatement());
            stmt = sm.getPreparedStatement(cld, sql.getStatement() ,
                    scrollable, queryFetchSize, isStoredProcedure);
            if (isStoredProcedure)
            {
                // Query implemented as a stored procedure, which must return a result set.
                // Query sytax is: { ?= call PROCEDURE_NAME(?,...,?)}
                getPlatform().registerOutResultSet((CallableStatement) stmt, 1);
                sm.bindStatement(stmt, query, cld, 2);

                if (logger.isDebugEnabled())
                    logger.debug("executeQuery: " + stmt);

                stmt.execute();
                rs = (ResultSet) ((CallableStatement) stmt).getObject(1);
            }
            else
            {
                sm.bindStatement(stmt, query, cld, 1);

                if (logger.isDebugEnabled())
                    logger.debug("executeQuery: " + stmt);

                rs = stmt.executeQuery();
            }

            return new ResultSetAndStatement(sm, stmt, rs, sql);
        }
        catch (PersistenceBrokerException e)
        {
            // release resources on exception
            sm.closeResources(stmt, rs);
            logger.error("PersistenceBrokerException during the execution of the query: " + e.getMessage(), e);
            throw e;
        }
        catch (SQLException e)
        {
            // release resources on exception
            sm.closeResources(stmt, rs);
            throw ExceptionHelper.generateException(e, sql.getStatement(), null, logger, null);
        }
    }
993427
@Override
  public String getSqlWithValues() {
    final StringBuilder sb = new StringBuilder();
    final String statementQuery = getStatementQuery();

    // iterate over the characters in the query replacing the parameter placeholders
    // with the actual values
    int currentParameter = 0;
    for( int pos = 0; pos < statementQuery.length(); pos ++) {
      char character = statementQuery.charAt(pos);
      if( statementQuery.charAt(pos) == '?' && currentParameter <= parameterValues.size()) {
        // replace with parameter value
        Value value = parameterValues.get(currentParameter);
        sb.append(value != null ? value.toString() : new Value().toString());
        currentParameter++;
      } else {
        sb.append(character);
      }
    }

    return sb.toString();
  }
99752
function interpretStatements(statements) {
    var /** @type {?} */ ctx = new _ExecutionContext(null, null, null, new Map());
    var /** @type {?} */ visitor = new StatementInterpreter();
    visitor.visitAllStatements(statements, ctx);
    var /** @type {?} */ result = {};
    ctx.exports.forEach(function (exportName) { result[exportName] = ctx.vars.get(exportName); });
    return result;
}
301635
def get_statements(self, reprocess=False):
        """"""
        if self._statements is None or reprocess:
            # Handle the case that there is no content.
            if self.content is None:
                self._statements = []
                return []

            # Map to the different processors.
            if self.reader == ReachReader.name:
                if self.format == formats.JSON:
                    # Process the reach json into statements.
                    json_str = json.dumps(self.content)
                    processor = reach.process_json_str(json_str)
                else:
                    raise ReadingError("Incorrect format for Reach output: %s."
                                       % self.format)
            elif self.reader == SparserReader.name:
                if self.format == formats.JSON:
                    # Process the sparser content into statements
                    processor = sparser.process_json_dict(self.content)
                    if processor is not None:
                        processor.set_statements_pmid(None)
                else:
                    raise ReadingError("Sparser should only ever be JSON, not "
                                       "%s." % self.format)
            elif self.reader == TripsReader.name:
                processor = trips.process_xml(self.content)
            else:
                raise ReadingError("Unknown reader: %s." % self.reader)

            # Get the statements from the processor, if it was resolved.
            if processor is None:
                logger.error("Production of statements from %s failed for %s."
                             % (self.reader, self.content_id))
                stmts = []
            else:
                stmts = processor.statements
            self._statements = stmts[:]
        else:
            stmts = self._statements[:]
        return stmts
501809
@Override
    public String prepareBatchQuery(List<String> statements) {

        StringBuilder sb = new StringBuilder("BEGIN BATCH \n");

        for (String statement : statements) {
            sb.append(statement).append("\n");
        }

        sb.append(" APPLY BATCH;");

        return sb.toString();
    }