@Override
	public int queryFunctions(QueryNearest query, BSimSqlClause filter, ResponseNearest response,
			DescriptionManager descMgr, Iterator<FunctionDescription> iter)
			throws SQLException, LSHException {
		//TODO: is this what the method should return
		//TODO: why is iter an argument?  Why not just use query.manage.listAllFunctions()

		//build a QueryNearestVector from query to do the vector search in parallel

		QueryNearestVector qnv = new QueryNearestVector();
		qnv.manage.transferSettings(query.manage);
		qnv.signifthresh = query.signifthresh;
		qnv.thresh = query.thresh;
		qnv.vectormax = query.vectormax;
		qnv.buildResponseTemplate();

		//currently the parallelized vector search does no de-duping
		//so we compute the number of distinct vectors queried to return
		Set<Long> distinctVecIds = new HashSet<>();

		while (iter.hasNext()) {
			FunctionDescription fd = iter.next();
			if (fd.getSignatureRecord() != null) {
				distinctVecIds.add(fd.getSignatureRecord().getLSHVector().calcUniqueHash());
				qnv.manage.transferFunction(fd, true);
			}
		}
		queryNearestVector(qnv);
		ResponseNearestVector rnv = qnv.nearresponse;

		//seems fishy but agrees with AbstractSQLFunctionDatabase.queryFunctions
		response.totalfunc = rnv.totalvec;

		for (SimilarityVectorResult simVecRes : rnv.result) {
			FunctionDescription base = simVecRes.getBase();
			Iterator<VectorResult> vecResults = simVecRes.iterator();
			SimilarityResult sim = new SimilarityResult(base);
			sim.setTotalCount(simVecRes.getTotalCount());
			int funcsForVec = 0;
			while (vecResults.hasNext()) {
				if (funcsForVec >= query.max) {
					break;
				}
				VectorResult dresult = vecResults.next();
				funcsForVec +=
					retrieveFuncDescFromVectors(dresult, descMgr, funcsForVec, query, filter, sim);
			}
			if (sim.size() == 0) {
				continue;
			}
			response.totalmatch += 1;
			if (sim.size() == 1) {
				response.uniquematch += 1;
			}
			response.result.add(sim);
			sim.transfer(response.manage, true);
		}
		return distinctVecIds.size();
	}
Create vector map which maps vector ID to {@link VectorStoreEntry}
@return vector map
@throws SQLException if error occurs while reading map data
Ghidra/Features/BSim/src/main/java/ghidra/features/bsim/query/file/H2FileFunctionDatabase.java