sqlgStep is either a {@link SqlgGraphStep} or {@link SqlgVertexStep}.

@return false if optimization must be terminated.
432479
boolean handleStep(ListIterator<Step<?, ?>> stepIterator, MutableInt pathCount) {
        Step<?, ?> step = stepIterator.next();
        removeTinkerPopLabels(step);
        if (step instanceof GraphStep) {
            doFirst(stepIterator, step, pathCount);
        } else if (this.sqlgStep == null) {
            boolean keepGoing = doFirst(stepIterator, step, pathCount);
            stepIterator.previous();
            return keepGoing;
        } else {
            if (step instanceof VertexStep || step instanceof EdgeVertexStep || step instanceof EdgeOtherVertexStep) {
                handleVertexStep(stepIterator, (AbstractStep<?, ?>) step, pathCount);
            } else if (step instanceof RepeatStep) {
                if (!unoptimizableRepeatStep()) {
                    handleRepeatStep((RepeatStep<?>) step, pathCount);
                } else {
                    this.currentReplacedStep.addLabel((pathCount) + BaseStrategy.PATH_LABEL_SUFFIX + BaseStrategy.SQLG_PATH_FAKE_LABEL);
                    return false;
                }
            } else if (step instanceof OptionalStep) {
                if (!unoptimizableOptionalStep((OptionalStep<?>) step)) {
                    this.optionalStepStack.clear();
                    handleOptionalStep(1, (OptionalStep<?>) step, this.traversal, pathCount);
                    this.optionalStepStack.clear();
                    //after choose steps the optimization starts over in VertexStrategy
                    this.reset = true;
                } else {
                    return false;
                }
            } else if (step instanceof ChooseStep) {
                if (!unoptimizableChooseStep((ChooseStep<?, ?, ?>) step)) {
                    this.chooseStepStack.clear();
                    handleChooseStep(1, (ChooseStep<?, ?, ?>) step, this.traversal, pathCount);
                    this.chooseStepStack.clear();
                    //after choose steps the optimization starts over
                    this.reset = true;
                } else {
                    return false;
                }
            } else if (step instanceof OrderGlobalStep) {
                stepIterator.previous();
                handleOrderGlobalSteps(stepIterator, pathCount);
                handleRangeGlobalSteps(stepIterator, pathCount);
            } else if (step instanceof RangeGlobalStep) {
                handleRangeGlobalSteps(stepIterator, pathCount);
            } else if (step instanceof SelectStep || (step instanceof SelectOneStep)) {
                handleOrderGlobalSteps(stepIterator, pathCount);
                handleRangeGlobalSteps(stepIterator, pathCount);
                //select step can not be followed by a PropertyStep
                if (step instanceof SelectOneStep) {
                    SelectOneStep selectOneStep = (SelectOneStep) step;
                    String key = (String) selectOneStep.getScopeKeys().iterator().next();
                    if (stepIterator.hasNext()) {
                        Step<?, ?> next = stepIterator.next();
                        if (next instanceof PropertiesStep) {
                            //get the step for the label
                            Optional<ReplacedStep<?, ?>> labeledReplacedStep = this.sqlgStep.getReplacedSteps().stream().filter(
                                    r -> {
                                        //Take the first
                                        if (r.hasLabels()) {
                                            String label = r.getLabels().iterator().next();
                                            String stepLabel = SqlgUtil.originalLabel(label);
                                            return stepLabel.equals(key);
                                        } else {
                                            return false;
                                        }
                                    }
                            ).findAny();
                            Preconditions.checkState(labeledReplacedStep.isPresent());
                            ReplacedStep<?, ?> replacedStep = labeledReplacedStep.get();
                            handlePropertiesStep(replacedStep, next);
                            return true;
                        } else {
                            stepIterator.previous();
                            return false;
                        }
                    }
                }
//                return !stepIterator.hasNext() || !(stepIterator.next() instanceof SelectOneStep);
            } else if (step instanceof DropStep && (!this.sqlgGraph.getSqlDialect().isMariaDb())) {

                Traversal.Admin<?, ?> root = TraversalHelper.getRootTraversal(this.traversal);
                final Optional<EventStrategy> eventStrategyOptional = root.getStrategies().getStrategy(EventStrategy.class);
                if (eventStrategyOptional.isPresent()) {
                    //Do nothing, it will go via the SqlgDropStepBarrier.
                } else {
                    //MariaDB does not support target and source together.
                    //Table 'E_ab' is specified twice, both as a target for 'DELETE' and as a separate source for data
                    //This has been fixed in 10.3.1, waiting for it to land in the repo.
                    handleDropStep();
                }
                return false;
            } else if (step instanceof DropStep && this.sqlgGraph.getSqlDialect().isMariaDb()) {
                return false;
            } else if (step instanceof PropertiesStep) {
                return handlePropertiesStep(this.currentReplacedStep, step);
            } else if (step instanceof PropertyMapStep) {
                return handlePropertyMapStep(step);
            } else {
                throw new IllegalStateException("Unhandled step " + step.getClass().getName());
            }
        }
        return true;
    }
