add crc32 filters

This commit is contained in:
ghost 2024-02-12 17:16:45 +02:00
parent d6b412cc39
commit 5289a0ac8f

View File

@ -17,8 +17,7 @@ class Manticore
?array $meta = [], ?array $meta = [],
?string $host = '127.0.0.1', ?string $host = '127.0.0.1',
?int $port = 9308 ?int $port = 9308
) ) {
{
$this->_client = new Client( $this->_client = new Client(
[ [
'host' => $host, 'host' => $host,
@ -32,6 +31,22 @@ class Manticore
$this->_index->create( $this->_index->create(
[ [
'crc32namespace' =>
[
'type' => 'int'
],
'crc32transaction' =>
[
'type' => 'int'
],
'crc32key' =>
[
'type' => 'int'
],
'crc32value' =>
[
'type' => 'int'
],
'block' => 'block' =>
[ [
'type' => 'int' 'type' => 'int'
@ -64,33 +79,33 @@ class Manticore
string $transaction, string $transaction,
string $key, string $key,
string $value string $value
): int ) {
{ return $this->_index->addDocument(
$crc32transaction = crc32(
$transaction
);
if (!$this->_index->getDocumentById($crc32transaction))
{
$this->_index->addDocument(
[ [
'crc32namespace' => crc32(
$namespace
),
'crc32transaction' => crc32(
$transaction
),
'crc32key' => crc32(
$key
),
'crc32value' => crc32(
$value
),
'block' => $block, 'block' => $block,
'namespace' => $namespace, 'namespace' => $namespace,
'transaction' => $transaction, 'transaction' => $transaction,
'key' => $key, 'key' => $key,
'value' => $value 'value' => $value
], ]
$crc32transaction
); );
} }
return $crc32transaction;
}
public function drop( public function drop(
?bool $silent = false ?bool $silent = false
) ) {
{
return $this->_index->drop( return $this->_index->drop(
$silent $silent
); );