use Org\Mxchange\CoreFramework\Index\Indexable;
use Org\Mxchange\CoreFramework\Registry\Registerable;
use Org\Mxchange\CoreFramework\Stack\File\StackableFile;
-use Org\Mxchange\CoreFramework\Stack\Index\IndexableStack;
+use Org\Mxchange\CoreFramework\Index\Stack\IndexableStack;
// Import SPL stuff
use \InvalidArgumentException;
}
/**
- * Adds given hash to an index file
+ * Adds given data's hash to an index file
*
* @param $groupId Name of stack to add hash for
* @param $data Hash and gap position to be added to the index
* @return void
+ * @throws InvalidArgumentException If a parameter is not valid
* @throws UnexpectedValueException If an invalid gap position is being returned
*/
- public function addHashToIndex (string $groupId, array $data) {
+ public function addHashedDataToIndex (string $groupId, array $data) {
+ // Validate parameter
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('FILE-STACK-INDEX: groupId=%s,data()=%d - CALLED!', $groupId, count($data)));
+ if (empty($groupId)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "groupId" is empty');
+ } elseif (count($data) == 0) {
+ // Throw it again
+ throw new InvalidArgumentException('Parameter "data" is an empty array');
+ } elseif (!isset($data[StackableFile::ARRAY_NAME_HASH])) {
+ // Important array element missing
+ throw new InvalidArgumentException(sprintf('data[%s] not found', $data[StackableFile::ARRAY_NAME_HASH]));
+ } elseif (!isset($data[StackableFile::ARRAY_NAME_GAP_POSITION])) {
+ // Important array element missing
+ throw new InvalidArgumentException(sprintf('data[%s] not found', $data[StackableFile::ARRAY_NAME_GAP_POSITION]));
+ } elseif (!isset($data[StackableFile::ARRAY_NAME_DATA_LENGTH])) {
+ // Important array element missing
+ throw new InvalidArgumentException(sprintf('data[%s] not found', $data[StackableFile::ARRAY_NAME_DATA_LENGTH]));
+ }
+
// Raw data been written to the file
- /* 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,
Indexable::SEPARATOR_GROUP_HASH,
// Throw IAE
throw new InvalidArgumentException(sprintf('length=%d is not valid', $length));
}
+
+ // Partial stub!
+ $this->partialStub('length=' . $length);
}
/**
return $status;
}
+ /**
+ * Checks if this index file has been fully and properly loaded.
+ *
+ * @return $isLoaded Whether this index file has been loaded
+ */
+ public function isIndexFileLoaded () {
+ // Trace message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('FILE-STACK-INDEX: CALLED!');
+ /* DEBUG-DIE: */ die(sprintf('[%s:%d]: this=%s', __METHOD__, __LINE__, print_r($this, true)));
+ }
+
}