Exemplo n.º 1
0
        private byte[] readblockdata(AllocationBlock ab)
        {
            byte[] data   = new byte[ab.datalength];
            long   offset = 0;
            int    len    = ab.datalength;
            int    dbsize = _BlockSize - _blockheader.Length - ab.keylen;

            ab.Blocks.ForEach(x =>
            {
                byte[] b = _datastore.ReadBlock(x);
                int c    = len;
                if (c > dbsize)
                {
                    c = dbsize;
                }
                Buffer.BlockCopy(b, _blockheader.Length + ab.keylen, data, (int)offset, c);
                offset += c;
                len    -= c;
            });
            if (ab.isCompressed)
            {
                data = MiniLZO.Decompress(data);
            }
            return(data);
        }
Exemplo n.º 2
0
        public object GetObjectHF(string key)
        {
            lock (_lock)
            {
                int alloc;
                if (_keys.Get(key, out alloc))
                {
                    AllocationBlock ab = FillAllocationBlock(alloc);
                    if (ab.deleteKey == false)
                    {
                        byte[] data   = new byte[ab.datalength];
                        long   offset = 0;
                        int    len    = ab.datalength;
                        int    dbsize = _BlockSize - _blockheader.Length - ab.keylen;
                        ab.Blocks.ForEach(x =>
                        {
                            byte[] b = _datastore.ReadBlock(x);
                            int c    = len;
                            if (c > dbsize)
                            {
                                c = dbsize;
                            }
                            Buffer.BlockCopy(b, _blockheader.Length + ab.keylen, data, (int)offset, c);
                            offset += c;
                            len    -= c;
                        });
                        if (ab.isCompressed)
                        {
                            data = MiniLZO.Decompress(data);
                        }

                        return(fastBinaryJSON.BJSON.ToObject(data));
                    }
                }
            }

            return(null);
        }