Documentation
¶
Overview ¶
Package util provides shared utility functions used across NornicDB packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeMsgpackBytes ¶
DecodeMsgpackBytes safely decodes msgpack from an in-memory payload with size validation.
func DecodeMsgpackFile ¶
DecodeMsgpackFile safely decodes msgpack from a file, rejecting oversized payloads.
func HashStringToInt64 ¶
HashStringToInt64 converts a string ID to an int64 for Neo4j Bolt protocol compatibility. NornicDB uses string IDs (UUIDs or custom strings), but Bolt protocol expects int64 IDs. This function uses FNV-1a hash algorithm for deterministic conversion with good distribution.
FNV-1a (Fowler-Noll-Vo) is a fast, non-cryptographic hash function that:
- Produces deterministic results (same input = same output)
- Has good distribution (fewer collisions than simple multiplicative hashing)
- Is fast and suitable for high-frequency operations
The hash uses FNV-1a 64-bit variant with offset basis 14695981039346656037.
Example:
HashStringToInt64("user-123") => 1234567890123456789
HashStringToInt64("user-123") => 1234567890123456789 (same result)
func MaxMsgpackDecodeBytes ¶
func MaxMsgpackDecodeBytes() int64
MaxMsgpackDecodeBytes returns the configured maximum number of bytes accepted for msgpack decode operations.
func ValidateMsgpackPayloadSize ¶
ValidateMsgpackPayloadSize rejects payloads larger than the configured cap.
Types ¶
This section is empty.