489030
public boolean moveToFirst() {
        try {
            return resultSet.first();
        } catch (SQLException e) {
            logger.error(e.getMessage(),e);
        }
        return false;
    }
216743
public boolean isWeaklyConnected() {

		final AbstractJobVertex[] reachable = getAllReachableJobVertices();
		final AbstractJobVertex[] all = getAllJobVertices();

		// Check if number if reachable vertices matches number of registered vertices
		if (reachable.length != all.length) {
			return false;
		}

		final HashMap<JobVertexID, AbstractJobVertex> tmp = new HashMap<JobVertexID, AbstractJobVertex>();
		for (int i = 0; i < reachable.length; i++) {
			tmp.put(reachable[i].getID(), reachable[i]);
		}

		// Check if all is subset of reachable
		for (int i = 0; i < all.length; i++) {
			if (!tmp.containsKey(all[i].getID())) {
				return false;
			}
		}

		// Check if reachable is a subset of all
		for (int i = 0; i < reachable.length; i++) {
			if (!includedInJobGraph(reachable[i].getID())) {
				return false;
			}
		}

		return true;
	}
395417
public boolean isFilled() {
        boolean isFilled = false;

        if (this.originalSql != null && this.originalSql.length() > 0) {
            if (this.parsedSql != null && this.parsedSql.length() > 0) {
                if (this.sqlParameterNames != null) {
                    if (this.sqlParameterValues != null) {
                        isFilled = true;
                    }
                }
            }
        }

        return isFilled;
    }
429257
private boolean processStepResults(double fx_candidate, double actualReduction, double predictedReduction) {
		double ratio = actualReduction/predictedReduction;
		boolean accepted;

		// Accept the new state if the score improved
		if( fx_candidate < fx ) {
			// reduce the amount of dampening.  Magic equation from [1].  My attempts to improve
			// upon it have failed.  It is truly magical.
			lambda = lambda* max(1.0/3.0, 1.0-Math.pow(2.0*ratio-1.0,3.0));
			nu=NU_INITIAL;
			accepted = true;
		} else {
			lambda *= nu;
			nu *= 2;
			accepted = false;
		}

		if( UtilEjml.isUncountable(lambda) || UtilEjml.isUncountable(nu) )
			throw new OptimizationException("BUG! lambda="+lambda+"  nu="+nu);

		if( accepted ) {
			boolean converged = checkConvergenceFTest(fx_candidate,fx);
			if( verbose != null ) {
				double length_p = NormOps_DDRM.normF(p); // TODO compute elsewhere ?
				verbose.printf("%-4d  %9.3E  %10.3E  %9.3E  %9.3E  %9.3E  %6.3f   %6.2E\n",
						totalSelectSteps, fx_candidate, fx_candidate - fx,length_p,ftest_val,gtest_val, ratio, lambda);
				if( converged ) {
					verbose.println("Converged f-test");
				}
			}

			acceptNewState(fx_candidate);
			return maximumLambdaNu() || converged;
		} else
			return false;
	}
