Пример #1
0
 /**
  *
  * @param FileInterface $file
  * @param array $columnPages [[(ColumnSchema)$columnPage, 'ASC'], [$columnPage2, 'DESC'], $columnPage3, ...]
  * @throws ErrorException
  */
 public function __construct(FileInterface $file, array $columnPages)
 {
     // rebuild array to have usable keys
     $usedColumnSchemas = array();
     foreach ($columnPages as $columnDataset) {
         if (count($columnDataset) === 2) {
             list($columnPage, $direction) = $columnDataset;
         } elseif (count($columnDataset) === 1) {
             $columnPage = current($columnDataset);
             $direction = "ASC";
         } elseif ($columnDataset instanceof ColumnSchema) {
             $columnPage = $columnDataset;
             $direction = "ASC";
         } else {
             throw new ErrorException("Invalid content in parameter \$columnPages!");
         }
         $direction = $direction === "ASC" ? "ASC" : "DESC";
         if (!$columnPage instanceof ColumnSchema) {
             throw new ErrorException("Given column-page is not subclass of 'ColumnSchema'!");
         }
         $usedColumnSchemas[] = [$columnPage, $direction];
     }
     $this->file = $file;
     $this->columnPages = $usedColumnSchemas;
     if ($file->getLength() <= 0) {
         $file->setData(str_pad("", $this->getPageSize(), ""));
     }
 }
Пример #2
0
 public function __construct(FileInterface $file)
 {
     $this->file = $file;
     $this->filePageCount = ceil(self::HASHTABLE_SIZE / self::REFERENCE_SIZE);
     $this->usedHashCharCount = ceil(log($this->filePageCount, 16));
     $this->doublesBeginSeek = (int) (self::REFERENCE_SIZE * $this->filePageCount);
     if ($file->getLength() <= 0) {
         $this->clearAll();
     }
 }
Пример #3
0
 public function setDoublesFile(FileInterface $file)
 {
     $this->doublesFile = $file;
     if ($file->getLength() <= 0) {
         $file->setData(str_pad("", $this->keyLength * 2, ""));
     }
 }