MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / init

Method init

src/jrd/recsrc/HashJoin.cpp:277–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275}
276
277void HashJoin::init(thread_db* tdbb, CompilerScratch* csb, FB_SIZE_T count,
278 RecordSource* const* args, NestValueArray* const* keys,
279 double selectivity)
280{
281 m_impure = csb->allocImpure<Impure>();
282
283 m_leader.source = args[0];
284 m_leader.keys = keys[0];
285 const FB_SIZE_T leaderKeyCount = m_leader.keys->getCount();
286 m_leader.keyLengths = FB_NEW_POOL(csb->csb_pool) ULONG[leaderKeyCount];
287 m_leader.totalKeyLength = 0;
288
289 m_cardinality = m_leader.source->getCardinality();
290
291 for (FB_SIZE_T j = 0; j < leaderKeyCount; j++)
292 {
293 dsc desc;
294 (*m_leader.keys)[j]->getDesc(tdbb, csb, &desc);
295
296 USHORT keyLength = desc.isText() ? desc.getStringLength() : desc.dsc_length;
297
298 if (IS_INTL_DATA(&desc))
299 keyLength = INTL_key_length(tdbb, INTL_INDEX_TYPE(&desc), keyLength);
300 else if (desc.isTime())
301 keyLength = sizeof(ISC_TIME);
302 else if (desc.isTimeStamp())
303 keyLength = sizeof(ISC_TIMESTAMP);
304 else if (desc.dsc_dtype == dtype_dec64)
305 keyLength = Decimal64::getKeyLength();
306 else if (desc.dsc_dtype == dtype_dec128)
307 keyLength = Decimal128::getKeyLength();
308
309 m_leader.keyLengths[j] = keyLength;
310 m_leader.totalKeyLength += keyLength;
311 }
312
313 auto keyCount = 0;
314
315 for (FB_SIZE_T i = 1; i < count; i++)
316 {
317 RecordSource* const sub_rsb = args[i];
318 fb_assert(sub_rsb);
319
320 m_cardinality *= sub_rsb->getCardinality();
321
322 SubStream sub;
323 sub.buffer = FB_NEW_POOL(csb->csb_pool) BufferedStream(csb, sub_rsb);
324 sub.keys = keys[i];
325 const FB_SIZE_T subKeyCount = sub.keys->getCount();
326 sub.keyLengths = FB_NEW_POOL(csb->csb_pool) ULONG[subKeyCount];
327 sub.totalKeyLength = 0;
328
329 keyCount += subKeyCount;
330
331 for (FB_SIZE_T j = 0; j < subKeyCount; j++)
332 {
333 dsc desc;
334 (*sub.keys)[j]->getDesc(tdbb, csb, &desc);

Callers

nothing calls this directly

Calls 10

INTL_key_lengthFunction · 0.85
BufferedStreamClass · 0.85
getCardinalityMethod · 0.80
isTextMethod · 0.80
getStringLengthMethod · 0.80
isTimeMethod · 0.80
isTimeStampMethod · 0.80
getCountMethod · 0.45
getDescMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected