add column unique numbering scheme, more efficient selects
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Tables;
|
||||
|
||||
use App\Models\Row;
|
||||
|
||||
class RowNumerator
|
||||
{
|
||||
/** @var int */
|
||||
private $next;
|
||||
/** @var int */
|
||||
private $last;
|
||||
|
||||
/**
|
||||
* Create a numerator for the given number of rows.
|
||||
*
|
||||
* @param int $capacity
|
||||
*/
|
||||
public function __construct($capacity)
|
||||
{
|
||||
list($this->next, $this->last) = Row::allocateRowIDs($capacity);
|
||||
}
|
||||
|
||||
public function next()
|
||||
{
|
||||
if ($this->next > $this->last)
|
||||
throw new \OutOfBoundsException("Row numerator has run out of allocated GRID slots");
|
||||
|
||||
return $this->next++;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user