internal override unsafe Task <long> SaveChunk(SeriesChunk chunk) { var ret = base.SaveChunk(chunk); var extSid = this.GetExtendedSeriesId(chunk.Id); var header = new MessageHeader { UUID = new UUID(extSid.UUID), MessageType = MessageType.SetChunk, Version = chunk.Version }; var commandBody = new ChunkCommandBody { ChunkKey = chunk.ChunkKey, Count = chunk.Count, }; var len = MessageHeader.Size + ChunkCommandBody.Size; BufferClaim claim; _appendLog.Claim(len, out claim); *(MessageHeader *)(claim.Data) = header; TypeHelper <ChunkCommandBody> .StructureToPtr(commandBody, claim.Data + MessageHeader.Size); claim.ReservedValue = Pid; claim.Commit(); return(ret); }
internal virtual Task<long> SaveChunk(SeriesChunk chunk) { var setSQL = @"INSERT OR REPLACE INTO " + ChunkTableName + " (Id,ChunkKey,Count,Version,ChunkValue)" + " VALUES ( @id, @chKey, @count, @version, @chVal); UPDATE " + IdTableName + " SET Version = @version WHERE Id = @id;"; var processedTmp = _connection.Execute(setSQL, new { id = chunk.Id, chKey = chunk.ChunkKey, count = chunk.Count, version = chunk.Version, chVal = chunk.ChunkValue }); if (processedTmp < 1) throw new ApplicationException("Cannot set value"); return Task.FromResult(0L); }