/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 2009 Oracle. All rights reserved.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using BerkeleyDB.Internal;
namespace BerkeleyDB {
///
/// A log sequence number, which specifies a unique location in a log file.
///
public class LSN {
///
/// The log file number.
///
public uint LogFileNumber;
///
/// The offset in the log file.
///
public uint Offset;
///
/// Instantiate a new LSN object
///
/// The log file number.
/// The offset in the log file.
public LSN(uint file, uint off) {
LogFileNumber = file;
Offset = off;
}
internal LSN(DB_LSN dblsn) {
LogFileNumber = dblsn.file;
Offset = dblsn.offset;
}
internal static DB_LSN getDB_LSN(LSN inp) {
if (inp == null)
return null;
DB_LSN ret = new DB_LSN();
ret.file = inp.LogFileNumber;
ret.offset = inp.Offset;
return ret;
}
///
/// Compare two LSNs.
///
/// The first LSN to compare
/// The second LSN to compare
///
/// 0 if they are equal, 1 if lsn1 is greater than lsn2, and -1 if lsn1
/// is less than lsn2.
///
public static int Compare(LSN lsn1, LSN lsn2) {
DB_LSN a = new DB_LSN();
a.offset = lsn1.Offset;
a.file = lsn1.LogFileNumber;
DB_LSN b = new DB_LSN();
b.offset = lsn2.Offset;
b.file = lsn2.LogFileNumber;
return libdb_csharp.log_compare(a, b);
}
}
}