Пример #1
0
        public NeedleIndex Write(long key, int alternateKey, int cookie, byte[] data)
        {
            // sync
            var offset = _storeFile.Append(new Needle
            {
                Key = key,
                AlternateKey = alternateKey,
                Cookie = cookie,
                Data = data,
                DataCheckSum = Checksum(data),
                DataSize = data.Length,
                Flags = 0,
                FooterMagicNumber = 0,
                HeaderMagicNumber = 0,
                Padding = 0
            });

            var index = new NeedleIndex
            {
                Key = key,
                AlternateKey = alternateKey,
                DataSize = data.Length,
                Flags = 0,
                Offset = offset
            };

            // async / Fire and forget
            _indexFile.Append(index);

            return index;
        }
Пример #2
0
 public void AddAll(NeedleIndex[] needleIndex)
 {
     this[ImageSize.Large] = GetInfo(needleIndex, ImageSize.Large);
     this[ImageSize.Medium] = GetInfo(needleIndex, ImageSize.Medium);
     this[ImageSize.Small] = GetInfo(needleIndex, ImageSize.Small);
     this[ImageSize.Thumbnails] = GetInfo(needleIndex, ImageSize.Thumbnails);
 }
Пример #3
0
        public NeedleIndex Write(long key, int alternateKey, int cookie, byte[] data)
        {
            // sync
            var offset = _storeFile.Append(new Needle
            {
                Key               = key,
                AlternateKey      = alternateKey,
                Cookie            = cookie,
                Data              = data,
                DataCheckSum      = Checksum(data),
                DataSize          = data.Length,
                Flags             = 0,
                FooterMagicNumber = 0,
                HeaderMagicNumber = 0,
                Padding           = 0
            });

            var index = new NeedleIndex
            {
                Key          = key,
                AlternateKey = alternateKey,
                DataSize     = data.Length,
                Flags        = 0,
                Offset       = offset
            };

            // async / Fire and forget
            _indexFile.Append(index);

            return(index);
        }
Пример #4
0
        private InMemoryIndex ConvertToInMemoryIndex(NeedleIndex[] needleIndex)
        {
            var idx = new InMemoryIndex
            {
                PhotoKey = needleIndex[0].Key
            };

            idx.AddAll(needleIndex);

            return idx;
        }
Пример #5
0
        public void Store(long photoKey, int cookie, byte[][] allResizeResult)
        {
            // for now always assume 4 size (small, thumb, medium and large)

            var indexes = new NeedleIndex[4];

            for (var i = 0; i < allResizeResult.Length; i++)
            {
                // should be single thread access per file... ACTOR
                var index = _haystackService.Write(photoKey, i, cookie, allResizeResult[0]);

                indexes[i] = index;
            }

            _inMemoryIndex.Save(indexes);
        }
Пример #6
0
        public void Save(NeedleIndex[] index)
        {
            var inMemoryIdx = ConvertToInMemoryIndex(index);

            _inMemoryIndices.Add(inMemoryIdx.PhotoKey, inMemoryIdx);
        }
Пример #7
0
 private ImageInfo GetInfo(NeedleIndex[] needleIndex, ImageSize logicalSize)
 {
     return new ImageInfo { Size = needleIndex[(int)logicalSize].DataSize, Offset = needleIndex[(int)logicalSize].Offset };
 }
Пример #8
0
 // non blocking
 public void Append(NeedleIndex needleIndex)
 {
     // use actor
     throw new System.NotImplementedException();
 }