Database¶
We support Postgres database.
DB scheme¶
- class luna_events.db.events_db_tools.models.events_models.AttachResult(**kwargs)¶
Attach result ORM class
- class luna_events.db.events_db_tools.models.events_models.BodyDescriptor(**kwargs)¶
Descriptor ORM class.
- class luna_events.db.events_db_tools.models.events_models.BodyDetectResult(**kwargs)¶
Body detection results.
- class luna_events.db.events_db_tools.models.events_models.Descriptor(**kwargs)¶
Descriptor ORM class.
- class luna_events.db.events_db_tools.models.events_models.Event(**kwargs)¶
Event ORM class.
- class luna_events.db.events_db_tools.models.events_models.EventMatchResult(**kwargs)¶
Match result ORM class.
- class luna_events.db.events_db_tools.models.events_models.EventStatsColumn(*args, targetable=False, filterable=False, **kwargs)¶
Column which used for stats requests.
- targetable¶
column is target able
- filterable¶
column is filter able
- class luna_events.db.events_db_tools.models.events_models.FaceDetectResult(**kwargs)¶
Detect result ORM class.
- class luna_events.db.events_db_tools.models.events_models.FaceMatchResult(**kwargs)¶
Match result ORM class.
- class luna_events.db.events_db_tools.models.events_models.Location(**kwargs)¶
- class luna_events.db.events_db_tools.models.events_models.Migrations(**kwargs)¶
Migrations ORM class.
- class luna_events.db.events_db_tools.models.events_models.Tag(**kwargs)¶
Tag ORM class
DB matching installation¶
You can use the VLMAtch function to perform descriptors matching using PostgreSQL database.
To enable matching in db, one needs to:
#) Compile a library with a VLMatch function using appropriate database development libraries. The library is compiled according to the current database version.
Import the library in the running database and check it availability.
#) Enable USE_DB_MATCH_FUNCTION parameter in the service settings (/var/lib/luna/current/luna-events/luna_events/config/config.py).
Instruction for PostgreSQL database¶
You can find all the required files for the VLMatch user-defined extension (UDx) compilation in the following directory:
/var/lib/luna/current/luna-events/base_scripts/database_matching/postgres
The following instruction describes installation for PostgreSQL 12.
For VLMatch UDx function compilation one needs to:
Make sure, that PostgreSQL of the required version is installed and launched.
Install the required PostgreSQL development environment. You can find more information at postgres installation manual.
The llvm-toolset-7-clang is required for postgresql12-devel. Install it from the centos-release-scl-rh
repository.
yum -y install centos-release-scl-rh
yum -y --enablerepo=centos-sclo-rh-testing install llvm-toolset-7-clang
Then install the development environment.
sudo yum -y install postgresql12 postgresql12-server postgresql12-devel
Install the gcc-c++ package. The package version 4.8 or higher is required.
yum -y install gcc-c++.x86_64
Install CMAKE. The version 3.5 or higher is required.
Open the make.sh script using a text editor. It includes paths to the currently used PostgreSQL version. Change the following values (if necessary):
SDK_HOME
specifies the path to PostgreSQL home directory. The default value is/usr/pgsql-12/include/server
;LIB_ROOT
specifies the path to PostgreSQL library root directory. The default value is/usr/pgsql-12/lib
.
Go to the make.sh script directory and run it:
cd /var/lib/luna/current/luna-events/base_scripts/database_matching/postgres/
chmod +x make.sh
./make.sh
Define the function inside the service database:
sudo -u postgres -h 127.0.0.1 -- psql -d luna_events -c "CREATE FUNCTION VLMatch(bytea, bytea, int) RETURNS float8 AS 'VLMatchSource.so', 'VLMatch' LANGUAGE C PARALLEL SAFE;"
Test function by sending re following request to the service database:
sudo -u postgres -h 127.0.0.1 -- psql -d luna_events -c "SELECT VLMatch('\x1234567890123456789012345678901234567890123456789012345678901234'::bytea, '\x0123456789012345678901234567890123456789012345678901234567890123'::bytea, 32);"
The result returned by the database must be “0.4765625”.
Check that the
USE_DB_MATCH_FUNCTION
parameter is enabled in the service settings (/var/lib/luna/current/luna-events/luna_events/config/config.py).