From: Roland Häder Date: Mon, 7 Dec 2020 09:47:50 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cc783d97086d21b6a675b8b5be801ca1af426a42;p=core.git Continued: - moved constants from BaseIndex class to Indexable interface - removed extra file Signed-off-by: Roland Häder --- diff --git a/framework/main/classes/index/class_BaseIndex.php b/framework/main/classes/index/class_BaseIndex.php index 0a801bf1..21a79b7d 100644 --- a/framework/main/classes/index/class_BaseIndex.php +++ b/framework/main/classes/index/class_BaseIndex.php @@ -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)) diff --git a/framework/main/classes/index/file_stack/class_FileStackIndex.php b/framework/main/classes/index/file_stack/class_FileStackIndex.php index 1a8783e4..2a0efa3a 100644 --- a/framework/main/classes/index/file_stack/class_FileStackIndex.php +++ b/framework/main/classes/index/file_stack/class_FileStackIndex.php @@ -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] ); diff --git a/framework/main/interfaces/index/class_Indexable.php b/framework/main/interfaces/index/class_Indexable.php index 054f2fa5..d09095a2 100644 --- a/framework/main/interfaces/index/class_Indexable.php +++ b/framework/main/interfaces/index/class_Indexable.php @@ -28,5 +28,24 @@ use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; * along with this program. If not, see . */ 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 index ff3d15fb..00000000 --- a/framework/main/interfaces/index/stack/class_IndexableStack.ph +++ /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);