Ejemplo n.º 1
0
        void WriteHeaderToIndexForStream(RecordHeader header, Dictionary <RecordKey, RecordHeader> index,
                                         Stream stream)
        {
            var key = new RecordKey(header.Table, header.Key);

            if (header.Action == StorageActions.Store)
            {
                if (!index.ContainsKey(key))
                {
                    index.Add(key, header);
                }
                else
                {
                    index[key] = header;
                }

                stream.MovePositionForward(header.RecordSize);
            }
            else if (header.Action == StorageActions.Delete)
            {
                if (index.ContainsKey(key))
                {
                    index.Remove(key);
                }
            }
        }
Ejemplo n.º 2
0
        public byte[] Read(string table, string itemKey)
        {
            var key = new RecordKey(table, itemKey);

            if (_indexes.ContainsKey(key))
            {
                RecordHeader header = _indexes[key];

                return(ReadFromStream(_dataStream, header));
            }

            return(null);
        }