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

Method aggPass

src/dsql/AggNodes.cpp:381–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381bool AggNode::aggPass(thread_db* tdbb, Request* request) const
382{
383 dsc* desc = NULL;
384
385 if (arg)
386 {
387 desc = EVL_expr(tdbb, request, arg);
388 if (request->req_flags & req_null)
389 return false;
390
391 if (distinct)
392 {
393 fb_assert(asb);
394
395 // "Put" the value to sort.
396 impure_agg_sort* asbImpure = request->getImpure<impure_agg_sort>(asb->impure);
397 UCHAR* data;
398 asbImpure->iasb_sort->put(tdbb, reinterpret_cast<ULONG**>(&data));
399
400 MOVE_CLEAR(data, asb->length);
401
402 if (asb->intl)
403 {
404 // Convert to an international byte array.
405 dsc to;
406 to.dsc_dtype = dtype_text;
407 to.dsc_flags = 0;
408 to.dsc_sub_type = 0;
409 to.dsc_scale = 0;
410 to.dsc_ttype() = ttype_sort_key;
411 to.dsc_length = asb->keyItems[0].getSkdLength();
412 to.dsc_address = data;
413 INTL_string_to_key(tdbb, INTL_TEXT_TO_INDEX(desc->getTextType()),
414 desc, &to, INTL_KEY_UNIQUE);
415 }
416
417 dsc toDesc = asb->desc;
418 toDesc.dsc_address = data +
419 (asb->intl ? asb->keyItems[1].getSkdOffset() : 0);
420 MOV_move(tdbb, desc, &toDesc);
421
422 // dimitr: Here we add a monotonically increasing value to the sort record.
423 // It allows the record to look more random than it was originally.
424 // This helps the quick sort algorithm to avoid the worst-case of
425 // all equal values (see CORE-214).
426
427 ULONG* const pDummy = reinterpret_cast<ULONG*>(data + asb->length - sizeof(ULONG));
428 *pDummy = asbImpure->iasb_dummy++;
429
430 return true;
431 }
432 }
433
434 aggPass(tdbb, request, desc);
435 return true;
436}
437
438void AggNode::aggFinish(thread_db* /*tdbb*/, Request* request) const

Callers

nothing calls this directly

Calls 15

EVL_exprFunction · 0.85
INTL_string_to_keyFunction · 0.85
MOV_moveFunction · 0.85
createFunction · 0.85
MOV_make_string2Function · 0.85
EVL_make_valueFunction · 0.85
MOV_compareFunction · 0.85
MOV_get_dec128Function · 0.85
MOV_get_doubleFunction · 0.85
dsc_ttypeMethod · 0.80
getSkdLengthMethod · 0.80
getTextTypeMethod · 0.80

Tested by

no test coverage detected