diff --git a/lib/blockstorestorage/longtail_blockstorestorage.c b/lib/blockstorestorage/longtail_blockstorestorage.c index dbb97500..542e9d8b 100644 --- a/lib/blockstorestorage/longtail_blockstorestorage.c +++ b/lib/blockstorestorage/longtail_blockstorestorage.c @@ -1282,13 +1282,13 @@ static int BlockStoreStorageAPI_Init( const TLongtail_Hash* stire_index_chunk_hashes = store_index->m_ChunkHashes; uint32_t block_count = *store_index->m_BlockCount; + uint32_t chunk_index_offset = 0; for (uint32_t b = 0; b < block_count; ++b) { uint32_t block_chunk_count = store_index->m_BlockChunkCounts[b]; - uint32_t chunk_index_offset = store_index->m_BlockChunksOffsets[b]; for (uint32_t c = 0; c < block_chunk_count; ++c) { - uint32_t chunk_index = chunk_index_offset + c; + uint32_t chunk_index = chunk_index_offset++; TLongtail_Hash chunk_hash = store_index->m_ChunkHashes[chunk_index]; Longtail_LookupTable_Put(block_store_fs->m_ChunkHashToBlockIndexLookup, chunk_hash, b); } diff --git a/src/longtail.c b/src/longtail.c index c4b4a1e3..af0ad521 100644 --- a/src/longtail.c +++ b/src/longtail.c @@ -3672,6 +3672,7 @@ struct WriteBlockJob const struct Longtail_StoreIndex* m_StoreIndex; struct AssetPartLookup* m_AssetPartLookup; uint32_t m_BlockIndex; + uint32_t m_FirstChunkIndex; int m_Err; }; @@ -3756,7 +3757,7 @@ static int WriteContentBlockJob(void* context, uint32_t job_id, int is_cancelled TLongtail_Hash block_hash = store_index->m_BlockHashes[job->m_BlockIndex]; uint32_t chunk_count = store_index->m_BlockChunkCounts[job->m_BlockIndex]; - uint32_t first_chunk_index = store_index->m_BlockChunksOffsets[job->m_BlockIndex]; + uint32_t first_chunk_index = job->m_FirstChunkIndex; uint32_t block_data_size = 0; for (uint32_t chunk_index = first_chunk_index; chunk_index < first_chunk_index + chunk_count; ++chunk_index) @@ -4003,6 +4004,7 @@ int Longtail_WriteContent( } uint32_t job_count = 0; + uint32_t chunk_index_offset = 0; for (uint32_t block_index = 0; block_index < block_count; ++block_index) { TLongtail_Hash block_hash = store_index->m_BlockHashes[block_index]; @@ -4018,12 +4020,15 @@ int Longtail_WriteContent( job->m_AssetsFolder = assets_folder; job->m_StoreIndex = store_index; job->m_BlockIndex = block_index; + job->m_FirstChunkIndex = chunk_index_offset; job->m_AssetPartLookup = asset_part_lookup; job->m_Err = EINVAL; funcs[job_count] = WriteContentBlockJob; ctxs[job_count] = job; + chunk_index_offset += store_index->m_BlockChunkCounts[block_index]; + ++job_count; } @@ -5582,10 +5587,10 @@ int Longtail_WriteVersion( LONGTAIL_LOG(ctx, LONGTAIL_LOG_LEVEL_ERROR, "Longtail_Alloc() failed with %d", ENOMEM) return ENOMEM; } + uint32_t chunk_index_offset = 0; for (uint32_t b = 0; b < block_count; ++b) { uint32_t block_chunk_count = store_index->m_BlockChunkCounts[b]; - uint32_t chunk_index_offset = store_index->m_BlockChunksOffsets[b]; for (uint32_t c = 0; c < block_chunk_count; ++c) { uint32_t chunk_index = chunk_index_offset + c; @@ -6098,16 +6103,17 @@ int Longtail_GetMissingChunks( LONGTAIL_FATAL_ASSERT(ctx, chunk_to_reference_block_index_lookup != 0, return EINVAL ) uint32_t reference_block_count = *store_index->m_BlockCount; + uint32_t chunk_index_offset = 0; for (uint32_t b = 0; b < reference_block_count; ++b) { uint32_t block_chunk_count = store_index->m_BlockChunkCounts[b]; - uint32_t chunk_index_offset = store_index->m_BlockChunksOffsets[b]; for (uint32_t c = 0; c < block_chunk_count; ++c) - { + { uint32_t chunk_index = chunk_index_offset + c; TLongtail_Hash chunk_hash = store_index->m_ChunkHashes[chunk_index]; Longtail_LookupTable_PutUnique(chunk_to_reference_block_index_lookup, chunk_hash, b); } + chunk_index_offset += block_chunk_count; } uint32_t missing_chunk_count = 0; @@ -6179,7 +6185,9 @@ int Longtail_GetExistingStoreIndex( size_t chunk_to_index_lookup_size = Longtail_LookupTable_GetSize(chunk_count); size_t block_to_index_lookup_size = Longtail_LookupTable_GetSize(store_block_count); size_t chunk_to_store_index_lookup_size = Longtail_LookupTable_GetSize(chunk_count); + size_t chunk_index_offsets_size = sizeof(uint32_t) * store_block_count; size_t found_store_block_hashes_size = sizeof(TLongtail_Hash) * store_block_count; + size_t found_store_block_chunk_index_offset_size = sizeof(uint32_t) * store_block_count; size_t block_uses_size = sizeof(uint32_t) * store_block_count; size_t block_sizes_size = sizeof(uint32_t) * store_block_count; size_t block_order_size = sizeof(uint32_t) * store_block_count; @@ -6187,7 +6195,9 @@ int Longtail_GetExistingStoreIndex( size_t tmp_mem_size = chunk_to_index_lookup_size + block_to_index_lookup_size + chunk_to_store_index_lookup_size + + chunk_index_offsets_size + found_store_block_hashes_size + + found_store_block_chunk_index_offset_size + block_uses_size + block_sizes_size + block_order_size; @@ -6209,9 +6219,15 @@ int Longtail_GetExistingStoreIndex( struct Longtail_LookupTable* chunk_to_store_index_lookup = Longtail_LookupTable_Create(p, chunk_count, 0); p += chunk_to_store_index_lookup_size; + uint32_t* chunk_index_offsets = (uint32_t*)p; + p += chunk_index_offsets_size; + TLongtail_Hash* found_store_block_hashes = (TLongtail_Hash*)p; p += found_store_block_hashes_size; + uint32_t* found_store_block_chunk_index_offset = (uint32_t*)p; + p += found_store_block_chunk_index_offset_size; + uint32_t* block_uses = (uint32_t*)p; p += block_uses_size; @@ -6231,19 +6247,20 @@ int Longtail_GetExistingStoreIndex( uint32_t found_chunk_count = 0; if (min_block_usage_percent <= 100) { + uint32_t chunk_index_offset = 0; for (uint32_t b = 0; b < store_block_count; ++b) { block_order[b] = b; + chunk_index_offsets[b] = chunk_index_offset; block_uses[b] = 0; block_sizes[b] = 0; TLongtail_Hash block_hash = store_index->m_BlockHashes[b]; uint32_t block_chunk_count = store_index->m_BlockChunkCounts[b]; - uint32_t chunk_offset = store_index->m_BlockChunksOffsets[b]; for (uint32_t c = 0; c < block_chunk_count; ++c) { - uint32_t chunk_size = store_index->m_ChunkSizes[chunk_offset]; - TLongtail_Hash chunk_hash = store_index->m_ChunkHashes[chunk_offset]; - ++chunk_offset; + uint32_t chunk_size = store_index->m_ChunkSizes[chunk_index_offset]; + TLongtail_Hash chunk_hash = store_index->m_ChunkHashes[chunk_index_offset]; + ++chunk_index_offset; block_sizes[b] += chunk_size; if (Longtail_LookupTable_Get(chunk_to_index_lookup, chunk_hash)) { @@ -6276,8 +6293,8 @@ int Longtail_GetExistingStoreIndex( } TLongtail_Hash block_hash = store_index->m_BlockHashes[b]; uint32_t block_chunk_count = store_index->m_BlockChunkCounts[b]; - uint32_t store_chunk_index_offset = store_index->m_BlockChunksOffsets[b]; uint32_t current_found_block_index = found_block_count; + uint32_t store_chunk_index_offset = chunk_index_offsets[b]; for (uint32_t c = 0; c < block_chunk_count; ++c) { TLongtail_Hash chunk_hash = store_index->m_ChunkHashes[store_chunk_index_offset]; @@ -6297,6 +6314,7 @@ int Longtail_GetExistingStoreIndex( uint32_t* block_index_ptr = Longtail_LookupTable_PutUnique(block_to_index_lookup, block_hash, current_found_block_index); if (block_index_ptr == 0) { + found_store_block_chunk_index_offset[found_block_count] = store_chunk_index_offset; found_store_block_hashes[found_block_count++] = block_hash; } ++store_chunk_index_offset; @@ -6308,8 +6326,8 @@ int Longtail_GetExistingStoreIndex( } if (found_block_count == 0) - { - Longtail_Free(tmp_mem); + { + Longtail_Free(tmp_mem); return Longtail_CreateStoreIndexFromBlocks( 0, 0, @@ -6330,8 +6348,8 @@ int Longtail_GetExistingStoreIndex( LONGTAIL_LOG(ctx, LONGTAIL_LOG_LEVEL_ERROR, "Longtail_Alloc() failed with %d", ENOMEM) Longtail_Free(tmp_mem); return ENOMEM; - } + struct Longtail_BlockIndex** block_index_header_ptrs = (struct Longtail_BlockIndex**)tmp_mem_2; struct Longtail_BlockIndex* block_index_headers = (struct Longtail_BlockIndex*)&block_index_header_ptrs[found_block_count]; struct Longtail_LookupTable* block_hash_lookup = Longtail_LookupTable_Create(&((char*)block_index_headers)[block_index_headers_size], found_block_count, 0); @@ -6345,12 +6363,13 @@ int Longtail_GetExistingStoreIndex( Longtail_LookupTable_Put(block_hash_lookup, block_hash, b); } + uint32_t store_chunk_index_offset = 0; for (uint32_t b = 0; b < found_block_count; ++b) { TLongtail_Hash block_hash = found_store_block_hashes[b]; + uint32_t block_chunk_index_offset = found_store_block_chunk_index_offset[b]; uint32_t store_block_index = *Longtail_LookupTable_Get(block_hash_lookup, block_hash); uint32_t block_chunk_count = store_index->m_BlockChunkCounts[store_block_index]; - uint32_t block_chunk_index_offset = store_index->m_BlockChunksOffsets[store_block_index]; block_index_headers[b].m_BlockHash = &store_index->m_BlockHashes[store_block_index]; block_index_headers[b].m_HashIdentifier = store_index->m_HashIdentifier; block_index_headers[b].m_ChunkCount = &store_index->m_BlockChunkCounts[store_block_index]; @@ -6957,15 +6976,15 @@ int Longtail_ChangeVersion( uint32_t* asset_indexes = (uint32_t*)p; uint32_t block_count = *store_index->m_BlockCount; + uint32_t chunk_index_offset = 0; for (uint32_t b = 0; b < block_count; ++b) { uint32_t block_chunk_count = store_index->m_BlockChunkCounts[b]; - uint32_t chunk_index_offset = store_index->m_BlockChunksOffsets[b]; for (uint32_t c = 0; c < block_chunk_count; ++c) { - uint32_t chunk_index = chunk_index_offset + c; - TLongtail_Hash chunk_hash = store_index->m_ChunkHashes[chunk_index]; + TLongtail_Hash chunk_hash = store_index->m_ChunkHashes[chunk_index_offset]; Longtail_LookupTable_PutUnique(chunk_hash_to_block_index, chunk_hash, b); + ++chunk_index_offset; } } @@ -7070,7 +7089,6 @@ size_t Longtail_GetStoreIndexDataSize(uint32_t block_count, uint32_t chunk_count sizeof(uint32_t) + // m_ChunkCount (sizeof(TLongtail_Hash) * block_count) + // m_BlockHashes (sizeof(TLongtail_Hash) * chunk_count) + // m_ChunkHashes - (sizeof(uint32_t) * block_count) + // m_BlockChunksOffsets (sizeof(uint32_t) * block_count) + // m_BlockChunkCounts (sizeof(uint32_t) * block_count) + // m_BlockTags (sizeof(uint32_t) * chunk_count); // m_ChunkSizes @@ -7107,9 +7125,6 @@ struct Longtail_StoreIndex* Longtail_InitStoreIndex(void* mem, uint32_t block_co store_index->m_ChunkHashes = (TLongtail_Hash*)(void*)p; p += sizeof(TLongtail_Hash) * chunk_count; - store_index->m_BlockChunksOffsets = (uint32_t*)(void*)p; - p += sizeof(uint32_t) * block_count; - store_index->m_BlockChunkCounts = (uint32_t*)(void*)p; p += sizeof(uint32_t) * block_count; @@ -7169,9 +7184,6 @@ static int InitStoreIndexFromData( store_index->m_ChunkHashes = (TLongtail_Hash*)(void*)p; p += sizeof(TLongtail_Hash) * chunk_count; - store_index->m_BlockChunksOffsets = (uint32_t*)(void*)p; - p += sizeof(uint32_t) * block_count; - store_index->m_BlockChunkCounts = (uint32_t*)(void*)p; p += sizeof(uint32_t) * block_count; @@ -7251,7 +7263,6 @@ int Longtail_CreateStoreIndexFromBlocks( store_index->m_BlockHashes[b] = *block_index->m_BlockHash; store_index->m_BlockTags[b] = *block_index->m_Tag; store_index->m_BlockChunkCounts[b] = block_chunk_count; - store_index->m_BlockChunksOffsets[b] = c; memcpy(&store_index->m_ChunkHashes[c], block_index->m_ChunkHashes, sizeof(TLongtail_Hash) * block_chunk_count); memcpy(&store_index->m_ChunkSizes[c], block_index->m_ChunkSizes, sizeof(uint32_t) * block_chunk_count); c += block_chunk_count; @@ -7261,31 +7272,6 @@ int Longtail_CreateStoreIndexFromBlocks( return 0; } -int Longtail_MakeBlockIndex( - const struct Longtail_StoreIndex* store_index, - uint32_t block_index, - struct Longtail_BlockIndex* out_block_index) -{ - MAKE_LOG_CONTEXT_FIELDS(ctx) - LONGTAIL_LOGFIELD(store_index, "%p"), - LONGTAIL_LOGFIELD(block_index, "%u"), - LONGTAIL_LOGFIELD(out_block_index, "%p") - MAKE_LOG_CONTEXT_WITH_FIELDS(ctx, 0, LONGTAIL_LOG_LEVEL_INFO) - - LONGTAIL_VALIDATE_INPUT(ctx, store_index != 0, return EINVAL) - LONGTAIL_VALIDATE_INPUT(ctx, block_index < (*store_index->m_BlockCount), return EINVAL) - LONGTAIL_VALIDATE_INPUT(ctx, store_index != 0, return EINVAL) - uint32_t block_chunks_offset = store_index->m_BlockChunksOffsets[block_index]; - out_block_index->m_BlockHash = &store_index->m_BlockHashes[block_index]; - out_block_index->m_HashIdentifier = store_index->m_HashIdentifier; - out_block_index->m_ChunkCount = &store_index->m_BlockChunkCounts[block_index]; - out_block_index->m_Tag = &store_index->m_BlockTags[block_index]; - out_block_index->m_ChunkHashes = &store_index->m_ChunkHashes[block_chunks_offset]; - out_block_index->m_ChunkSizes = &store_index->m_ChunkSizes[block_chunks_offset]; - return 0; -} - - int Longtail_MergeStoreIndex( const struct Longtail_StoreIndex* local_store_index, const struct Longtail_StoreIndex* remote_store_index, @@ -7327,7 +7313,12 @@ int Longtail_MergeStoreIndex( size_t local_block_hash_to_index_size = Longtail_LookupTable_GetSize(local_block_count); size_t remote_block_hash_to_index_size = Longtail_LookupTable_GetSize(remote_block_count); size_t block_hashes_size = sizeof(TLongtail_Hash) * (local_block_count + remote_block_count); - size_t work_mem_size = local_block_hash_to_index_size + remote_block_hash_to_index_size + block_hashes_size; + size_t block_chunk_index_offsets_size = sizeof(uint32_t) * (local_block_count + remote_block_count); + size_t work_mem_size = + local_block_hash_to_index_size + + remote_block_hash_to_index_size + + block_hashes_size + + block_chunk_index_offsets_size; void* work_mem = Longtail_Alloc("MergeStoreIndex", work_mem_size); if (!work_mem) @@ -7342,9 +7333,12 @@ int Longtail_MergeStoreIndex( struct Longtail_LookupTable* remote_block_hash_to_index = Longtail_LookupTable_Create(p, remote_block_count, 0); p += remote_block_hash_to_index_size; TLongtail_Hash* block_hashes = (TLongtail_Hash*)p; + p += block_hashes_size; + uint32_t* block_chunk_index_offsets = (uint32_t*)p; uint32_t unique_block_count = 0; uint32_t chunk_count = 0; + uint32_t chunk_index_offset = 0; for (uint32_t local_block = 0; local_block < local_block_count; ++local_block) { TLongtail_Hash block_hash = local_store_index->m_BlockHashes[local_block]; @@ -7353,9 +7347,13 @@ int Longtail_MergeStoreIndex( continue; } block_hashes[unique_block_count] = block_hash; + block_chunk_index_offsets[unique_block_count] = chunk_index_offset; + uint32_t block_chunk_count = local_store_index->m_BlockChunkCounts[local_block]; ++unique_block_count; - chunk_count += local_store_index->m_BlockChunkCounts[local_block]; + chunk_index_offset += block_chunk_count; + chunk_count += block_chunk_count; } + chunk_index_offset = 0; for (uint32_t remote_block = 0; remote_block < remote_block_count; ++remote_block) { TLongtail_Hash block_hash = remote_store_index->m_BlockHashes[remote_block]; @@ -7368,8 +7366,11 @@ int Longtail_MergeStoreIndex( continue; } block_hashes[unique_block_count] = block_hash; - ++unique_block_count; - chunk_count += remote_store_index->m_BlockChunkCounts[remote_block]; + block_chunk_index_offsets[unique_block_count] = chunk_index_offset; + uint32_t block_chunk_count = remote_store_index->m_BlockChunkCounts[remote_block]; + ++unique_block_count; + chunk_index_offset += block_chunk_count; + chunk_count += block_chunk_count; } size_t merged_block_store_index_size = Longtail_GetStoreIndexSize(unique_block_count, chunk_count); @@ -7385,7 +7386,7 @@ int Longtail_MergeStoreIndex( *merged_store_index->m_HashIdentifier = hash_identifier; *merged_store_index->m_BlockCount = unique_block_count; *merged_store_index->m_ChunkCount = chunk_count; - uint32_t chunk_index_offset = 0; + chunk_index_offset = 0; const struct Longtail_StoreIndex* source_index = local_store_index; struct Longtail_LookupTable* source_lookup_table = local_block_hash_to_index; for (uint32_t b = 0; b < unique_block_count; ++b) @@ -7404,13 +7405,12 @@ int Longtail_MergeStoreIndex( uint32_t source_block = *index_ptr; uint32_t block_chunk_count = source_index->m_BlockChunkCounts[source_block]; merged_store_index->m_BlockTags[b] = source_index->m_BlockTags[source_block]; - uint32_t block_chunk_offset = source_index->m_BlockChunksOffsets[source_block]; + uint32_t block_chunk_offset = block_chunk_index_offsets[b]; const TLongtail_Hash* local_chunk_hashes = &source_index->m_ChunkHashes[block_chunk_offset]; const uint32_t* local_chunk_sizes = &source_index->m_ChunkSizes[block_chunk_offset]; merged_store_index->m_BlockHashes[b] = block_hash; merged_store_index->m_BlockChunkCounts[b] = block_chunk_count; - merged_store_index->m_BlockChunksOffsets[b] = chunk_index_offset; TLongtail_Hash* merged_chunk_hashes = &merged_store_index->m_ChunkHashes[chunk_index_offset]; memcpy(merged_chunk_hashes, local_chunk_hashes, sizeof(TLongtail_Hash) * block_chunk_count); uint32_t* merged_chunk_sizes = &merged_store_index->m_ChunkSizes[chunk_index_offset]; @@ -7526,7 +7526,6 @@ struct Longtail_StoreIndex* Longtail_CopyStoreIndex(struct Longtail_StoreIndex* *copy_store_index->m_ChunkCount = chunk_count; memcpy(copy_store_index->m_BlockHashes, store_index->m_BlockHashes, sizeof(TLongtail_Hash) * block_count); memcpy(copy_store_index->m_ChunkHashes, store_index->m_ChunkHashes, sizeof(TLongtail_Hash) * chunk_count); - memcpy(copy_store_index->m_BlockChunksOffsets, store_index->m_BlockChunksOffsets, sizeof(uint32_t) * block_count); memcpy(copy_store_index->m_BlockChunkCounts, store_index->m_BlockChunkCounts, sizeof(uint32_t) * block_count); memcpy(copy_store_index->m_BlockTags, store_index->m_BlockTags, sizeof(uint32_t) * block_count); memcpy(copy_store_index->m_ChunkSizes, store_index->m_ChunkSizes, sizeof(uint32_t) * chunk_count); @@ -7733,7 +7732,6 @@ uint32_t Longtail_StoreIndex_GetBlockCount(const struct Longtail_StoreIndex* sto uint32_t Longtail_StoreIndex_GetChunkCount(const struct Longtail_StoreIndex* store_index) { return *store_index->m_ChunkCount;} const TLongtail_Hash* Longtail_StoreIndex_GetBlockHashes(const struct Longtail_StoreIndex* store_index) { return store_index->m_BlockHashes;} const TLongtail_Hash* Longtail_StoreIndex_GetChunkHashes(const struct Longtail_StoreIndex* store_index) { return store_index->m_ChunkHashes;} -const uint32_t* Longtail_StoreIndex_GetBlockChunksOffsets(const struct Longtail_StoreIndex* store_index) { return store_index->m_BlockChunksOffsets;} const uint32_t* Longtail_StoreIndex_GetBlockChunkCounts(const struct Longtail_StoreIndex* store_index) { return store_index->m_BlockChunkCounts;} const uint32_t* Longtail_StoreIndex_GetBlockTags(const struct Longtail_StoreIndex* store_index) { return store_index->m_BlockTags;} const uint32_t* Longtail_StoreIndex_GetChunkSizes(const struct Longtail_StoreIndex* store_index) { return store_index->m_ChunkSizes;} diff --git a/src/longtail.h b/src/longtail.h index 7dcd0a6a..973a7fca 100644 --- a/src/longtail.h +++ b/src/longtail.h @@ -1409,7 +1409,6 @@ struct Longtail_StoreIndex uint32_t* m_ChunkCount; // Total number of chunks across all blocks - chunk hashes may occur more than once TLongtail_Hash* m_BlockHashes; // [] m_BlockHashes is the hash of each block TLongtail_Hash* m_ChunkHashes; // [] For each m_BlockChunkCount[n] there are n consecutive chunk hashes in m_ChunkHashes[] - uint32_t* m_BlockChunksOffsets; // [] m_BlockChunksOffsets[n] is the offset in m_ChunkBlockCount[] and m_ChunkHashes[] uint32_t* m_BlockChunkCounts; // [] m_BlockChunkCounts[n] is number of chunks in block m_BlockHash[n] uint32_t* m_BlockTags; // [] m_BlockTags is the tag for each block uint32_t* m_ChunkSizes; // [] m_ChunkSizes is the size of each chunk @@ -1421,7 +1420,6 @@ LONGTAIL_EXPORT uint32_t Longtail_StoreIndex_GetBlockCount(const struct Longtail LONGTAIL_EXPORT uint32_t Longtail_StoreIndex_GetChunkCount(const struct Longtail_StoreIndex* store_index); LONGTAIL_EXPORT const TLongtail_Hash* Longtail_StoreIndex_GetBlockHashes(const struct Longtail_StoreIndex* store_index); LONGTAIL_EXPORT const TLongtail_Hash* Longtail_StoreIndex_GetChunkHashes(const struct Longtail_StoreIndex* store_index); -LONGTAIL_EXPORT const uint32_t* Longtail_StoreIndex_GetBlockChunksOffsets(const struct Longtail_StoreIndex* store_index); LONGTAIL_EXPORT const uint32_t* Longtail_StoreIndex_GetBlockChunkCounts(const struct Longtail_StoreIndex* store_index); LONGTAIL_EXPORT const uint32_t* Longtail_StoreIndex_GetBlockTags(const struct Longtail_StoreIndex* store_index); LONGTAIL_EXPORT const uint32_t* Longtail_StoreIndex_GetChunkSizes(const struct Longtail_StoreIndex* store_index); @@ -1448,11 +1446,6 @@ LONGTAIL_EXPORT int Longtail_MergeStoreIndex( const struct Longtail_StoreIndex* remote_store_index, struct Longtail_StoreIndex** out_store_index); -LONGTAIL_EXPORT int Longtail_MakeBlockIndex( - const struct Longtail_StoreIndex* store_index, - uint32_t block_index, - struct Longtail_BlockIndex* out_block_index); - LONGTAIL_EXPORT int Longtail_GetExistingStoreIndex( const struct Longtail_StoreIndex* store_index, uint32_t chunk_count, diff --git a/test/test.cpp b/test/test.cpp index 0f13846a..f6971d80 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -607,36 +607,15 @@ TEST(Longtail, Longtail_CreateStoreIndexFromBlocks) ASSERT_EQ(4, *store_index->m_ChunkCount); ASSERT_EQ(*block_index1->m_BlockHash, store_index->m_BlockHashes[0]); ASSERT_EQ(*block_index1->m_Tag, store_index->m_BlockTags[0]); - ASSERT_EQ(0, store_index->m_BlockChunksOffsets[0]); ASSERT_EQ(2, store_index->m_BlockChunkCounts[0]); ASSERT_EQ(*block_index2->m_BlockHash, store_index->m_BlockHashes[1]); ASSERT_EQ(*block_index2->m_Tag, store_index->m_BlockTags[1]); - ASSERT_EQ(2, store_index->m_BlockChunksOffsets[1]); ASSERT_EQ(2, store_index->m_BlockChunkCounts[1]); ASSERT_EQ(chunk_hashes[0], store_index->m_ChunkHashes[0]); ASSERT_EQ(chunk_hashes[1], store_index->m_ChunkHashes[1]); ASSERT_EQ(chunk_hashes[2], store_index->m_ChunkHashes[2]); ASSERT_EQ(chunk_hashes[3], store_index->m_ChunkHashes[3]); - - struct Longtail_BlockIndex restored_block_indexes[2]; - ASSERT_EQ(0, Longtail_MakeBlockIndex(store_index, 0, &restored_block_indexes[0])); - ASSERT_EQ(0, Longtail_MakeBlockIndex(store_index, 1, &restored_block_indexes[1])); - - ASSERT_EQ(*block_index1->m_BlockHash, *restored_block_indexes[0].m_BlockHash); - ASSERT_EQ(*block_index1->m_HashIdentifier, *restored_block_indexes[0].m_HashIdentifier); - ASSERT_EQ(2, *restored_block_indexes[0].m_ChunkCount); - ASSERT_EQ(*block_index1->m_Tag, *restored_block_indexes[0].m_Tag); - ASSERT_EQ(chunk_hashes[0], restored_block_indexes[0].m_ChunkHashes[0]); - ASSERT_EQ(chunk_hashes[1], restored_block_indexes[0].m_ChunkHashes[1]); - - ASSERT_EQ(*block_index2->m_BlockHash, *restored_block_indexes[1].m_BlockHash); - ASSERT_EQ(*block_index2->m_HashIdentifier, *restored_block_indexes[1].m_HashIdentifier); - ASSERT_EQ(2, *restored_block_indexes[1].m_ChunkCount); - ASSERT_EQ(*block_index2->m_Tag, *restored_block_indexes[1].m_Tag); - ASSERT_EQ(chunk_hashes[2], restored_block_indexes[1].m_ChunkHashes[0]); - ASSERT_EQ(chunk_hashes[3], restored_block_indexes[1].m_ChunkHashes[1]); - Longtail_Free(store_index); Longtail_Free(block_index2); Longtail_Free(block_index1); @@ -756,11 +735,9 @@ TEST(Longtail, Longtail_MergeStoreIndex) ASSERT_EQ(5, *store_index->m_ChunkCount); ASSERT_EQ(*block_index1->m_BlockHash, store_index->m_BlockHashes[0]); ASSERT_EQ(*block_index1->m_Tag, store_index->m_BlockTags[0]); - ASSERT_EQ(0, store_index->m_BlockChunksOffsets[0]); ASSERT_EQ(2, store_index->m_BlockChunkCounts[0]); ASSERT_EQ(*block_index2->m_BlockHash, store_index->m_BlockHashes[1]); ASSERT_EQ(*block_index2->m_Tag, store_index->m_BlockTags[1]); - ASSERT_EQ(2, store_index->m_BlockChunksOffsets[1]); ASSERT_EQ(3, store_index->m_BlockChunkCounts[1]); ASSERT_EQ(chunk_hashes[0], store_index->m_ChunkHashes[0]); ASSERT_EQ(chunk_hashes[1], store_index->m_ChunkHashes[1]); @@ -815,35 +792,15 @@ TEST(Longtail, Longtail_CreateStoreIndexFromContentIndex) ASSERT_EQ(4, *store_index->m_ChunkCount); ASSERT_EQ(*block_index1->m_BlockHash, store_index->m_BlockHashes[0]); ASSERT_EQ(*block_index1->m_Tag, store_index->m_BlockTags[0]); - ASSERT_EQ(0, store_index->m_BlockChunksOffsets[0]); ASSERT_EQ(2, store_index->m_BlockChunkCounts[0]); ASSERT_EQ(*block_index2->m_BlockHash, store_index->m_BlockHashes[1]); ASSERT_EQ(*block_index2->m_Tag, store_index->m_BlockTags[1]); - ASSERT_EQ(2, store_index->m_BlockChunksOffsets[1]); ASSERT_EQ(2, store_index->m_BlockChunkCounts[1]); ASSERT_EQ(chunk_hashes[0], store_index->m_ChunkHashes[0]); ASSERT_EQ(chunk_hashes[1], store_index->m_ChunkHashes[1]); ASSERT_EQ(chunk_hashes[2], store_index->m_ChunkHashes[2]); ASSERT_EQ(chunk_hashes[3], store_index->m_ChunkHashes[3]); - struct Longtail_BlockIndex restored_block_indexes[2]; - ASSERT_EQ(0, Longtail_MakeBlockIndex(store_index, 0, &restored_block_indexes[0])); - ASSERT_EQ(0, Longtail_MakeBlockIndex(store_index, 1, &restored_block_indexes[1])); - - ASSERT_EQ(*block_index1->m_BlockHash, *restored_block_indexes[0].m_BlockHash); - ASSERT_EQ(*block_index1->m_HashIdentifier, *restored_block_indexes[0].m_HashIdentifier); - ASSERT_EQ(2, *restored_block_indexes[0].m_ChunkCount); - ASSERT_EQ(*block_index1->m_Tag, *restored_block_indexes[0].m_Tag); - ASSERT_EQ(chunk_hashes[0], restored_block_indexes[0].m_ChunkHashes[0]); - ASSERT_EQ(chunk_hashes[1], restored_block_indexes[0].m_ChunkHashes[1]); - - ASSERT_EQ(*block_index2->m_BlockHash, *restored_block_indexes[1].m_BlockHash); - ASSERT_EQ(*block_index2->m_HashIdentifier, *restored_block_indexes[1].m_HashIdentifier); - ASSERT_EQ(2, *restored_block_indexes[1].m_ChunkCount); - ASSERT_EQ(*block_index2->m_Tag, *restored_block_indexes[1].m_Tag); - ASSERT_EQ(chunk_hashes[2], restored_block_indexes[1].m_ChunkHashes[0]); - ASSERT_EQ(chunk_hashes[3], restored_block_indexes[1].m_ChunkHashes[1]); - Longtail_Free(store_index); Longtail_Free(block_index2); Longtail_Free(block_index1); @@ -6400,7 +6357,6 @@ TEST(Longtail, CopyStoreIndex) for (uint32_t b = 0; b < *s1->m_BlockCount; ++b) { ASSERT_EQ(s1->m_BlockHashes[b], s1c->m_BlockHashes[b]); - ASSERT_EQ(s1->m_BlockChunksOffsets[b], s1c->m_BlockChunksOffsets[b]); ASSERT_EQ(s1->m_BlockChunkCounts[b], s1c->m_BlockChunkCounts[b]); ASSERT_EQ(s1->m_BlockTags[b], s1c->m_BlockTags[b]); }