Пример #1
0
        public WrappedDevice(ISegmentedDevice device)
        {
            _device      = device;
            _segmentSize = device.GetSegmentSize();

            if (!Utility.IsPowerOfTwo(_segmentSize))
            {
                throw new Exception("Invalid segment size");
            }

            _segmentSizeBits = Utility.GetLogBase2((ulong)_segmentSize);
            _segmentSizeMask = _segmentSize - 1;
        }
Пример #2
0
        /// <summary>
        /// Initialize
        /// </summary>
        /// <param name="size"></param>
        /// <param name="sector_size"></param>
        public void Initialize(long size, int sector_size)
        {
            if (!Utility.IsPowerOfTwo(size))
            {
                throw new ArgumentException("Size {0} is not a power of 2");
            }
            if (!Utility.Is32Bit(size))
            {
                throw new ArgumentException("Size {0} is not 32-bit");
            }

            minTableSize       = size;
            resizeInfo         = default(ResizeInfo);
            resizeInfo.status  = ResizeOperationStatus.DONE;
            resizeInfo.version = 0;
            Initialize(resizeInfo.version, size, sector_size);
        }
Пример #3
0
 /// <summary>
 /// Initialize device
 /// </summary>
 /// <param name="segmentSize"></param>
 public void Initialize(long segmentSize)
 {
     this.segmentSize = segmentSize;
     if (!Utility.IsPowerOfTwo(segmentSize))
     {
         if (segmentSize != -1)
         {
             throw new Exception("Invalid segment size: " + segmentSize);
         }
         segmentSizeBits = 64;
         segmentSizeMask = ~0UL;
     }
     else
     {
         segmentSizeBits = Utility.GetLogBase2((ulong)segmentSize);
         segmentSizeMask = (ulong)segmentSize - 1;
     }
 }
Пример #4
0
 /// <summary>
 /// Initialize device
 /// </summary>
 /// <param name="segmentSize"></param>
 /// <param name="epoch"></param>
 public virtual void Initialize(long segmentSize, LightEpoch epoch = null)
 {
     Debug.Assert(Capacity == -1 || Capacity % segmentSize == 0, "capacity must be a multiple of segment sizes");
     this.segmentSize = segmentSize;
     this.epoch       = epoch;
     if (!Utility.IsPowerOfTwo(segmentSize))
     {
         if (segmentSize != -1)
         {
             throw new FasterException("Invalid segment size: " + segmentSize);
         }
         segmentSizeBits = 64;
         segmentSizeMask = ~0UL;
     }
     else
     {
         segmentSizeBits = Utility.GetLogBase2((ulong)segmentSize);
         segmentSizeMask = (ulong)segmentSize - 1;
     }
 }
Пример #5
0
 /// <summary>
 /// Initialize device
 /// </summary>
 /// <param name="segmentSize"></param>
 /// <param name="epoch"></param>
 public virtual void Initialize(long segmentSize, LightEpoch epoch = null)
 {
     // TODO(Tianyu): Alternatively, we can adjust capacity based on the segment size: given a phsyical upper limit of capacity,
     // we only make use of (Capacity / segmentSize * segmentSize) many bytes.
     Debug.Assert(Capacity == -1 || Capacity % segmentSize == 0, "capacity must be a multiple of segment sizes");
     this.segmentSize = segmentSize;
     this.epoch       = epoch;
     if (!Utility.IsPowerOfTwo(segmentSize))
     {
         if (segmentSize != -1)
         {
             throw new Exception("Invalid segment size: " + segmentSize);
         }
         segmentSizeBits = 64;
         segmentSizeMask = ~0UL;
     }
     else
     {
         segmentSizeBits = Utility.GetLogBase2((ulong)segmentSize);
         segmentSizeMask = (ulong)segmentSize - 1;
     }
 }
Пример #6
0
        public StorageDeviceBase(
            string filename, long segmentSize, uint sectorSize)
        {
            FileName    = filename;
            SegmentSize = segmentSize;

            if (!Utility.IsPowerOfTwo(segmentSize))
            {
                if (segmentSize != -1)
                {
                    throw new Exception("Invalid segment size: " + segmentSize);
                }
                segmentSizeBits = 64;
                segmentSizeMask = ~0UL;
            }
            else
            {
                segmentSizeBits = Utility.GetLogBase2((ulong)segmentSize);
                segmentSizeMask = (ulong)segmentSize - 1;
            }

            SectorSize = sectorSize;
        }