]> git.mxchange.org Git - core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 7 Dec 2020 09:47:50 +0000 (10:47 +0100)
committerRoland Häder <roland@mxchange.org>
Mon, 7 Dec 2020 09:47:50 +0000 (10:47 +0100)
- moved constants from BaseIndex class to Indexable interface
- removed extra file

Signed-off-by: Roland Häder <roland@mxchange.org>
framework/main/classes/index/class_BaseIndex.php
framework/main/classes/index/file_stack/class_FileStackIndex.php
framework/main/interfaces/index/class_Indexable.php
framework/main/interfaces/index/stack/class_IndexableStack.ph [deleted file]

index 0a801bf109eb6f5c9369d6ae9921b091eba79acb..21a79b7de90db59812b24766444abdef30b7cd63 100644 (file)
@@ -41,26 +41,6 @@ abstract class BaseIndex extends BaseFrameworkSystem {
        // Load traits
        use IteratorTrait;
 
-       /**
-        * Magic for this index
-        */
-       const INDEX_MAGIC = 'INDEXv0.1';
-
-       /**
-        * Separator group->hash
-        */
-       const SEPARATOR_GROUP_HASH = 0x01;
-
-       /**
-        * Separator hash->gap position
-        */
-       const SEPARATOR_HASH_GAP_POSITION = 0x02;
-
-       /**
-        * Separator gap position->length
-        */
-       const SEPARATOR_GAP_LENGTH = 0x03;
-
        /**
         * Minimum block length
         */
@@ -128,9 +108,9 @@ abstract class BaseIndex extends BaseFrameworkSystem {
                if (count($header) != 2) {
                        // Bad header
                        throw new UnexpectedValueException(sprintf('header()=%d is not expected value 2', count($header)));
-               } elseif ($header[0] !== self::INDEX_MAGIC) {
+               } elseif ($header[0] !== Indexable::INDEX_MAGIC) {
                        // Magic must be in first element
-                       throw new UnexpectedValueException(sprintf('header[0]=%s is not the expected magic (%s)', $header[0], self::INDEX_MAGIC));
+                       throw new UnexpectedValueException(sprintf('header[0]=%s is not the expected magic (%s)', $header[0], Indexable::INDEX_MAGIC));
                } elseif (strlen($header[1]) != BaseBinaryFile::LENGTH_COUNT) {
                        // Length of total entries not matching
                        throw new UnexpectedValueException(sprintf('header[1](%d)=%s does not have expected length %d', strlen($header[1]), $header[1], BaseBinaryFile::LENGTH_COUNT));
@@ -156,7 +136,7 @@ abstract class BaseIndex extends BaseFrameworkSystem {
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-INDEX: CALLED!');
                $header = sprintf('%s%s%s%s',
                        // Magic
-                       self::INDEX_MAGIC,
+                       Indexable::INDEX_MAGIC,
 
                        // Separator header data
                        chr(BaseBinaryFile::SEPARATOR_HEADER_DATA),
@@ -195,7 +175,7 @@ abstract class BaseIndex extends BaseFrameworkSystem {
 
                // Calculate header size
                $this->getIteratorInstance()->setHeaderSize(
-                       strlen(self::INDEX_MAGIC) +
+                       strlen(Indexable::INDEX_MAGIC) +
                        strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_DATA)) +
                        BaseBinaryFile::LENGTH_COUNT +
                        strlen(chr(BaseBinaryFile::SEPARATOR_HEADER_ENTRIES))
index 1a8783e425d56d15029b0517caf437b8f469879b..2a0efa3a944a309f59e376f152b9ba6f221ef81a 100644 (file)
@@ -77,11 +77,11 @@ class FileStackIndex extends BaseIndex implements IndexableStack, Registerable {
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,hash=%s,gap=%d,length=%d - CALLED!', $groupId, $data[StackableFile::ARRAY_NAME_HASH], $data[StackableFile::ARRAY_NAME_GAP_POSITION], $data[StackableFile::ARRAY_NAME_DATA_LENGTH]));
                $rawData = sprintf('%s%s%s%s%s%s%s',
                        $groupId,
-                       self::SEPARATOR_GROUP_HASH,
+                       Indexable::SEPARATOR_GROUP_HASH,
                        hex2bin($data[StackableFile::ARRAY_NAME_HASH]),
-                       self::SEPARATOR_HASH_GAP_POSITION,
+                       Indexable::SEPARATOR_HASH_GAP_POSITION,
                        $data[StackableFile::ARRAY_NAME_GAP_POSITION],
-                       self::SEPARATOR_GAP_LENGTH,
+                       Indexable::SEPARATOR_GAP_LENGTH,
                        $data[StackableFile::ARRAY_NAME_DATA_LENGTH]
                );
 
index 054f2fa5e64a391c256b05284ae0231309a5829f..d09095a21945a99ff72a32d04dd035ab3464244d 100644 (file)
@@ -28,5 +28,24 @@ use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface Indexable extends FrameworkInterface {
+       /**
+        * Magic for this index
+        */
+       const INDEX_MAGIC = 'INDEXv0.1';
+
+       /**
+        * Separator group->hash
+        */
+       const SEPARATOR_GROUP_HASH = 0x01;
+
+       /**
+        * Separator hash->gap position
+        */
+       const SEPARATOR_HASH_GAP_POSITION = 0x02;
+
+       /**
+        * Separator gap position->length
+        */
+       const SEPARATOR_GAP_LENGTH = 0x03;
 
 }
diff --git a/framework/main/interfaces/index/stack/class_IndexableStack.ph b/framework/main/interfaces/index/stack/class_IndexableStack.ph
deleted file mode 100644 (file)
index ff3d15f..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-
-       /**
-        * Adds given hash to an index file
-        *
-        * @param       $stackName      Name of stack to add hash
-        * @param       $data           Hash and gap position to be added to the index
-        * @return      void
-        */
-       function addHashToIndex ($stackName, array $data);