Ejemplo n.º 1
0
 internal void WriteHeader(AbstractBufferedWriter writer)
 {
     FileCollectionWithFileInfos.WriteHeader(writer, _guid);
     writer.WriteUInt8((byte)KVFileType.TransactionLog);
     writer.WriteVInt64(_generation);
     writer.WriteVInt32((int) _previousFileId);
 }
Ejemplo n.º 2
0
 internal void WriteHeader(AbstractBufferedWriter writer)
 {
     writer.WriteByteArrayRaw(FileCollectionWithFileInfos.MagicStartOfFile);
     writer.WriteUInt8((byte)KVFileType.TransactionLog);
     writer.WriteVInt64(_generation);
     writer.WriteVInt32((int) _previousFileId);
 }
Ejemplo n.º 3
0
 public void WriteHeader(AbstractBufferedWriter writer)
 {
     FileCollectionWithFileInfos.WriteHeader(writer, _guid);
     writer.WriteUInt8((byte)KVFileType.PureValuesWithId);
     writer.WriteVInt64(_subId);
     writer.WriteVInt64(_generation);
 }
Ejemplo n.º 4
0
 public void WriteHeader(AbstractBufferedWriter writer)
 {
     writer.WriteByteArrayRaw(FileCollectionWithFileInfos.MagicStartOfFile);
     writer.WriteUInt8((byte)KVFileType.PureValuesWithId);
     writer.WriteVInt64(_subId);
     writer.WriteVInt64(_generation);
 }
Ejemplo n.º 5
0
 internal void Store(AbstractBufferedWriter writer)
 {
     writer.WriteVUInt32(BindingId);
     writer.WriteVUInt32(ServiceId);
     writer.WriteVUInt32(MethodId);
     writer.WriteBool(OneWay);
 }
Ejemplo n.º 6
0
 internal void WriteHeader(AbstractBufferedWriter writer)
 {
     FileCollectionWithFileInfos.WriteHeader(writer, _guid);
     writer.WriteUInt8((byte) KVFileType.HashKeyIndex);
     writer.WriteVInt64(_subId);
     writer.WriteVInt64(_generation);
     writer.WriteVUInt32(_keyLen);
 }
Ejemplo n.º 7
0
 internal void WriteHeader(AbstractBufferedWriter writer)
 {
     writer.WriteByteArrayRaw(DiskChunkCache.MagicStartOfFile);
     writer.WriteUInt8((byte)DiskChunkFileType.HashIndex);
     writer.WriteVInt64(_generation);
     writer.WriteVUInt32((uint)KeySize);
     writer.WriteVUInt64((ulong)KeyValueCount);
 }
Ejemplo n.º 8
0
 internal void Save(AbstractBufferedWriter writer)
 {
     writer.WriteVUInt32((uint)FieldCount);
     for (int i = 0; i < FieldCount; i++)
     {
         this[i].Save(writer);
     }
 }
Ejemplo n.º 9
0
 internal void WriteHeader(AbstractBufferedWriter writer)
 {
     writer.WriteByteArrayRaw(FileCollectionWithFileInfos.MagicStartOfFile);
     writer.WriteUInt8((byte) KVFileType.HashKeyIndex);
     writer.WriteVInt64(_subId);
     writer.WriteVInt64(_generation);
     writer.WriteVUInt32(_keyLen);
 }
Ejemplo n.º 10
0
 internal void WriteHeader(AbstractBufferedWriter writer)
 {
     writer.WriteByteArrayRaw(FileCollectionWithFileInfos.MagicStartOfFile);
     writer.WriteUInt8((byte)KVFileType.KeyIndex);
     writer.WriteVInt64(_generation);
     writer.WriteVUInt32(_trLogFileId);
     writer.WriteVUInt32(_trLogOffset);
     writer.WriteVUInt64((ulong)_keyValueCount);
 }
Ejemplo n.º 11
0
 internal void WriteHeader(AbstractBufferedWriter writer)
 {
     FileCollectionWithFileInfos.WriteHeader(writer, _guid);
     writer.WriteUInt8((byte)KVFileType.ModernKeyIndex);
     writer.WriteVInt64(_generation);
     writer.WriteVUInt32(_trLogFileId);
     writer.WriteVUInt32(_trLogOffset);
     writer.WriteVUInt64((ulong)_keyValueCount);
     writer.WriteVUInt64(_commitUlong);
     writer.WriteUInt8((byte) _compressionType);
 }
Ejemplo n.º 12
0
 internal void WriteHeader(AbstractBufferedWriter writer)
 {
     FileCollectionWithFileInfos.WriteHeader(writer, _guid);
     var withCommitUlong = _commitUlong != 0;
     writer.WriteUInt8((byte)(withCommitUlong ? KVFileType.KeyIndexWithCommitUlong : KVFileType.KeyIndex));
     writer.WriteVInt64(_generation);
     writer.WriteVUInt32(_trLogFileId);
     writer.WriteVUInt32(_trLogOffset);
     writer.WriteVUInt64((ulong)_keyValueCount);
     if (withCommitUlong)
         writer.WriteVUInt64(_commitUlong);
 }
Ejemplo n.º 13
0
 public void Store(AbstractBufferedWriter writer)
 {
     writer.WriteString(_name);
     writer.WriteString(_ifaceName);
     if (_resultFieldHandler != null)
     {
         writer.WriteString(_resultFieldHandler.Name);
         writer.WriteByteArray(_resultFieldHandler.Configuration);
     }
     else
     {
         writer.WriteString(null);
     }
     writer.WriteVUInt32((uint)_parameters.Length);
     foreach (var parameter in _parameters)
     {
         parameter.Store(writer);
     }
 }
Ejemplo n.º 14
0
 void StoreDescriptor(ITypeDescriptor descriptor, AbstractBufferedWriter writer)
 {
     if (descriptor is ListTypeDescriptor)
     {
         writer.WriteUInt8((byte)TypeCategory.List);
     }
     else if (descriptor is DictionaryTypeDescriptor)
     {
         writer.WriteUInt8((byte)TypeCategory.Dictionary);
     }
     else if (descriptor is ObjectTypeDescriptor)
     {
         writer.WriteUInt8((byte)TypeCategory.Class);
     }
     else if (descriptor is EnumTypeDescriptor)
     {
         writer.WriteUInt8((byte)TypeCategory.Enum);
     }
     else
     {
         throw new ArgumentOutOfRangeException();
     }
     ((IPersistTypeDescriptor)descriptor).Persist(writer, (w, d) =>
     {
         SerializerTypeInfo result;
         if (!_typeOrDescriptor2Info.TryGetValue(d, out result))
             if (!_typeOrDescriptor2InfoNew.TryGetValue(d, out result))
                 throw new BTDBException("Invalid state unknown descriptor " + d.Name);
         w.WriteVInt32(result.Id);
     });
 }
Ejemplo n.º 15
0
 public DBWriterCtx(IInternalObjectDBTransaction transaction, AbstractBufferedWriter writer, bool preferInline)
 {
     _transaction = transaction;
     _writer = writer;
     _preferInline = preferInline;
 }
Ejemplo n.º 16
0
 public void Persist(AbstractBufferedWriter writer, Action<AbstractBufferedWriter, ITypeDescriptor> nestedDescriptorPersistor)
 {
     writer.WriteString(_name);
     writer.WriteVUInt32((_signed ? 1u : 0) + (_flags ? 2u : 0) + 4u * (uint)_pairs.Count);
     foreach (var pair in _pairs)
     {
         writer.WriteString(pair.Key);
         if (_signed)
             writer.WriteVInt64((long)pair.Value);
         else
             writer.WriteVUInt64(pair.Value);
     }
 }
Ejemplo n.º 17
0
 public void Store(AbstractBufferedWriter writer)
 {
     writer.WriteString(_name);
     writer.WriteVUInt32((uint)_methodInfs.Length);
     foreach (var methodInf in _methodInfs)
     {
         methodInf.Store(writer);
     }
     writer.WriteVUInt32((uint)PropertyInfs.Length);
     foreach (var propertyInf in PropertyInfs)
     {
         propertyInf.Store(writer);
     }
 }
Ejemplo n.º 18
0
 void StartNewPureValueFile()
 {
     _pureValueFile = _fileCollection.AddFile("hpv");
     _pureValueFileWriter = _pureValueFile.GetAppenderWriter();
     var fileInfo = new FilePureValuesWithId(_subDBId, _fileCollection.NextGeneration());
     fileInfo.WriteHeader(_pureValueFileWriter);
     _fileCollection.SetInfo(_pureValueFile.Index, fileInfo);
 }
Ejemplo n.º 19
0
 void StartNewHashIndexFile()
 {
     _hashIndexFile = _fileCollection.AddFile("hid");
     _hashIndexWriter = _hashIndexFile.GetAppenderWriter();
     var fileInfo = new HashKeyIndex(_subDBId, _fileCollection.NextGeneration(), (uint)_keyLen);
     fileInfo.WriteHeader(_hashIndexWriter);
     _fileCollection.SetInfo(_hashIndexFile.Index, fileInfo);
 }
Ejemplo n.º 20
0
 internal static void WriteHeader(AbstractBufferedWriter writer, Guid? guid)
 {
     if (guid.HasValue)
     {
         writer.WriteByteArrayRaw(MagicStartOfFileWithGuid);
         writer.WriteGuid(guid.Value);
     }
     else
     {
         writer.WriteByteArrayRaw(MagicStartOfFile);
     }
 }
Ejemplo n.º 21
0
 void SetNewValueFile()
 {
     _cacheValueFile = _fileCollection.AddFile("cav");
     _cacheValueFileId = _cacheValueFile.Index;
     _cacheValueWriter = _cacheValueFile.GetAppenderWriter();
 }
Ejemplo n.º 22
0
 public void StoreDescriptor(ITypeDescriptor descriptor, AbstractBufferedWriter writer, Func<ITypeDescriptor, uint> descriptor2Id)
 {
     if (descriptor is ListTypeDescriptor)
     {
         writer.WriteUInt8((byte)TypeCategory.List);
     }
     else if (descriptor is DictionaryTypeDescriptor)
     {
         writer.WriteUInt8((byte)TypeCategory.Dictionary);
     }
     else if (descriptor is ObjectTypeDescriptor)
     {
         writer.WriteUInt8((byte)TypeCategory.Class);
     }
     else if (descriptor is EnumTypeDescriptor)
     {
         writer.WriteUInt8((byte)TypeCategory.Enum);
     }
     else
     {
         throw new ArgumentOutOfRangeException();
     }
     var p = descriptor as IPersistTypeDescriptor;
     p.Persist(writer, (w, d) => w.WriteVUInt32(descriptor2Id(d)));
 }
Ejemplo n.º 23
0
 public void Persist(AbstractBufferedWriter writer, Action<AbstractBufferedWriter, ITypeDescriptor> nestedDescriptorPersistor)
 {
     writer.WriteString(Name);
     writer.WriteVUInt32((uint)_fields.Count);
     foreach (var pair in _fields)
     {
         writer.WriteString(pair.Key);
         nestedDescriptorPersistor(writer, pair.Value);
     }
 }
Ejemplo n.º 24
0
 public void Persist(AbstractBufferedWriter writer, Action<AbstractBufferedWriter, ITypeDescriptor> nestedDescriptorPersistor)
 {
     nestedDescriptorPersistor(writer, _keyDescriptor);
     nestedDescriptorPersistor(writer, _valueDescriptor);
 }
Ejemplo n.º 25
0
 public DBWriterCtx(IInternalObjectDBTransaction transaction, AbstractBufferedWriter writer)
 {
     _transaction = transaction;
     _writer = writer;
 }
Ejemplo n.º 26
0
 internal void Save(AbstractBufferedWriter writer)
 {
     writer.WriteString(_name);
     writer.WriteString(_handler.Name);
     writer.WriteByteArray(_handler.Configuration);
 }
Ejemplo n.º 27
0
 public void Store(AbstractBufferedWriter writer)
 {
     writer.WriteString(_name);
     writer.WriteString(_fieldHandler.Name);
     writer.WriteByteArray(_fieldHandler.Configuration);
 }
Ejemplo n.º 28
0
 public void WriteHeader(AbstractBufferedWriter writer)
 {
     writer.WriteByteArrayRaw(DiskChunkCache.MagicStartOfFile);
     writer.WriteUInt8((byte)DiskChunkFileType.PureValues);
     writer.WriteVInt64(_generation);
 }
Ejemplo n.º 29
0
 void MoveValuesContent(AbstractBufferedWriter writer, uint wastefullFileId)
 {
     const uint blockSize = 128 * 1024;
     var wasteFullStream = _keyValueDB.FileCollection.GetFile(wastefullFileId);
     var totalSize = wasteFullStream.GetSize();
     var blocks = (int)((totalSize + blockSize - 1) / blockSize);
     var wasteInMemory = new byte[blocks][];
     var pos = 0UL;
     for (var i = 0; i < blocks; i++)
     {
         _cancellation.ThrowIfCancellationRequested();
         wasteInMemory[i] = new byte[blockSize];
         var readSize = totalSize - pos;
         if (readSize > blockSize) readSize = blockSize;
         wasteFullStream.RandomRead(wasteInMemory[i], 0, (int)readSize, pos);
         pos += readSize;
     }
     _root.Iterate((valueFileId, valueOfs, valueSize) =>
         {
             if (valueFileId != wastefullFileId) return;
             var size = (uint)Math.Abs(valueSize);
             _newPositionMap.Add(((ulong)wastefullFileId << 32) | valueOfs, (uint)writer.GetCurrentPosition());
             pos = valueOfs;
             while (size > 0)
             {
                 _cancellation.ThrowIfCancellationRequested();
                 var blockId = pos / blockSize;
                 var blockStart = pos % blockSize;
                 var writeSize = (uint)(blockSize - blockStart);
                 if (writeSize > size) writeSize = size;
                 writer.WriteBlock(wasteInMemory[blockId], (int)blockStart, (int)writeSize);
                 size -= writeSize;
                 pos += writeSize;
             }
         });
 }
Ejemplo n.º 30
0
 public ServiceWriterCtx(IServiceInternalServer serviceServer, AbstractBufferedWriter writer)
 {
     _serviceClient = null;
     _serviceServer = serviceServer;
     _writer = writer;
 }