Added alias option for Vector field (#1221)

* Added support for new arguments for BITPOS, BITCOUNT commands (#1045)

* Added support for new arguments for EXPIRE, EXPIREAT commands (#1046)

* Extended core support by implementing SORT_RO command (#1044)

* Added support for SORT_RO command

* Codestyle fixes

* Added command description

---------

Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>

* fix deprecated call

* Added support for container commands (#1049)

* Added support for container commands FUNCTION LOAD, FUNCTION DELETE and FCALL

* Changed ContainerInterface and AbstractContainer

* Re-implement logic of abstract methods

---------

Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>

* Added stream commands to KeyPrefixProcessor (#1051)

Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>

* Fix return type of ReplicationInterface::getSlaves (#1111)

* Codestyle fixes

* Changed return annotation

* Added alias option for Vector field

---------

Co-authored-by: Vladyslav Vildanov <vladyslavvildanov@Vladyslav-Vildanov-MacBook-Pro.local>
Co-authored-by: Till Krüss <till@kruss.io>
Co-authored-by: Stephan <glaubinix@users.noreply.github.com>
This commit is contained in:
Vladyslav Vildanov
2023-03-27 17:01:55 +03:00
committed by GitHub
parent c61af25f8a
commit 55ce9cd2f4
2 changed files with 9 additions and 5 deletions
@@ -12,7 +12,7 @@
namespace Predis\Command\Argument\Search\SchemaFields;
class VectorField implements FieldInterface
class VectorField extends AbstractField
{
/**
* @var array
@@ -23,13 +23,17 @@ class VectorField implements FieldInterface
* @param string $fieldName
* @param string $algorithm
* @param array $attributeNameValueDictionary
* @param string $alias
*/
public function __construct(
string $fieldName,
string $algorithm,
array $attributeNameValueDictionary
array $attributeNameValueDictionary,
string $alias = ''
) {
array_push($this->fieldArguments, $fieldName, 'VECTOR', $algorithm, count($attributeNameValueDictionary));
$this->setCommonOptions('VECTOR', $fieldName, $alias);
array_push($this->fieldArguments, $algorithm, count($attributeNameValueDictionary));
$this->fieldArguments = array_merge($this->fieldArguments, $attributeNameValueDictionary);
}
@@ -22,7 +22,7 @@ class VectorFieldTest extends TestCase
public function testReturnsCorrectFieldArgumentsArray(): void
{
$this->assertSame(
['field_name', 'VECTOR', 'FLAT', 2, 'attribute_name', 'attribute_value'],
(new VectorField('field_name', 'FLAT', ['attribute_name', 'attribute_value']))->toArray());
['field_name', 'AS', 'field', 'VECTOR', 'FLAT', 2, 'attribute_name', 'attribute_value'],
(new VectorField('field_name', 'FLAT', ['attribute_name', 'attribute_value'], 'field'))->toArray());
}
}