]> git.mxchange.org Git - core.git/blobdiff - framework/main/classes/stacker/file/class_BaseFileStack.php
Refacuring / possible WIP:
[core.git] / framework / main / classes / stacker / file / class_BaseFileStack.php
index 66345fd72112ad7f76bbc920d0912a4268df91af..6b4a8bfb0f58982df285a06ca2251ea08c089a96 100644 (file)
@@ -72,7 +72,7 @@ abstract class BaseFileStack extends BaseStacker {
         * @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();
@@ -254,8 +254,8 @@ abstract class BaseFileStack extends BaseStacker {
                }
 
                // 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
@@ -269,8 +269,8 @@ abstract class BaseFileStack extends BaseStacker {
                $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
@@ -649,13 +649,13 @@ abstract class BaseFileStack extends BaseStacker {
        /**
         * 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);
        }
 
@@ -691,16 +691,16 @@ abstract class BaseFileStack extends BaseStacker {
        /**
         * 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,
@@ -708,7 +708,7 @@ abstract class BaseFileStack extends BaseStacker {
                );
 
                // 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
@@ -723,11 +723,11 @@ abstract class BaseFileStack extends BaseStacker {
                }
 
                // 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,