org.apache.derby.impl.store.raw.log
Class LogCounter

java.lang.Object
  extended by org.apache.derby.impl.store.raw.log.LogCounter
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, Formatable, TypedFormat, DatabaseInstant, LogInstant

public class LogCounter
extends java.lang.Object
implements LogInstant

A very simple log instant implementation. Within the stored log record a log counter is represented as a long, hence the getValueAsLong() method. Outside the LogFactory the instant is passed around as a LogCounter (through its LogInstant interface). The way the long is encoded is such that < == > correctly tells if one log instant is lessThan, equals or greater than another.

See Also:
Serialized Form

Field Summary
static long DERBY_10_0_MAX_LOGFILE_NUMBER
           
private static long FILE_NUMBER_SHIFT
           
private static long FILE_POSITION_MASK
           
private  long fileNumber
           
private  long filePosition
           
static long INVALID_LOG_INSTANT
          A well defined value of an invalid log instant.
static long MAX_LOGFILE_NUMBER
           
static long MAX_LOGFILE_SIZE
           
 
Constructor Summary
LogCounter()
          Public niladic constructor needed for Formatable interface.
LogCounter(long value)
           
LogCounter(long fileNumber, long position)
           
 
Method Summary
 boolean equals(java.lang.Object other)
          Return true if this DatabaseInstant equals DatabaseInstant from the same database.
 long getLogFileNumber()
           
static long getLogFileNumber(long valueAsLong)
           
 long getLogFilePosition()
           
static long getLogFilePosition(long valueAsLong)
           
 int getTypeFormatId()
          Get the formatID which corresponds to this class.
 long getValueAsLong()
          These following methods are only intended to be called by an implementation of a log factory.
 int hashCode()
           
 boolean lessThan(DatabaseInstant other)
          LogScan methods
static long makeLogInstantAsLong(long filenum, long filepos)
          Static functions that can only be used inside the RawStore's log factory which passes the log counter around encoded as a long
 DatabaseInstant next()
          Return the next higher DatabaseInstant.
 DatabaseInstant prior()
          Return the next lower DatabaseInstant.
 void readExternal(java.io.ObjectInput oi)
          Read this in.
static java.lang.String toDebugString(long instant)
           
 java.lang.String toString()
          Convert the database instant to a string.
 void writeExternal(java.io.ObjectOutput oo)
          Write this out.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

INVALID_LOG_INSTANT

public static final long INVALID_LOG_INSTANT
A well defined value of an invalid log instant.

See Also:
Constant Field Values

DERBY_10_0_MAX_LOGFILE_NUMBER

public static final long DERBY_10_0_MAX_LOGFILE_NUMBER
See Also:
Constant Field Values

MAX_LOGFILE_NUMBER

public static final long MAX_LOGFILE_NUMBER
See Also:
Constant Field Values

FILE_NUMBER_SHIFT

private static final long FILE_NUMBER_SHIFT
See Also:
Constant Field Values

MAX_LOGFILE_SIZE

public static final long MAX_LOGFILE_SIZE
See Also:
Constant Field Values

FILE_POSITION_MASK

private static final long FILE_POSITION_MASK
See Also:
Constant Field Values

fileNumber

private long fileNumber

filePosition

private long filePosition
Constructor Detail

LogCounter

public LogCounter(long value)

LogCounter

public LogCounter(long fileNumber,
                  long position)

LogCounter

public LogCounter()
Public niladic constructor needed for Formatable interface.

Method Detail

makeLogInstantAsLong

public static final long makeLogInstantAsLong(long filenum,
                                              long filepos)
Static functions that can only be used inside the RawStore's log factory which passes the log counter around encoded as a long


getLogFilePosition

public static final long getLogFilePosition(long valueAsLong)

getLogFileNumber

public static final long getLogFileNumber(long valueAsLong)

lessThan

public boolean lessThan(DatabaseInstant other)
LogScan methods

Specified by:
lessThan in interface DatabaseInstant
Parameters:
other - a DatabaseInstant from the same database as this.
Returns:
the comparison result. If 'other' is from another database the result is undefined.

equals

public boolean equals(java.lang.Object other)
Description copied from interface: DatabaseInstant
Return true if this DatabaseInstant equals DatabaseInstant from the same database.

Specified by:
equals in interface DatabaseInstant
Overrides:
equals in class java.lang.Object
Parameters:
other - a DatabaseInstant from the same database as this.
Returns:
the comparison result. If 'other' is from another database the result is undefined.

next

public DatabaseInstant next()
Description copied from interface: DatabaseInstant
Return the next higher DatabaseInstant. There is no requirement that a transaction with the next instant exist in the database. It is required that this.lessThan( this.next()), and that no instant can be between this and this.next(). If the DatabaseInstant is implemented using a integer then next() should return a new DatabaseInstant formed by adding one to the integer.

Specified by:
next in interface DatabaseInstant
Returns:
the next possible DatabaseInstant

prior

public DatabaseInstant prior()
Description copied from interface: DatabaseInstant
Return the next lower DatabaseInstant. There is no requirement that a transaction with the next instant exist in the database. It is required that this.prior().lessThan( this), and that no instant can be between this and this.prior(). If the DatabaseInstant is implemented using a integer then prior() should return a new DatabaseInstant formed by subtracting one from the integer.

Specified by:
prior in interface DatabaseInstant
Returns:
the prior possible DatabaseInstant

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Description copied from interface: DatabaseInstant
Convert the database instant to a string. This is mainly used for debugging.

Specified by:
toString in interface DatabaseInstant
Overrides:
toString in class java.lang.Object
Returns:
a string representation of the instant.

toDebugString

public static java.lang.String toDebugString(long instant)

getValueAsLong

public long getValueAsLong()
These following methods are only intended to be called by an implementation of a log factory. All other uses of this object should only see it as a log instant.


getLogFilePosition

public long getLogFilePosition()

getLogFileNumber

public long getLogFileNumber()

readExternal

public void readExternal(java.io.ObjectInput oi)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Read this in.

Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException - error reading from log stream
java.lang.ClassNotFoundException - corrupted log stream

writeExternal

public void writeExternal(java.io.ObjectOutput oo)
                   throws java.io.IOException
Write this out.

Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException - error writing to log stream

getTypeFormatId

public int getTypeFormatId()
Get the formatID which corresponds to this class.

Specified by:
getTypeFormatId in interface TypedFormat
Returns:
the formatID of this class

Built on Thu 2011-03-10 11:54:14+0000, from revision ???

Apache Derby V10.6 Internals - Copyright © 2004,2007 The Apache Software Foundation. All Rights Reserved.