Core Library

fwNgsild — JSON-LD @context Engine

The semantic layer that makes NGSI-LD interoperable. Every GE that touches NGSI-LD data needs @context handling — fwNgsild provides it as a shared library.

What It Does

fwNgsild is the JSON-LD @context processing engine for NGSI-LD. It downloads remote @context documents via the fwHttp client, parses them into dual fwHash tables (name→URI and URI→name), caches them thread-safely, and performs full expansion and compaction of NGSI-LD entities.

This is the library that turns short attribute names like "temperature" into fully qualified URIs like "https://uri.fiware.org/ns/data-models#temperature" and back again — the core operation that makes NGSI-LD a linked-data protocol rather than just another JSON API.

Core Capabilities

Why It Exists

Without fwNgsild, every Generic Enabler would reimplement @context handling. The NGSI-LD Broker, the Multi-Agent system, any component that processes NGSI-LD payloads — they all need to expand and compact attribute names, resolve contexts, handle prefixes. That's complex, error-prone code involving HTTP downloads, caching, hash tables, and recursive resolution.

fwNgsild is designed for full JSON-LD compliance. The key design principle: no strcmp shortcuts — everything goes through fwHash. All lookups are uniform O(1) hash operations, making the library correct by construction for any @context, not just the ones the developer anticipated.

Performance

Context lookups are O(1) fwHash operations. Context download happens once per unique @context URL, then the parsed result is cached thread-safely with TTL-based expiration.

Expansion/compaction of a typical 20-attribute entity: ~5–15μs. This is fast enough to be negligible compared to any I/O operation — database access, network calls, or even HTTP parsing.

Dependencies

LibraryRole
fwHttpHTTP client for downloading remote @context documents
fwJsonJSON parser for parsing context documents into FtNode trees
fwAllocBump allocator for all memory allocation during context processing
fwHashHash tables for the dual name↔URI lookup maps

Used By