-
Notifications
You must be signed in to change notification settings - Fork 0
Concept Berkeley DB
Turkce Dokumantasyon | English Documentation
Category: Core Concepts & Architecture
Subsystem: Storage Engine & I/O Layer (DB_File)
Entry Type: Core Architectural Choice & Storage Engine Analysis
At the heart of AmberDB lies the industry-proven Berkeley DB Version 1.x Hash Engine (DB_File) for low-level physical data persistence and direct key-value mapping.
Provided as a standard Perl core extension, DB_File maps on-disk files directly to Perl hashes (tie %hash, 'DB_File', $filepath). AmberDB builds an entire enterprise-grade NoSQL infrastructure on top of this battle-tested, ultra-lightweight C library—adding schema validation, precomputed binary inverted indexes, Strict 2PL ACID transactions, multi-dimensional faceting, and multilingual phonetic search.
AmberDB and Berkeley DB (DB_File) Stack
Application CRUD & Queries ($adb->read_id, search_table, field_filter)
|
v
┌─────────────────────────────────────────────────────────────┐
│ AmberDB Layer │
│ Schema Validation, 8-Byte Binary Indexes (.inx, .fld, .src)│
│ Strict 2PL Locks, Undo-Journal (.txn), Locale & Faceting │
└─────────────────────────────────────────────────────────────┘
|
v
┌─────────────────────────────────────────────────────────────┐
│ Berkeley DB (DB_File Hash) │
│ Pure C Library, O(1) Hash Access, OS Memory Mapping │
└─────────────────────────────────────────────────────────────┘
|
v
┌─────────────────────────────────────────────────────────────┐
│ Operating System Page Cache & Disk I/O │
└─────────────────────────────────────────────────────────────┘
The deliberate architectural choice of DB_File over client-server engines (MySQL, PostgreSQL, MongoDB) is rooted in key technical advantages:
- Client-server database systems incur overhead from TCP socket negotiation, network packet framing, SQL parsing, and BSON/JSON serialization on every request.
-
DB_Fileis an embedded C library executing within the Perl process address space. Single-key$O(1)$ lookups execute with zero network overhead.
- Berkeley DB data files leverage the host operating system's native Page Cache and memory mapping.
- Frequently queried records are served directly from OS RAM at microsecond speeds without incurring physical disk I/O.
- AmberDB thrives in multi-process Perl web server environments (Starman, Apache mod_perl, Plack workers).
- All independent worker processes access the same
.dband.inxfiles concurrently with atomic POSIXflocksynchronization.
-
DB_Filehas been standard across all Unix, Linux, Windows, and macOS distributions since the 1990s. - It requires no dedicated background daemons or runtime VMs, performing with equal reliability on embedded micro-controllers (e.g. Raspberry Pi) and multi-core enterprise cloud servers.
While raw DB_File is strictly a key-value store lacking query planning, validation, and multi-table transactions, AmberDB elevates it to a complete NoSQL ecosystem:
- Schema & Block Data Model: Transforms raw key-values into typed, extensible document arrays.
-
Precomputed Binary Indexes: Implements
.fld,.src,.fac, and.srtindexes, delivering instant$O(1)$ equivalents for SQLWHERE,LIKE,GROUP BY, andORDER BY. - Strict 2PL & Undo Journal: Provides full ACID guarantees with automatic crash recovery.
- Multilingual Search Engine: Adds 9-language phonetic search and Unicode Collation.
Single Record Lookup Latency (1 Million Records)
AmberDB (DB_File + Inx) | 0.008 ms (8 microseconds)
SQLite (Embedded B-Tree) | 0.045 ms (45 microseconds)
MySQL / Postgres (TCP) | 0.850 ms (850 microseconds)
MongoDB (Socket BSON) | 1.200 ms (1200 microseconds)
AmberDB — High-Performance Schema-Driven NoSQL Database Engine for Perl.
Copyright 2005-2026 Maruf Cetin. Released under the Artistic License 2.0.
CPAN · GitHub Repository · Issue Tracker
- Berkeley DB (DB_File) Engine
- AmberDB Table Schema
- Global Flags
- Table Schema Flags
- Directory Structure
- File Structure (Extensions)
- Repeat Blocks
- Auto-Increment ID
- ASCII ID
- Relational Records
- Record Anatomy
- JOIN-Free Architecture
- Packed Binary Index
- Strict 2PL Locking
- Undo Journal & Rollback
- Tiered Junk Indexing
- Disjunctive Faceting
- Phonetic Accent Search
- 2-Pillar Disaster Recovery
- RAM-Disk Acceleration
- In-Memory Schema Mutation
- Simple Mode
- new
- config
- set_datadir
- insert_id
- insert_list
- modify_id
- modify_list
- delete_id
- delete_list
- read_id
- read_all
- read_list
- exist_id
- exist_list
- exist_table
- table_count
- table_keys
- table_lastid
- table_attr
- table_create
- field_fetch
- field_filter
- search_table
- facet_menu
- field_fltkeys
- field_allfltkeys
- facet_rules
- slug_read
- slug_fetch
- transact_start
- transact_end
- transact_commit
- transact_rollback
- transact_recover
- flock_open
- flock_close
- cache_setup
- cache_read
- cache_write
- cache_delete
- cache_preload
- cache_ensure
- buffer_write
- buffer_read
- buffer_delete
- recs_scan
- recs_get
- recs_put
- recs_del
- locale_uc
- locale_lc
- locale_sort
- locale_to_ascii
- locale_num2text
- locale_format_currency
- locale_format_date
- array_sort
- array_punch
- array_filter
- array_sublist
- deep_copy
- log_owner
- use_counter
- use_junk
- keep_deleted
- auto_id
- buffer_write
- simple
- no_write
- no_backup
- jnktype
- keys_only
- id_type
- language
- .db · .table · .dbase
- .inx · .fld · .src
- .fac · .srt · .slg
- .unq · .del · .aut
- .cnt · .txn · .amberdb
- .csv · .cache · .tmp