public static function Utility::normalizeMaxRows in Search API Solr 8.3
Same name and namespace in other branches
- 4.x src/Utility/Utility.php \Drupal\search_api_solr\Utility\Utility::normalizeMaxRows()
Normalize the number of rows to fetch to nearest higher power of 2.
The _search_all() and _topic_all() streaming expressions need a row limit that matches the real number of documents or higher. To increase the number of query result cache hits we "normalize" the document counts to the nearest higher power of 2. Setting them to a very high fixed value instead makes no sense as this would waste memory in Solr Cloud and might lead to out of memory exceptions. The absolute maximum Solr accepts regardless of the available memory is 2147483629. So we use this a cut-off.
Parameters
int $rows: The number of rows.
Return value
int Normalized number of rows.
2 calls to Utility::normalizeMaxRows()
- search_api_solr_cron in ./
search_api_solr.module - Implements hook_cron().
- StreamingExpressionBuilder::getSearchAllRows in src/
Utility/ StreamingExpressionBuilder.php - Returns the row limit for _search_all() and _topic_all() expressions.
File
- src/
Utility/ Utility.php, line 593
Class
- Utility
- Provides various helper functions for Solr backends.
Namespace
Drupal\search_api_solr\UtilityCode
public static function normalizeMaxRows(int $rows) {
$i = 2;
while ($i <= $rows) {
$i *= 2;
}
return $i > 2147483629 ? 2147483629 : $i;
}