samp.directory
← Skrypty i biblioteki

estxvn/omp-index

High-performance C++20 component for open.mp, designed for scalable in-memory indexing, with direct and bidirectional mappings, one-to-many associations, equality-based secondary indexes, and atomic batch operations.

Plugin★ 7zaktualizowano 20 godzin temuMITC++
Otwórz na GitHubie
Wypróbuj w kompilatorze Pawn →

Dodaje jej pliki include, razem z bibliotekami, od których zależy, do kompilatora Pawn w twojej przeglądarce, gotowe do dołączenia w skrypcie.

README.md

omp-index

omp-index 2.0.0 manages in-memory associations for open.mp and replaces IndexWeaver 1.x with an incompatible Pawn API. Direct registries map sparse signed IDs to nonnegative indices. Bidirectional registries also support inverse lookup and enforce one-to-one ownership of each index. Group registries provide one-to-many relations and secondary equality indexes, with atomic member moves and bounded pages. Conditional writes and atomic pair batches protect the component's index state during updates and reloads.

The production qualification covers the exact Windows x86 and Linux x86 Release ZIPs on official open.mp v1.6.7.3218. Both packages use the scalar75 storage engine and passed a continuous 24-hour workload and independent replay. Final production validation

Installation

  1. Select omp-index-2.0.0-windows-x86.zip or omp-index-2.0.0-linux-x86.zip for the matching open.mp v1.6.7.3218 x86 server. Check the archive SHA-256 against the published checksum before extracting it. GitHub releases · Frozen package hashes
  2. Stop the server and remove any previous omp-index or IndexWeaver binary from components/. These builds share the same open.mp UID, and the loader accepts one component per UID.
  3. Place components/Index.dll or components/Index.so in the server's components/ directory, alongside its Pawn component. Copy include/omp_index.inc from the same ZIP into your Pawn compiler's include path.
  4. Compile your script with #include <omp_index>. Start the server and check for Index 2.0.0: loaded and successful native calls. idx_get_version reports the loaded component version, while IDX_INCLUDE_VERSION identifies the include used at compile time.

Keep one handle array for each registry and check the returned IDX_STATUS before using any output.

#include <open.mp>
#include <omp_index>

new g_ClanIndex[IDX_HANDLE_CELLS];

main() {}

public OnGameModeInit() {
	new IDX_STATUS:status = idx_create(IDX_BIJECTIVE, g_ClanIndex);

	if (status != IDX_OK) {
		printf("[Index] Registry creation failed: %d", _:status);
		return 1;
	}

	new const clans[] = {12, 25, 48, 72, 105};
	new const indices[] = {0, 1, 2, 3, 4};
	new failed_row = -1;

	status = idx_set_many(g_ClanIndex, sizeof(clans), clans, sizeof(clans), indices, sizeof(indices), failed_row, IDX_INSERT_ONLY);

	if (status != IDX_OK) {
		printf("[Index] Clan loading failed: status=%d row=%d", _:status, failed_row);
	} else {
		printf("[Index] Loaded %d clans.", sizeof(clans));
	}

	return 1;
}

stock IDX_STATUS:GetClanIndex(clanid, &index) {
	return idx_get(g_ClanIndex, clanid, index);
}

IDs and group keys may use every signed Pawn cell value. For direct and bidirectional registries, the stored index must be nonnegative. Check the result and the bounds of any Pawn array before indexing it. The script owns the lifetime and identifiers of players, vehicles and other entities, the synchronization with its arrays and database, and treatment of every status. A successful lookup gives the stored index and does not establish that an engine entity or external database row still exists.

The examples cover account ↔ player lookup, staged reloads and properties grouped by owner. For PostgreSQL or any other database, validate that IDs fit into a signed Pawn cell before using them as keys, and keep the application arrays synchronized with the successful registry update.

Handles, failures and reloads

Give idx_create a zero-initialized result array or a stale handle. It refuses to replace a currently live handle and preserves the array on failure. A live token from another AMX returns IDX_ERROR_WRONG_OWNER. idx_destroy leaves the original three Pawn cells unchanged while invalidating every copy of the token. Keep handles inside one component lifetime and treat their contents as opaque.

Registries belong to the creating AMX. Unloading a gamemode or filterscript destroys its registries without further allocation. A filterscript that stays loaded across GMX keeps its own registries. Any reloaded script receives a fresh owner attachment even when the server reuses an AMX address. Use idx_destroy for early release and rely on automatic cleanup at server shutdown, when native dispatch may already be closed. Calls are synchronous on the server thread. Reserve, shrink, clear and table growth can do substantial work on a large registry.

idx_set_many and idx_remove_many apply an entire pair batch atomically. The lookup batches return a status for each row. Group registries change one membership at a time. To publish a complete replacement, populate a temporary registry of the same kind. Check each batch or membership write and the related Pawn state, then use idx_swap to publish the registry contents in one call. Destroy the temporary handle to release the old data. Pair and memory budgets apply while both copies are live. Application arrays and database state have their own update contracts.

See the 24-native API and compatibility matrix, the pair transaction contracts, and the group registry architecture. The Pawn include also provides six stocks.

Build and test

Use CMake 3.25 or newer and a C++20 compiler. FetchContent resolves pinned source commits. An engine-only build has no SDK or Pawn compiler dependency. Component builds target the official 32-bit open.mp runtime.