367571
public boolean isValid()
    {
    // Must be non-empty...
    boolean valid = varNamePath_ != null;

    if( valid)
      {
      // Containing a sequence of identifiers...
      int i;
      for( i = 0; i < varNamePath_.length && DefUtils.isIdentifier( varNamePath_[i]); i++);

      // Optionally terminated by a single wildcard.
      int membersLeft = varNamePath_.length - i;
      valid =
        membersLeft == 0
        ||
        (membersLeft == 1
         &&
         (varNamePath_[i].equals( ALL_DESCENDANTS) || varNamePath_[i].equals( ALL_CHILDREN)));
      }

    return valid;
    }
1289811
public boolean hasNextThrow() throws SQLException {
		if (closed) {
			return false;
		}
		if (alreadyMoved) {
			// we do this so multiple hasNext() calls can be made, result would be true or closed is true
			return true;
		}
		boolean result;
		if (first) {
			first = false;
			result = results.first();
		} else {
			result = results.next();
		}
		if (!result) {
			IOUtils.closeThrowSqlException(this, "iterator");
		}
		alreadyMoved = true;
		return result;
	}
970381
public boolean execute(Sql sql) throws SQLException {
		
		long start =  System.currentTimeMillis();
		
		if (sql.validate() == false) {
			return false;
		}
		
		boolean result = false;
		
		PreparedStatement stmt = null;
		try {
			stmt = this.createStatment(conn, sql);
			stmt.execute();
			
			result = true;
		} catch (SQLException e) {
			throw e;
		} finally {
			try {
				if (stmt != null && stmt.isClosed() == false) {
					stmt.close();
				}
			} catch (SQLException e) {
				logger.error(e.getMessage(), e);
			}
		}
		
		logger.debug(String.format("Execute %s used %d ms", sql.getSql(), System.currentTimeMillis() - start));

		return result;
	}
869608
private boolean performLineSearch() {
		// if true then it can't iterate any more
		if( lineSearch.iterate() ) {
			// see if the line search failed
			if( !lineSearch.isConverged() ) {
				if( firstStep ) {
					// if it failed on the very first step then it might have been too large
					// try halving the step size
					initialStep /= 2;
					if( initialStep != 0 ) {
						invokeLineInitialize(fx, maxStep);
						return false;
					} else {
						if( verbose != null && verboseLevel != 0 ) {
							verbose.println("Initial step reduced to zero");
						}
						return terminateSearch(false);
					}
				} else {
					return terminateSearch(false);
				}
			} else {
				firstStep = false;
			}

			// update variables
			double step = lineSearch.getStep();

			// save the new x
			System.arraycopy(function.getCurrentState(),0,x.data,0,N);
			// compute the change in the x
			for( int i = 0; i < N; i++ )
				s.data[i] = step * searchVector.data[i];
			updated = true;

			// convergence tests
			// function value at end of line search
			double fstp = lineSearch.getFunction();

			if( verbose != null ) {
				double actualStep = NormOps_DDRM.fastNormF(s);
				double ftest_val = Math.abs(fstp-fx)/Math.abs(fx);
				double gtest_val = Math.abs(derivAtZero);

				verbose.printf("%-4d  %9.3E  %10.3E  %9.3E  %9.3E  %9.3E  %6.3f\n",
						iterations, fstp, fstp - fx,actualStep,ftest_val,gtest_val, maxStep);
			}

			// see if the actual different and predicted differences are smaller than the
			// error tolerance
			if( Math.abs(fstp-fx) <= ftol*Math.abs(fx) || Math.abs(derivAtZero) < gtol ) {
				if( verbose != null ) {
					verbose.println("converged after line search.");
				}
				return terminateSearch(true);
			}

			if( fstp > fx ) {
				throw new RuntimeException("Bug! Worse results!");
			}

			// current function value is now the previous
			fx = fstp;

			// start the loop again
			mode = 0;
		}
		return false;
	}
