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

Function make_int64_key

src/jrd/btr.cpp:6388–6431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6386
6387
6388static INT64_KEY make_int64_key(SINT64 q, SSHORT scale)
6389{
6390/**************************************
6391 *
6392 * m a k e _ i n t 6 4 _ k e y
6393 *
6394 **************************************
6395 *
6396 * Functional description
6397 * Make an Index key for a 64-bit Integer value.
6398 *
6399 **************************************/
6400
6401 // Following structure declared above in the modules global section
6402 //
6403 // static const struct {
6404 // FB_UINT64 limit; --- if abs(q) is >= this, ...
6405 // SINT64 factor; --- then multiply by this, ...
6406 // SSHORT scale_change; --- and add this to the scale.
6407 // } int64_scale_control[];
6408 //
6409
6410 // Before converting the scaled int64 to a double, multiply it by the
6411 // largest power of 10 which will NOT cause an overflow, and adjust
6412 // the scale accordingly. This ensures that two different
6413 // representations of the same value, entered at times when the
6414 // declared scale of the column was different, actually wind up
6415 // being mapped to the same key.
6416
6417 int n = 0;
6418 const FB_UINT64 uq = (FB_UINT64) ((q >= 0) ? q : -q); // absolute value
6419
6420 while (uq < int64_scale_control[n].limit)
6421 n++;
6422
6423 q *= int64_scale_control[n].factor;
6424 scale -= int64_scale_control[n].scale_change;
6425
6426 INT64_KEY key;
6427 key.d_part = ((double) (q / 10000)) / powerof10(scale);
6428 key.s_part = (SSHORT) (q % 10000);
6429
6430 return key;
6431}
6432
6433
6434#ifdef DEBUG_INDEXKEY

Callers 1

compressFunction · 0.85

Calls 1

powerof10Function · 0.85

Tested by

no test coverage detected