cmake -S . -B build-engine -DOMP_INDEX_BUILD_COMPONENT=OFF
cmake --build build-engine --config Debug
ctest --test-dir build-engine -C Debug --output-on-failure
cmake -S . -B build-win32 -A Win32
cmake --build build-win32 --config Release
ctest --test-dir build-win32 -C Release --output-on-failure
cmake --install build-win32 --config Release --prefix stage-win32
cmake -S . -B build-linux-x86 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32
cmake --build build-linux-x86 --parallel
ctest --test-dir build-linux-x86 --output-on-failure
cmake --install build-linux-x86 --prefix stage-linux-x86

The Linux component requires an x86-capable compiler, linker and system libraries. To run the local storage comparison, enable OMP_INDEX_BUILD_BENCHMARKS. Enable OMP_INDEX_SANITIZERS on supported Linux GCC or Clang configurations and OMP_INDEX_BUILD_FUZZERS for the Clang sanitizer fuzz build. Reuse a populated FetchContent build directory or supply complete source overrides, including each nested SDK dependency beneath the SDK source directory. The dependency inventory records pins and attribution.

CTest lists independently runnable cases under the index, groups, registry and pawn labels. The test executables also accept one exact scenario name and run their entire group when called with no arguments. Checks stay active in Debug and Release.

ctest --test-dir build -C Release --show-only
ctest --test-dir build -C Release -R '^index\.transactions$' --output-on-failure --no-tests=error
ctest --test-dir build -C Release -L '^fault-injection$' --output-on-failure --no-tests=error
ctest --test-dir build -C Release -LE '^heavy$' --output-on-failure --no-tests=error
ctest --test-dir build -C Release -L '^heavy$' --output-on-failure --no-tests=error

The heavy tests exercise the full default staging limits in Release and RelWithDebInfo. The ordinary stress case runs a fixed operation count. The pinned Pawn headers enable mock-AMX tests on host builds with OMP_INDEX_BUILD_PAWN_TESTS=ON. Real lifecycle integration uses the x86 package, the pinned open.mp server and Pawn compiler, as described in the qualification instructions.

On Linux, use matching Clang, llvm-profdata and llvm-cov versions for source-based coverage. The script writes JSON, a text summary, HTML annotations and JUnit to the new output directory. Its source scope is the standalone core and Pawn adapter.

CC=clang-18 CXX=clang++-18 LLVM_COV=llvm-cov-18 LLVM_PROFDATA=llvm-profdata-18 \
  bash scripts/measure_coverage.sh build-coverage

Startup configuration

All options use positive integer values under omp_index in the server configuration. Adjust the defaults to measured workloads on the target host.

OptionDefaultMeaning
max_slots1,024Maximum materialized slots, including retired slots.
max_registries_per_amx128Maximum live registry count for a single AMX. Must fit within max_slots.
max_pairs_per_registry1,048,576Maximum active pairs or memberships in a registry. Also caps pair reservation.
max_total_pairs2,097,152Maximum combined pairs and memberships, including staging registries.
max_batch_rows4,096Maximum rows per bulk native or group page.
max_requested_bytes134,217,728Maximum requested bytes tracked by the manager. Includes retained capacity and simultaneous scratch and replacement allocations.

The memory budget covers slot metadata, owner contexts, registry objects and their live storage allocations. It also counts allocated-but-empty capacity and temporary buffers during reserve, shrink or bulk writes. Allocator metadata, native stack usage, runtime objects outside the controlled allocator and process RSS are measured separately. A reserve failure can leave additional table capacity available. It preserves the associations. Destroying a registry releases its storage and returns its slot to the free list. Slot storage is retained up to bounded high-water capacity until shutdown.

Migration from IndexWeaver 1.x

Replace #include <indexweaver> with #include <omp_index>, migrate all legacy native calls and recompile each script. Create an IDX_DIRECT registry per category in its owning script. Choose IDX_BIJECTIVE only when each index has a unique owner and you need inverse lookup. If scripts shared an old category, keep the new registry in one owner and route other scripts' requests through that owner.

IndexWeaver 1.xomp-index 2.0.0
SetMapIndex, GetMapIndex, HasMapIndex, RemoveMapIndexUse idx_set, idx_get, idx_has and idx_remove with a handle. Replace the -1 miss convention with IDX_ERROR_NOT_FOUND for idx_get. Check IDX_OK before using the output.
ClearMapRegistry, ReserveMapRegistry, CountMapRegistryUse idx_clear, idx_reserve and idx_count on the owned pair registry. Reserve uses the v2 resource limits.
ClearAllMapRegistries, CountAllMapRegistriesClear, destroy or count registries through their owning scripts. Keep any application-wide registry inventory in the application.
SetMapDebugLevel, GetMapDebugLevelHandle IDX_STATUS values in the script and use idx_get_stats for owned-registry diagnostics.

Repopulate your registries from the application's authoritative data. After GMX, the new gamemode builds its own registries and surviving filterscripts decide how to refresh references to gamemode entities. Historical IndexWeaver API and behavior

License

omp-index is released under the MIT License. Release ZIPs include the project license and the corresponding third-party notices under licenses/. MIT license · Dependency versions and attribution

batch-operationsbidirectional-mappingcpp20data-structuresgame-servergamemodegenerational-handleshash-tablehigh-performancein-memoryindexingmemory-managementone-to-manyopen-mppawnscalabilitysecondary-indexes

Ta strona jest zbudowana z tego, co GitHub publikuje o repozytorium. samp.directory nie hostuje kodu. Zgłoś problem z tym wpisem

estxvn/omp-index: Plugin SA-MP | samp.directory