Skip to content

Commit

Permalink
Correctly track the last blob file created. Make blobs read-only afte…
Browse files Browse the repository at this point in the history
…r creation.
  • Loading branch information
brianwalenz committed Nov 12, 2019
1 parent d20b159 commit 20a0673
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
2 changes: 0 additions & 2 deletions src/stores/sqStore.H
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ private:
char _blobName[FILENAME_MAX+1]; // A temporary to make life easier.

sqStoreInfo *_info;

uint32 _blobNumber;
writeBuffer *_buffer;
};

Expand Down
24 changes: 15 additions & 9 deletions src/stores/sqStoreBlob.C
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,24 @@
//
sqStoreBlobWriter::sqStoreBlobWriter(const char *storePath, sqStoreInfo *info) {

memset(_storePath, 0, sizeof(char) * FILENAME_MAX); // Clear the path.
memset(_blobName, 0, sizeof(char) * FILENAME_MAX); // Clear the name.
memset(_storePath, 0, sizeof(char) * FILENAME_MAX); // Clear the path.
memset(_blobName, 0, sizeof(char) * FILENAME_MAX); // Clear the name.

strncpy(_storePath, storePath, FILENAME_MAX); // Copy path to our path.
strncpy(_storePath, storePath, FILENAME_MAX); // Copy path to our path.

_info = info; // Remember the info!
_blobNumber = _info->_numBlobs++; // Set up for the next avail blob.
_info = info; // Remember the info!
_info->_numBlobs++; // Set up for the next avail blob.

makeBlobName(_storePath, _blobNumber, _blobName); // Construct the name of the blob file.
makeBlobName(_storePath, _info->_numBlobs, _blobName); // Construct the name of the blob file.

_buffer = new writeBuffer(_blobName, "w"); // And open it.
_buffer = new writeBuffer(_blobName, "w"); // And open it.
}


sqStoreBlobWriter::~sqStoreBlobWriter() {
delete _buffer;

AS_UTL_makeReadOnly(_blobName);
}


Expand All @@ -68,15 +70,19 @@ sqStoreBlobWriter::writeData(sqReadDataWriter *rdw) {
if (_buffer->tell() > AS_BLOBFILE_MAX_SIZE) {
delete _buffer;

makeBlobName(_storePath, ++_blobNumber, _blobName);
AS_UTL_makeReadOnly(_blobName);

_info->_numBlobs++;

makeBlobName(_storePath, _info->_numBlobs, _blobName);

_buffer = new writeBuffer(_blobName, "w");
}

// Save the current position in the blob file in the sqStore
// metadata, then tell the rdw to dump data.

rdw->_meta->sqRead_setPosition(_blobNumber, _buffer->tell());
rdw->_meta->sqRead_setPosition(_info->_numBlobs, _buffer->tell());
rdw->sqReadDataWriter_writeBlob(_buffer);
}

Expand Down

0 comments on commit 20a0673

Please sign in to comment.