Esempio n. 1
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            IDataValue tempValue = arguments[0] as IDataValue;

            if (tempValue == null)
            {
                tempValue = DataValue.FromNative(program.ValueManager, arguments[0]);
            }

            if (tempValue.IsPhysicalStreaming)
            {
                using (Stream stream = tempValue.OpenStream())
                {
                    return((int)CRC32Utility.GetCRC32(stream));
                }
            }
            else
            {
                byte[] physical = new byte[tempValue.GetPhysicalSize(true)];
                tempValue.WriteToPhysical(physical, 0, true);
                return((int)CRC32Utility.GetCRC32(physical));
            }
        }
Esempio n. 2
0
        private IDataValue _writeValue;      // saves the row instantiated to write the compound value if this is a compound scalar

        public override int GetPhysicalSize(bool expandStreams)
        {
            int size = 1;             // Scalar header

            if (!IsNil)
            {
                if (IsNative)
                {
                    if (DataType.IsCompound)
                    {
                        _writeValue = DataValue.FromNative(Manager, DataType.CompoundRowType, Value);
                        return(size + _writeValue.GetPhysicalSize(expandStreams));
                    }
                    else
                    {
                        Streams.IConveyor conveyor = Manager.GetConveyor(DataType);
                        if (conveyor.IsStreaming)
                        {
                            _writeStream = new MemoryStream(64);
                            conveyor.Write(Value, _writeStream);
                            return(size + (int)_writeStream.Length);
                        }
                        return(size + conveyor.GetSize(Value));
                    }
                }

                if (expandStreams)
                {
                    _writeStream = Manager.StreamManager.Open(StreamID, LockMode.Exclusive);
                    return(size + (int)_writeStream.Length);
                }

                return(size + StreamID.CSizeOf);
            }
            return(size);
        }