294 var removedBlocks =
new List<IndexBlock>();
297 var sIndexSet = (SnapshotIndexSet)indexSet;
298 var indices = sIndexSet.AllIndices.ToList();
305 foreach (var index
in indices) {
306 int indexNum = index.IndexNumber;
312 var blocks = index.AllBlocks.ToList();
316 long blockP = area.
Id;
319 area.WriteInt8(blocks.Count);
321 foreach (var block
in blocks) {
322 var mappedBlock = (IMappedBlock)block;
326 int blockSize = mappedBlock.Count;
328 bottomInt = mappedBlock.Bottom;
329 topInt = mappedBlock.Top;
332 long blockPointer = mappedBlock.BlockPointer;
335 if (blockPointer == -1 || mappedBlock.HasChanged) {
338 if (blockPointer != -1)
339 curIndexBlock.AddDeletedArea(blockPointer);
343 blockPointer = mappedBlock.Flush();
346 area.WriteInt8(bottomInt);
347 area.WriteInt8(topInt);
348 area.WriteInt8(blockPointer);
349 area.WriteInt4(blockSize | (((
int)mappedBlock.CompactType) << 24));
356 var deletedBlocks = index.DeletedBlocks.ToArray();
357 for (
int i = 0; i < deletedBlocks.Length; ++i) {
358 long delBlockP = deletedBlocks[i].BlockPointer;
360 curIndexBlock.AddDeletedArea(delBlockP);
364 curIndexBlock.MarkAsDeleted();
367 var newIndexBlock =
new IndexBlock(
this, indexNum, curIndexBlock.BlockSize, blockP);
368 newIndexBlock.Parent = curIndexBlock;
371 newIndexBlock.AddReference();
377 removedBlocks.Add(curIndexBlock);
388 }
catch (IOException e) {
389 throw new InvalidOperationException(
"Error while committing index changed", e);
395 foreach (var block
in removedBlocks) {
396 block.RemoveReference();
IArea CreateArea(long size)
Allocates a block of memory in the store of the specified size and returns an IArea object that can b...
void Lock()
This method is called before the start of a sequence of Write commands between consistant states of s...
void Unlock()
This method is called after the end of a sequence of Write commands between consistant states of some...
long Id
Returns the unique identifier that represents this area.