* @throws UnexpectedValueException If header is not proper length
* @throws InvalidMagicException If a bad magic was found
*/
- public function readFileHeader () {
+ public function readStackHeader () {
// First rewind to beginning as the header sits at the beginning ...
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: CALLED!');
$this->getIteratorInstance()->rewind();
}
// Load the file header
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->readFileHeader() ...');
- $this->readFileHeader();
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->readStackHeader() ...');
+ $this->readStackHeader();
/*
* Get stack index instance. This can be used for faster
$this->setIndexInstance($indexInstance);
// Is the index loaded correctly and the stack file is just created?
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->indexInstance->isIndexFileLoaded() ...');
- if (!$this->getIndexInstance()->isIndexFileLoaded()) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: Calling this->indexInstance->isIndexLoaded() ...');
+ if (!$this->getIndexInstance()->isIndexLoaded()) {
/*
* Something horrible has happened to the index as it should be
* loaded at this point. The stack's file structure then needs to
/**
* Writes given value to the file and returns a hash and gap position for it
*
- * @param $groupId Group identifier
+ * @param $stackName Group identifier
* @param $value Value to be added to the stack
* @return $data Hash and gap position
* @throws UnsupportedOperationException This method is not (and maybe never will be) supported
*/
- public function writeValueToFile (string $groupId, $value) {
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: groupId=%s,value[%s]=%s', $groupId, gettype($value), print_r($value, true)));
+ public function writeValueToFile (string $stackName, $value) {
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackName=%s,value[%s]=%s', $stackName, gettype($value), print_r($value, true)));
throw new UnsupportedOperationException(array($this, __FUNCTION__, $this->getIteratorInstance()->getPointerInstance()), self::EXCEPTION_UNSPPORTED_OPERATION);
}
/**
* Writes given raw data to the file and returns a gap position and length
*
- * @param $groupId Group identifier
+ * @param $stackName Group identifier
* @param $hash Hash from encoded value
* @param $encoded Encoded value to be written to the file
* @return $data Gap position and length of the raw data
*/
- public function writeDataToFreeGap (string $groupId, string $hash, string $encoded) {
+ public function writeDataToFreeGap (string $stackName, string $hash, string $encoded) {
// Raw data been written to the file
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: groupId=%s,hash=%s,encoded()=%d - CALLED!', $groupId, $hash, strlen($encoded)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackName=%s,hash=%s,encoded()=%d - CALLED!', $stackName, $hash, strlen($encoded)));
$rawData = sprintf('%s%s%s%s%s',
- $groupId,
+ $stackName,
BaseBinaryFile::SEPARATOR_GROUP_HASH,
hex2bin($hash),
BaseBinaryFile::SEPARATOR_HASH_VALUE,
);
// Search for next free gap
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: groupId=%s,hash=%s,rawData()=%d', $groupId, $hash, strlen($rawData)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackName=%s,hash=%s,rawData()=%d', $stackName, $hash, strlen($rawData)));
$gapPosition = $this->getIteratorInstance()->searchNextGap(strlen($rawData));
// Gap position cannot be smaller than header length + 1
}
// Then write the data at that gap
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: groupId=%s,hash=%s,gapPosition=%s', $groupId, $hash, $gapPosition));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackName=%s,hash=%s,gapPosition=%s', $stackName, $hash, $gapPosition));
$this->getIteratorInstance()->writeData($gapPosition, $rawData);
// Return gap position, hash and length of raw data
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: groupId=%s,hash=%s,rawData()=%d - EXIT!', $groupId, $hash, strlen($rawData)));
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: stackName=%s,hash=%s,rawData()=%d - EXIT!', $stackName, $hash, strlen($rawData)));
return [
self::ARRAY_NAME_GAP_POSITION => $gapPosition,
self::ARRAY_NAME_HASH => $hash,