1327421
private E loadEdge(KeyedGraph<V, E> graph, ResultSet edges) throws SQLException {
        final int startNode = edges.getInt(startNodeIndex);
        final int endNode = edges.getInt(endNodeIndex);
        final int edgeID = edges.getInt(edgeIDIndex);
        double weight = WeightedGraph.DEFAULT_EDGE_WEIGHT;
        if (weightColumnIndex != -1) {
            weight = edges.getDouble(weightColumnIndex);
        }
        E edge;
        // Undirected graphs are either pseudographs or weighted pseudographs,
        // so there is no need to add edges in both directions.
        if (globalOrientation.equals(GraphFunctionParser.Orientation.UNDIRECTED)) {
            edge = graph.addEdge(endNode, startNode, edgeID);
        } else {
            // Directed graphs are either directed pseudographs or directed
            // weighted pseudographs and must specify an orientation for each
            // individual edge. If no orientations are specified, every edge
            // is considered to be directed with orientation given by the
            // geometry.
            int edgeOrientation = (edgeOrientationIndex == -1)
                    ? DIRECTED_EDGE
                    : edges.getInt(edgeOrientationIndex);
            if (edges.wasNull()) {
                throw new IllegalArgumentException("Invalid edge orientation: NULL.");
            }
            if (edgeOrientation == UNDIRECTED_EDGE) {
                if (globalOrientation.equals(GraphFunctionParser.Orientation.DIRECTED)) {
                    edge = loadDoubleEdge(graph, startNode, endNode, edgeID, weight);
                } // globalOrientation == Orientation.REVERSED
                else {
                    edge = loadDoubleEdge(graph, endNode, startNode, edgeID, weight);
                }
            } else if (edgeOrientation == DIRECTED_EDGE) {
                // Reverse a directed edge (global).
                if (globalOrientation.equals(GraphFunctionParser.Orientation.REVERSED)) {
                    edge = graph.addEdge(endNode, startNode, edgeID);
                } // No reversal.
                else {
                    edge = graph.addEdge(startNode, endNode, edgeID);
                }
            } else if (edgeOrientation == REVERSED_EDGE) {
                // Reversing twice is the same as no reversal.
                if (globalOrientation.equals(GraphFunctionParser.Orientation.REVERSED)) {
                    edge = graph.addEdge(startNode, endNode, edgeID);
                } // Otherwise reverse just once (local).
                else {
                    edge = graph.addEdge(endNode, startNode, edgeID);
                }
            } else {
                throw new IllegalArgumentException("Invalid edge orientation: " + edgeOrientation);
            }
        }
        setEdgeWeight(edge, weight);
        return edge;
    }
