GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing apple.github.io — Blob — FoundationDB 8.0.1 documentation BlobPython Java GoalStore binary large objects (blobs) in the database. ChallengeA blob is too large to be stored as a single key-value pair in FoundationDB. Values of key-value pairs are limited to 100 kB, and you’ll get the better performance by keeping them closer to 10 kb. ExplanationThe core of the approach is simple: even though we can’t store the blob in a single key-value pair, we can still store it by using multiple key-value pairs. We do this by splitting the blob into chunks and storing the chunks within a single subspace. OrderingChunks are stored in order in adjacent key-value pairs. This approach allows the blob to be read with a single range read. PatternWe create a subspace for a given blob. This subspace will hold the individual chunks of the blob as key-value pairs. In the key, we store a byte-offset into the blob; in the value, we store a range of the bytes starting at that offset. A constant A simple transactional function to store a single blob with this strategy would look like: CHUNK_SIZE = 10000 blob_subspace = fdb.Subspace(('myblob',)) @fdb.transactional def write_blob(tr, blob_data): length = len(blob_data) if not length: return chunks = [(n, n+CHUNK_SIZE) for n in range(0, length, CHUNK_SIZE)] for start, end in chunks: tr[blob_subspace[start]] = blob_data[start:end] The blob can then be efficiently read with a single range read: @fdb.transactional def read_blob(tr): blob_data = '' for k, v in tr[blob_subspace.range()]: blob_data += v return blob_data ExtensionsA sparse representation for random reads and writes The simple model above lets us read and write a blob as a whole, but it can be extended to allow random reads and writes, allowing the blob to be partially accessed or streamed. At the same time, the representation can remain sparse, only consuming space for the data that is actually written. For efficiency, we sometimes join chunks after a write to avoid the fragmentation than might result from small writes. Joining chunks is controlled by a constant |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |