Example #1
0
 public virtual void ApplyTo(NeoDatis.Odb.Core.Layers.Layer3.Engine.IFileSystemInterface
                             fsi, int index)
 {
     if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
     {
         NeoDatis.Tool.DLogger.Debug("Applying WriteAction #" + index + " : " + ToString()
                                     );
     }
     fsi.SetWritePosition(position, false);
     for (int i = 0; i < listOfBytes.Count; i++)
     {
         fsi.WriteBytes(GetBytes(i), false, "WriteAction");
     }
 }
Example #2
0
        public virtual void Persist(NeoDatis.Odb.Core.Layers.Layer3.Engine.IFileSystemInterface
                                    fsi, int index)
        {
            long currentPosition = fsi.GetPosition();

            if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId))
            {
            }
            // DLogger.debug("# Writing WriteAction #" + index + " at " +
            // currentPosition+" : " + toString());
            int sizeOfLong = NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.Long.GetSize();
            int sizeOfInt  = NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.Integer.GetSize();

            // build the full byte array to write once
            byte[] bytes           = new byte[sizeOfLong + sizeOfInt + size];
            byte[] bytesOfPosition = byteArrayConverter.LongToByteArray(position);
            byte[] bytesOfSize     = byteArrayConverter.IntToByteArray(size);
            for (int i = 0; i < sizeOfLong; i++)
            {
                bytes[i] = bytesOfPosition[i];
            }
            int offset = sizeOfLong;

            for (int i = 0; i < sizeOfInt; i++)
            {
                bytes[offset] = bytesOfSize[i];
                offset++;
            }
            for (int i = 0; i < listOfBytes.Count; i++)
            {
                byte[] tmp = listOfBytes[i];
                System.Array.Copy(tmp, 0, bytes, offset, tmp.Length);
                offset += tmp.Length;
            }
            fsi.WriteBytes(bytes, false, "Transaction");
            int  fixedSize          = sizeOfLong + sizeOfInt;
            long positionAfterWrite = fsi.GetPosition();
            long writeSize          = positionAfterWrite - currentPosition;

            if (writeSize != size + fixedSize)
            {
                throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.DifferentSizeInWriteAction
                                                           .AddParameter(size).AddParameter(writeSize));
            }
        }