460479
public boolean doProcessing(List<JCCompilationUnit> roots,
                                List<ClassSymbol> classSymbols,
                                Iterable<? extends PackageSymbol> pckSymbols,
                                Log.DeferredDiagnosticHandler deferredDiagnosticHandler) {
        final Set<JCCompilationUnit> treesToClean =
                Collections.newSetFromMap(new IdentityHashMap<JCCompilationUnit, Boolean>());

        //fill already attributed implicit trees:
        for (Env<AttrContext> env : enter.getEnvs()) {
            treesToClean.add(env.toplevel);
        }

        Set<PackageSymbol> specifiedPackages = new LinkedHashSet<>();
        for (PackageSymbol psym : pckSymbols)
            specifiedPackages.add(psym);
        this.specifiedPackages = Collections.unmodifiableSet(specifiedPackages);

        Round round = new Round(roots, classSymbols, treesToClean, deferredDiagnosticHandler);

        boolean errorStatus;
        boolean moreToDo;
        do {
            // Run processors for round n
            round.run(false, false);

            // Processors for round n have run to completion.
            // Check for errors and whether there is more work to do.
            errorStatus = round.unrecoverableError();
            moreToDo = moreToDo();

            round.showDiagnostics(errorStatus || showResolveErrors);

            // Set up next round.
            // Copy mutable collections returned from filer.
            round = round.next(
                    new LinkedHashSet<>(filer.getGeneratedSourceFileObjects()),
                    new LinkedHashMap<>(filer.getGeneratedClasses()));

             // Check for errors during setup.
            if (round.unrecoverableError())
                errorStatus = true;

        } while (moreToDo && !errorStatus);

        // run last round
        round.run(true, errorStatus);
        round.showDiagnostics(true);

        filer.warnIfUnclosedFiles();
        warnIfUnmatchedOptions();

        /*
         * If an annotation processor raises an error in a round,
         * that round runs to completion and one last round occurs.
         * The last round may also occur because no more source or
         * class files have been generated.  Therefore, if an error
         * was raised on either of the last *two* rounds, the compile
         * should exit with a nonzero exit code.  The current value of
         * errorStatus holds whether or not an error was raised on the
         * second to last round; errorRaised() gives the error status
         * of the last round.
         */
        if (messager.errorRaised()
                || werror && round.warningCount() > 0 && round.errorCount() > 0)
            errorStatus = true;

        Set<JavaFileObject> newSourceFiles =
                new LinkedHashSet<>(filer.getGeneratedSourceFileObjects());
        roots = round.roots;

        errorStatus = errorStatus || (compiler.errorCount() > 0);

        round.finalCompiler();

        if (newSourceFiles.size() > 0)
            roots = roots.appendList(compiler.parseFiles(newSourceFiles));

        errorStatus = errorStatus || (compiler.errorCount() > 0);

        // Free resources
        this.close();

        if (errorStatus && compiler.errorCount() == 0) {
            compiler.log.nerrors++;
        }

        compiler.enterTreesIfNeeded(roots);

        if (!taskListener.isEmpty())
            taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));

        return true;
    }
669034
public static Geometry runBuffer(final Geometry geom, final double bufferSize,
            final BufferParameters bufferParameters) throws SQLException {
        return BufferOp.bufferOp(geom, bufferSize, bufferParameters);
    }
893792
function(executionStep) {
    // In order to use and index for implementing a join, the entire relation
    // must be fed to the JoinStep, otherwise the index can't be used.
    if (!(executionStep instanceof lf.proc.TableAccessFullStep)) {
      return null;
    }
    var candidateColumn = getColumnForTable(executionStep.table);
    return goog.isNull(candidateColumn.getIndex()) ? null : candidateColumn;
  }
755916
public boolean isFinished(final ProcessorGraphNode processorGraphNode) {
        this.processorLock.lock();
        try {
            return this.executedProcessors.containsKey(processorGraphNode.getProcessor());
        } finally {
            this.processorLock.unlock();
        }
    }
88162
public boolean process(Grid grid ) {
		// reset and initialize data structures
		init(grid);

		// add tangent points from adjacent ellipses
		if( !horizontal(grid) )
			return false;
		if( !vertical(grid) )
			return false;

		keypoints.reset();
		for (int i = 0; i < tangents.size(); i++) {
			tangents.get(i).getTop(keypoints.grow());
			tangents.get(i).getRight(keypoints.grow());
			tangents.get(i).getBottom(keypoints.grow());
			tangents.get(i).getLeft(keypoints.grow());
		}

		return true;
	}
709615
public static boolean step( IterativeOptimization search ) {
		for( int i = 0; i < 10000; i++ ) {
			boolean converged = search.iterate();
			if( converged || !search.isUpdated() ) {
				return converged;
			}
		}
		throw new RuntimeException("After 10,000 iterations it failed to take a step! Probably a bug.");
	}
1179442
public boolean wasSkipped() {
        return getSteps().stream().filter(s -> s.getEndState() != StepEndState.SKIPPED).count() == 0;
    }