MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / prepareAllQueries

Method prepareAllQueries

lib/prepare-handler.js:208–233  ·  view source on GitHub ↗

* Prepares all queries on a single host. * @param {Host} host * @param {Array} allPrepared

(host, allPrepared)

Source from the content-addressed store, hash-verified

206 * @param {Array} allPrepared
207 */
208 static async prepareAllQueries(host, allPrepared) {
209 const anyKeyspaceQueries = [];
210
211 const queriesByKeyspace = new Map();
212 allPrepared.forEach(info => {
213 let arr;
214 if (info.keyspace) {
215 arr = queriesByKeyspace.get(info.keyspace);
216
217 if (!arr) {
218 arr = [];
219 queriesByKeyspace.set(info.keyspace, arr);
220 }
221 } else {
222 arr = anyKeyspaceQueries;
223 }
224
225 arr.push(info.query);
226 });
227
228 for (const [keyspace, queries] of queriesByKeyspace) {
229 await PrepareHandler._borrowAndPrepare(host, keyspace, queries);
230 }
231
232 await PrepareHandler._borrowAndPrepare(host, null, anyKeyspaceQueries);
233 }
234
235 /**
236 * Borrows a connection from the host and prepares the queries provided.

Callers 2

_onNewConnectionOpenMethod · 0.80

Calls 5

setMethod · 0.80
_borrowAndPrepareMethod · 0.80
forEachMethod · 0.65
getMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected