/// <summary> /// Reads serialization state /// </summary> protected static SerializedState ReadSerializationState(BuildXLReader reader) { Contract.RequiresNotNull(reader); SerializedState result = new SerializedState(); result.NextId = reader.ReadInt32(); result.ByteBuffers = new byte[NumByteBuffers][]; int indexOfPartiallyFilledBuffer, lengthInPartiallyFilledBuffer; GetBufferIndex(result.NextId, out indexOfPartiallyFilledBuffer, out lengthInPartiallyFilledBuffer); for (int i = 0; i < NumByteBuffers; i++) { int arrayLength = reader.ReadInt32(); if (arrayLength == NullArrayMarker) { continue; } var buffer = new byte[arrayLength]; reader.Read(buffer, 0, i == indexOfPartiallyFilledBuffer ? lengthInPartiallyFilledBuffer : arrayLength); result.ByteBuffers[i] = buffer; } result.LargeStringBuffer = LargeStringBuffer.Deserialize(reader); result.StringSet = ConcurrentBigSet <StringId> .Deserialize(reader, () => reader.ReadStringId()); result.Count = reader.ReadInt32(); return(result); }
/// <nodoc /> internal StringTable(int initialCapacity = 0) { Contract.Requires(initialCapacity >= 0); #if DebugStringTable DebugRegisterStringTable(this); #endif CaseInsensitiveEqualityComparer = new CaseInsensitiveStringIdEqualityComparer(this); CaseInsensitiveComparer = new CaseInsensitiveStringIdComparer(this); OrdinalComparer = new OrdinalStringIdComparer(this); m_stringSet = new ConcurrentBigSet <StringId>(capacity: initialCapacity); // set up the initial buffer and consume the first byte so that StringId.Invalid's slot is consumed m_byteBuffers[0] = new byte[BytesPerBuffer]; m_largeStringBuffer = new LargeStringBuffer(); m_nextId = 1; Empty = AddString(string.Empty); }
/// <summary> /// Constructor used for deserialized tables /// </summary> protected StringTable(SerializedState state) { Contract.RequiresNotNull(state); #if DebugStringTable DebugRegisterStringTable(this); #endif CaseInsensitiveEqualityComparer = new CaseInsensitiveStringIdEqualityComparer(this); CaseInsensitiveComparer = new CaseInsensitiveStringIdComparer(this); OrdinalComparer = new OrdinalStringIdComparer(this); m_largeStringBuffer = state.LargeStringBuffer; m_byteBuffers = state.ByteBuffers; m_count = state.Count; m_nextId = state.NextId; m_stringSet = state.StringSet; Empty = AddString(string.Empty); }