private void queryNearest(SimilarityResult simres, DescriptionManager res, LSHVector vec,
			QueryNearest query, BSimSqlClause filter,
			HashMap<LSHVector, List<VectorResult>> vecToResultsMap)
			throws SQLException, LSHException {
		List<VectorResult> resultset = new ArrayList<>();
		int vectormax = query.vectormax;
		if (vectormax == 0) {
			vectormax = 2000000; // Really means a very big limit
		}

		// Check to see if we've already queried for this vector before. If so, just grab
		// the results from the map.
		if (vecToResultsMap.containsKey(vec)) {
			resultset = vecToResultsMap.get(vec);
			simres.setTotalCount(getTotalCount(resultset));
		}
		else {
			// Perform the query.
			simres.setTotalCount(
				queryNearestVector(resultset, vec, query.thresh, query.signifthresh, vectormax));

			// Put the new results in the map so we can use them if another 
			// similar vector comes along.
			vecToResultsMap.put(vec, resultset);
		}

		int count = 0;

		for (VectorResult dresult : resultset) {
			if (count >= query.max) {
				break;
			}
			count += retrieveFuncDescFromVectors(dresult, res, count, query, filter, simres);
		}
	}
Query the database for functions with a similar feature vector to -vec-
@param simres receives the list of results and their similarity to the base vector
@param res is the DescriptionManager container for the results
@param vec is the feature vector to match
@param query contains various thresholds for the query
@param filter specifies additional conditions functions (and exes) must meet after meeting sim/signif threshold
@param vecToResultsMap list of result vectors
@throws SQLException if there is an error issuing the query 
@throws LSHException if executable record creation fails
Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/client/AbstractSQLFunctionDatabase.java