Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests case with FLOAT16 and BFLOAT16 vectors #1465

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added tests case with FLOAT16 and BFLOAT16 vectors
  • Loading branch information
vladvildanov committed Jun 18, 2024
commit 84a966475c8ad4381d494f460f420ff214cbb325
1 change: 1 addition & 0 deletions .github/workflows/stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
- '8.3'
redis:
- latest
- edge

continue-on-error: ${{ matrix.php == '8.3' }}

Expand Down
2 changes: 1 addition & 1 deletion examples/transaction_using_cas.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function zpop($client, $key)
'cas' => true, // Initialize with support for CAS operations
'watch' => $key, // Key that needs to be WATCHed to detect changes
'retry' => 3, // Number of retries on aborted transactions, after
// which the client bails out with an exception.
// which the client bails out with an exception.
];

$client->transaction($options, function ($tx) use ($key, &$element) {
Expand Down
14 changes: 7 additions & 7 deletions src/Collection/Iterator/CursorBasedIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ public function next()
$this->fetch();
}

if ($this->elements) {
$this->extractNext();
} elseif ($this->cursor) {
goto tryFetch;
} else {
$this->valid = false;
}
if ($this->elements) {
$this->extractNext();
} elseif ($this->cursor) {
goto tryFetch;
} else {
$this->valid = false;
}
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Connection/RelayConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class RelayConnection extends StreamConnection
/**
* The Relay instance.
*
* @var \Relay\Relay
* @var Relay
*/
protected $client;

Expand Down Expand Up @@ -151,7 +151,7 @@ protected function assertParameters(ParametersInterface $parameters)
/**
* Creates a new instance of the client.
*
* @return \Relay\Relay
* @return Relay
*/
private function createClient()
{
Expand Down Expand Up @@ -189,7 +189,7 @@ private function createClient()
/**
* Returns the underlying client.
*
* @return \Relay\Relay
* @return Relay
*/
public function getClient()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Pipeline/RelayPipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RelayPipeline extends Pipeline
*/
protected function executePipeline(ConnectionInterface $connection, SplQueue $commands)
{
/** @var \Predis\Connection\RelayConnection $connection */
/** @var RelayConnection $connection */
$client = $connection->getClient();

$throw = $this->client->getOptions()->exceptions;
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPUnit/ArrayHasSameValuesConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* PHPUnit constraint matching arrays with same elements even in different order.
*/
class ArrayHasSameValuesConstraint extends \PHPUnit\Framework\Constraint\Constraint
class ArrayHasSameValuesConstraint extends PHPUnit\Framework\Constraint\Constraint
{
protected $array;

Expand Down
8 changes: 4 additions & 4 deletions tests/PHPUnit/PredisCommandTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class PredisCommandTestCase extends PredisTestCase
/**
* Returns the expected command for tests.
*
* @return Command\CommandInterface|string Instance or FQCN of the expected command
* @return CommandInterface|string Instance or FQCN of the expected command
*/
abstract protected function getExpectedCommand(): string;

Expand All @@ -36,13 +36,13 @@ abstract protected function getExpectedId(): string;
/**
* Returns a new command instance.
*
* @return Command\CommandInterface
* @return CommandInterface
*/
public function getCommand(): Command\CommandInterface
public function getCommand(): CommandInterface
{
$command = $this->getExpectedCommand();

return $command instanceof Command\CommandInterface ? $command : new $command();
return $command instanceof CommandInterface ? $command : new $command();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/PHPUnit/PredisTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Base test case class for the Predis test suite.
*/
abstract class PredisTestCase extends \PHPUnit\Framework\TestCase
abstract class PredisTestCase extends PHPUnit\Framework\TestCase
{
protected $redisServerVersion;
protected $redisJsonVersion;
Expand Down Expand Up @@ -150,7 +150,7 @@ public function assertSameWithPrecision($expected, $actual, int $precision = 0,
* Asserts that a string matches a given regular expression.
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws SebastianBergmann\RecursionContext\InvalidArgumentException
*/
public static function assertMatchesRegularExpression(string $pattern, string $string, $message = ''): void
{
Expand Down Expand Up @@ -295,7 +295,7 @@ protected function getMockConnectionOfType(string $interface, $parameters = null
if (!is_a($interface, '\Predis\Connection\NodeConnectionInterface', true)) {
$method = __METHOD__;

throw new \InvalidArgumentException(
throw new InvalidArgumentException(
"Argument `\$interface` for $method() expects a type implementing Predis\Connection\NodeConnectionInterface"
);
}
Expand Down Expand Up @@ -423,7 +423,7 @@ public function isRedisServerVersion(string $operator, string $version): bool
* decorates test methods while the version of the Redis server used to run
* integration tests is retrieved directly from the server by using `INFO`.
*
* @throws \PHPUnit\Framework\SkippedTestError When the required Redis server version is not met
* @throws PHPUnit\Framework\SkippedTestError When the required Redis server version is not met
*/
protected function checkRequiredRedisServerVersion(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPUnit/RedisCommandConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* PHPUnit constraint to verify that a Redis command matches certain conditions.
*/
class RedisCommandConstraint extends \PHPUnit\Framework\Constraint\Constraint
class RedisCommandConstraint extends PHPUnit\Framework\Constraint\Constraint
{
protected $commandID;
protected $arguments;
Expand Down
6 changes: 3 additions & 3 deletions tests/Predis/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function testConstructorWithClusterArgument(): void
*/
public function testConstructorWithReplicationArgument(): void
{
$replication = new Connection\Replication\MasterSlaveReplication();
$replication = new MasterSlaveReplication();

$factory = new Connection\Factory();
$replication->add($factory->create('tcp://host1?alias=master'));
Expand Down Expand Up @@ -912,7 +912,7 @@ public function testGetClientByMethodSupportsSelectingConnectionByRole(): void
*/
public function testGetClientByMethodSupportsSelectingConnectionByCommand(): void
{
$command = \Predis\Command\RawCommand::create('GET', 'key');
$command = Command\RawCommand::create('GET', 'key');
$connection = $this->getMockBuilder('Predis\Connection\ConnectionInterface')->getMock();

$aggregate = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')
Expand Down Expand Up @@ -1209,7 +1209,7 @@ public function testGetIteratorWithTraversableConnections(): void
$connection2 = $this->getMockConnection('tcp://127.0.0.1:6382');
$connection3 = $this->getMockConnection('tcp://127.0.0.1:6383');

$aggregate = new \Predis\Connection\Cluster\PredisCluster();
$aggregate = new Connection\Cluster\PredisCluster();

$aggregate->add($connection1);
$aggregate->add($connection2);
Expand Down
2 changes: 1 addition & 1 deletion tests/Predis/Collection/Iterator/HashKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testIterationWithNoResults(): void
->with('key:hash', 0, [])
->willReturn(
[0, [],
]);
]);

$iterator = new HashKey($client, 'key:hash');

Expand Down
27 changes: 27 additions & 0 deletions tests/Predis/Command/Redis/Search/FTCREATE_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Predis\Command\Argument\Search\SchemaFields\NumericField;
use Predis\Command\Argument\Search\SchemaFields\TagField;
use Predis\Command\Argument\Search\SchemaFields\TextField;
use Predis\Command\Argument\Search\SchemaFields\VectorField;
use Predis\Command\Redis\PredisCommandTestCase;

/**
Expand Down Expand Up @@ -86,6 +87,32 @@ public function testCreatesSearchIndexWithGivenArgumentsAndSchema(): void
$this->assertEquals('OK', $actualResponse);
}

/**
* @group connected
* @group relay-resp3
* @return void
* @requiresRediSearchVersion >= 2.8.0
*/
public function testCreatesSearchIndexWithFloat16Vector(): void
{
$redis = $this->getClient();

$schema = [
new VectorField('float16',
'FLAT',
['TYPE', 'FLOAT16', 'DIM', 768, 'DISTANCE_METRIC', 'COSINE']
),
new VectorField('bfloat16',
'FLAT',
['TYPE', 'BFLOAT16', 'DIM', 768, 'DISTANCE_METRIC', 'COSINE']
),
];

$actualResponse = $redis->ftcreate('index', $schema);

$this->assertEquals('OK', $actualResponse);
}

public function argumentsProvider(): array
{
return [
Expand Down
2 changes: 1 addition & 1 deletion tests/Predis/Command/Redis/TimeSeries/TSINFO_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function testReturnsInformationAboutGivenTimeSeries(): void
$redis = $this->getClient();
$expectedResponse = ['totalSamples', 0, 'memoryUsage', 4239, 'firstTimestamp', 0, 'lastTimestamp', 0,
'retentionTime', 60000, 'chunkCount', 1, 'chunkSize', 4096, 'chunkType', 'compressed', 'duplicatePolicy',
'max', 'labels', [['sensor_id', '2'], ['area_id', '32']], 'sourceKey', null, 'rules', []];
'max', 'labels', [['sensor_id', '2'], ['area_id', '32']], 'sourceKey', null, 'rules', []];

$arguments = (new CreateArguments())
->retentionMsecs(60000)
Expand Down
2 changes: 1 addition & 1 deletion tests/Predis/CommunicationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function testCommunicationExceptionHandlingWhenShouldResetConnectionIsFal
* @param int $code Exception code.
* @param Exception $inner Inner exception.
*
* @return \Predis\CommunicationException
* @return CommunicationException
*/
protected function createMockException(
Connection\NodeConnectionInterface $connection,
Expand Down
8 changes: 4 additions & 4 deletions tests/Predis/Configuration/Option/ConnectionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function testDefaultOptionValue(): void
*/
public function testAcceptsNamedArrayWithSchemeToConnectionClassMappings(): void
{
/** @var \Predis\Configuration\OptionsInterface */
/** @var OptionsInterface */
$options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock();

$class = get_class($this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock());
Expand Down Expand Up @@ -139,7 +139,7 @@ public function testUsesParametersOptionToSetDefaultParameters(): void
{
$parameters = ['database' => 5, 'password' => 'mypassword'];

/** @var \Predis\Configuration\OptionsInterface|\PHPUnit\Framework\MockObject\MockObject\MockObject */
/** @var OptionsInterface|\PHPUnit\Framework\MockObject\MockObject\MockObject */
$options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock();
$options
->expects($this->once())
Expand Down Expand Up @@ -184,7 +184,7 @@ public function testAcceptsCallableReturningConnectionFactoryInstance(): void
{
$option = new Connections();

/** @var \Predis\Configuration\OptionsInterface */
/** @var OptionsInterface */
$options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock();

$callable = $this->getMockBuilder('stdClass')
Expand All @@ -211,7 +211,7 @@ public function testThrowsExceptionOnInvalidArguments(): void

$option = new Connections();

/** @var \Predis\Configuration\OptionsInterface */
/** @var OptionsInterface */
$options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock();

$option->filter($options, new stdClass());
Expand Down
10 changes: 5 additions & 5 deletions tests/Predis/Connection/Cluster/RedisClusterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public function testGetIteratorReturnsConnectionsMappedInSlotsMapFetchedFromRedi
);

// TODO: I'm not sure about mocking a protected method, but it'll do for now
/** @var Connection\Cluster\RedisCluster|MockObject */
/** @var RedisCluster|MockObject */
$cluster = $this->getMockBuilder('Predis\Connection\Cluster\RedisCluster')
->onlyMethods(['getRandomConnection'])
->setConstructorArgs([$factory])
Expand Down Expand Up @@ -716,7 +716,7 @@ public function testRetriesExecutingCommandOnConnectionFailureButDoNotAskSlotMap
->willReturn($connection4);

// TODO: I'm not sure about mocking a protected method, but it'll do for now
/** @var Connection\Cluster\RedisCluster|MockObject */
/** @var RedisCluster|MockObject */
$cluster = $this->getMockBuilder('Predis\Connection\Cluster\RedisCluster')
->onlyMethods(['getRandomConnection'])
->setConstructorArgs([$factory])
Expand Down Expand Up @@ -823,7 +823,7 @@ public function testAskSlotMapRetriesOnDifferentNodeOnConnectionFailure(): void
->method('create');

// TODO: I'm not sure about mocking a protected method, but it'll do for now
/** @var Connection\Cluster\RedisCluster|MockObject */
/** @var RedisCluster|MockObject */
$cluster = $this->getMockBuilder('Predis\Connection\Cluster\RedisCluster')
->onlyMethods(['getRandomConnection'])
->setConstructorArgs([$factory])
Expand Down Expand Up @@ -889,7 +889,7 @@ public function testAskSlotMapHonorsRetryLimitOnMultipleConnectionFailures(): vo
->method('create');

// TODO: I'm not sure about mocking a protected method, but it'll do for now
/** @var Connection\Cluster\RedisCluster|MockObject */
/** @var RedisCluster|MockObject */
$cluster = $this->getMockBuilder('Predis\Connection\Cluster\RedisCluster')
->onlyMethods(['getRandomConnection'])
->setConstructorArgs([$factory])
Expand Down Expand Up @@ -1427,7 +1427,7 @@ public function testQueryClusterNodeForSlotMapPauseDurationOnRetry()
->method('create');

// TODO: I'm not sure about mocking a protected method, but it'll do for now
/** @var Connection\Cluster\RedisCluster|MockObject */
/** @var RedisCluster|MockObject */
$cluster = $this->getMockBuilder('Predis\Connection\Cluster\RedisCluster')
->onlyMethods(['getRandomConnection'])
->setConstructorArgs([$factory])
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

if (file_exists(__DIR__ . '/../autoload.php')) {
require __DIR__ . '/../autoload.php';
} elseif (@include('Predis/Autoloader.php')) {
} elseif (@include ('Predis/Autoloader.php')) {
Predis\Autoloader::register();
} else {
exit('ERROR: Unable to find a suitable mean to register Predis\Autoloader.');
Expand Down
Loading