Skip to content

Commit

Permalink
Use platform dependent constants in atoms trie
Browse files Browse the repository at this point in the history
Use 62 bits per atom id on 64bit platform and 30 bits per atom id on
32bits platform.
  • Loading branch information
vsbogd committed Mar 6, 2025
1 parent c2c7d2a commit 0a7f84f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/src/space/grounding/index/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,16 @@ enum AtomMatchMode {
Unification,
}

const TK_STORE_MASK: usize = 0b1 << 63;
const TK_MATCH_MASK: usize = 0b1 << 62;
const TK_VALUE_MASK: usize = !(0b11 << 62);

const TK_STORE_HASH: usize = 0b0 << 63;
const TK_STORE_INDEX: usize = 0b1 << 63;
const TK_MATCH_EXACT: usize = 0b0 << 62;
const TK_MATCH_CUSTOM: usize = 0b1 << 62;
const BITS_PER_ID: u32 = usize::BITS - 2;

const TK_STORE_MASK: usize = 0b10 << BITS_PER_ID;
const TK_MATCH_MASK: usize = 0b01 << BITS_PER_ID;
const TK_VALUE_MASK: usize = !(0b11 << BITS_PER_ID);

const TK_STORE_HASH: usize = 0b00 << BITS_PER_ID;
const TK_STORE_INDEX: usize = 0b10 << BITS_PER_ID;
const TK_MATCH_EXACT: usize = 0b00 << BITS_PER_ID;
const TK_MATCH_CUSTOM: usize = 0b01 << BITS_PER_ID;

/// Compact representation of the atom from the trie. It represents each
/// atom using single [usize] value. It keeps value of the key, key matching
Expand Down

0 comments on commit 0a7f84f

Please sign in to comment.