NAME
AmberDB::Index - Inverted search, exact field match, binary sort, and URL slug rewrite indexing engine
SYNOPSIS
# Indexing methods are called directly on the AmberDB instance ($adb):
# 1. URL Slug generation and reverse lookup (.slg)
my $slug = $adb->set_slug("catalog_product", $record_ref, 1);
my $slug_map = $adb->get_slug("catalog_product", 0, 101, 102);
# 2. Normalization of array or delimited values into clean lists and .unq IDs
my @unq_ids = $adb->field_to_list($raw_val, 'write', $table_path, $table_info, $blk);
# 3. Monotonic sort key generation for fixed-width sorting (.srt)
my $key = $adb->normalize_sort_key("1250.50", "num");
DESCRIPTION
AmberDB::Index manages flat-file inverted search indexes (.src), exact field matching indexes (.fld), primary key lists (.inx), binary pre-sorted record indexes (.srt), and bidirectional URL slug rewrite dictionaries (.slg).
Facet forward indexing (.fac) is handled by AmberDB::Index::Facet, and dual-tier cold record indexing (.jinx, .jfld, .jsrc) is managed by AmberDB::Index::Junk.
Inheritance Note: AmberDB inherits from AmberDB::Index via use parent. All indexing methods can be called directly on $adb.
METHODS
field_to_list($value, [$mode], [$table_path], [$table_info], [$blk])
Converts ARRAY references, comma/semicolon-delimited strings, or single scalars into a normalized list of trimmed values. =over 4 =item * In 'write' mode: Registers text values into the per-block unique/dictionary index (_${blk}.unq) with auto-incrementing numeric IDs (or validates foreign key IDs for RDBM fields). =item * In 'read' mode: Resolves existing string IDs from _${blk}.unq without creating new dictionary entries. =back
my @ids = $adb->field_to_list("Red, Blue, Green", 'write', $path, $info, 3);
normalize_sort_key($value, $type, [$length])
Normalizes an input value into a fixed-width byte key for fast monotonic sorting in binary .srt files: =over 4 =item * num / decimal: Adds a 1e12 (1,000,000,000,000) offset for signed float/integer monotonic sorting (%020.6f format). =item * string / ascii: Converts to ASCII, removes punctuation, truncates to 8 bytes (or $length), and pads with spaces. =item * date: Converts date expressions to 14-character YYYYMMDDHHMMSS timestamps. =back
my $sort_key = $adb->normalize_sort_key("249.90", "num");
set_slug($table_id, $record, [$write_mode])
Generates a URL-friendly ASCII slug from designated schema title blocks (slug_block) and registers bidirectional mapping in _0.slg (Record ID -> Slug) and _1.slg (Slug -> Record ID).
my $slug = $adb->set_slug("catalog_product", \@record, 1);
# => "kablosuz-bluetooth-kulaklik"
get_slug($table_id, [$type], @record_or_slug_ids)
Resolves URL slugs or reverse-maps slugs back to record IDs. =over 4 =item * $type = 0: Returns { record_id => slug } (default, reads _0.slg). =item * $type = 1: Returns { slug => record_id } (reads _1.slg). =back
my $slugs = $adb->get_slug("catalog_product", 0, 101, 102);
# => { 101 => "kablosuz-kulaklik", 102 => "akilli-saat" }
rdbm_target($table_info, $blk)
Returns ($target_table, $target_blk) if the specified schema block is configured as a relational foreign key (RDBM), or empty list / undef otherwise.
my ($target_table, $target_blk) = $adb->rdbm_target($schema, 2);
repeat_fields($table_info, @record)
Consolidates dynamic repeat columns (defined in $table_info->{repeat_ids} and repeat_start) into a single comma-separated value.
Low-Level Index Maintenance Methods
These methods are called automatically by AmberDB during CRUD operations (insert_id, modify_id, delete_id):
records_add / records_del— Updateskeys,count, andlastidin primary.inxfiles.match_add / match_modify / match_del— Manages exact-match inverted index files (_${blk}.fld).search_add / search_modify / search_del— Manages full-text keyword search index files (_${blk}.src).sort_add / sort_modify / sort_del— Manages binary pre-sorted record index files (_${blk}.srt).
AUTHOR
Maruf Cetin <marufcetin@gmail.com>
LICENSE AND COPYRIGHT
Copyright (C) 2006-2026 Maruf Cetin.
This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 1418:
Non-ASCII character seen before =encoding in '—'. Assuming UTF-8