public virtual StoreResult RemovekeyMetadata(ITransaction metadataTransaction, JSONDocument document, long rowId, IOperationContext context) { StorageResult <byte[]> result = _metadataPersister.DeleteDocument <long, byte[]>(metadataTransaction, GetKeyMetadataCollection(), rowId); if (result.Status == StoreResult.Success || result.Status == StoreResult.SuccessDelete || result.Status == StoreResult.SuccessKeyDoesNotExist) { lock (_rowToFileIndex) { _rowToFileIndex.Remove(rowId); } if (result.Status != StoreResult.SuccessKeyDoesNotExist) { //if (_statsCollector != null) //{ // _statsCollector.DecrementStatsValue(StatisticsType.DocumentCount); // SetAverageDocumentSize(); //} } lock (_keyToRowIndex) { _enumerationSet.Remove(rowId); } return(StoreResult.Success); } return(result.Status); }
protected void PersistFileMetadata(string databaseId, FileMetadata <long, byte[]> fileMetadata, ITransaction transaction) { if (fileMetadata == null) //if null then remove { //inMemory StoreKeyMetadata (needs to be done first) _fileMetadataDictionary.Remove(databaseId); //dbPersist _metadataPersister.DeleteDocument <string, byte[]>(transaction, "FileMetadata", databaseId); } else //else update previous { //inMemory StoreKeyMetadata _fileMetadataDictionary[databaseId] = fileMetadata; //dbPersist _metadataPersister.StoreDocument(transaction, "FileMetadata", databaseId, CompactBinaryFormatter.ToByteBuffer(fileMetadata, "")); } }