public virtual void TestLong() { long l1 = 785412; byte[] b = byteArrayConverter.LongToByteArray(l1); long l2 = byteArrayConverter.ByteArrayToLong(b, 0); AssertEquals(l1, l2); l1 = long.MaxValue; b = byteArrayConverter.LongToByteArray(l1); l2 = byteArrayConverter.ByteArrayToLong(b, 0); AssertEquals(l1, l2); l1 = long.MinValue; b = byteArrayConverter.LongToByteArray(l1); l2 = byteArrayConverter.ByteArrayToLong(b, 0); AssertEquals(l1, l2); }
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)); } }
public virtual void WriteLong(long i, bool writeInTransaction, string label, int writeActionType) { byte[] bytes = byteArrayConverter.LongToByteArray(i); if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId) && canLog && label != null) { NeoDatis.Tool.DLogger.Debug("writing long " + i + " at " + GetPosition() + " : " + label); } if (!writeInTransaction) { io.WriteBytes(bytes); } else { GetSession().GetTransaction().ManageWriteAction(io.GetCurrentPosition(), bytes); EnsureSpaceFor(NeoDatis.Odb.Core.Layers.Layer2.Meta.ODBType.NativeLong); } bytes = null; }