Top Description Fields Constructors Methods
org.apache.derby.impl.store.raw.log

public Class LogCounter

extends Object
implements LogInstant
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.store.raw.log.LogInstant, org.apache.derby.iapi.store.access.DatabaseInstant, java.io.Serializable, org.apache.derby.iapi.services.io.Formatable, org.apache.derby.iapi.services.io.TypedFormat, java.io.Externalizable
Imports
org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.services.io.FormatIdUtil, .StoredFormatIds, .CompressedNumber, org.apache.derby.iapi.store.raw.log.LogInstant, org.apache.derby.iapi.store.access.DatabaseInstant, java.io.IOException, .ObjectInput, .ObjectOutput

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.

Field Summary

Modifier and TypeField and Description
public static final long
private static final long
private static final long
private long
private long
public static final long
public static final long
public static final long

Constructor Summary

AccessConstructor and Description
public
LogCounter(long value)

public
LogCounter(long fileNumber, long position)

public
LogCounter()

Public niladic constructor needed for Formatable interface.

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
a DatabaseInstant from the same database as this.
other
)

Overrides java.lang.Object.equals.

Implements org.apache.derby.iapi.store.access.DatabaseInstant.equals.

Return true if this DatabaseInstant equals DatabaseInstant from the same database.

public static final long
getLogFileNumber(long valueAsLong)

public long
public static final long
getLogFilePosition(long valueAsLong)

public long
public int

Returns:

the formatID of this class
getTypeFormatId
()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Get the formatID which corresponds to this class.

public long
getValueAsLong()

These following methods are only intended to be called by an implementation of a log factory.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
lessThan(DatabaseInstant
a DatabaseInstant from the same database as this.
other
)

Implements org.apache.derby.iapi.store.access.DatabaseInstant.lessThan.

LogScan methods

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

public DatabaseInstant
next()

Implements org.apache.derby.iapi.store.access.DatabaseInstant.next.

Return the next higher DatabaseInstant.

public DatabaseInstant
prior()

Implements org.apache.derby.iapi.store.access.DatabaseInstant.prior.

Return the next lower DatabaseInstant.

public void
readExternal(ObjectInput
the stream to read data from in order to restore the object
oi
)

Implements java.io.Externalizable.readExternal.

Read this in.

public static String
toDebugString(long instant)

public String
toString()

Overrides java.lang.Object.toString.

Implements org.apache.derby.iapi.store.access.DatabaseInstant.toString.

Convert the database instant to a string.

public void
writeExternal(ObjectOutput
the stream to write the object to
oo
)

Implements java.io.Externalizable.writeExternal.

Write this out.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

DERBY_10_0_MAX_LOGFILE_NUMBERback to summary
public static final long DERBY_10_0_MAX_LOGFILE_NUMBER
FILE_NUMBER_SHIFTback to summary
private static final long FILE_NUMBER_SHIFT
FILE_POSITION_MASKback to summary
private static final long FILE_POSITION_MASK
fileNumberback to summary
private long fileNumber
filePositionback to summary
private long filePosition
INVALID_LOG_INSTANTback to summary
public static final long INVALID_LOG_INSTANT

Hides org.apache.derby.iapi.store.raw.log.LogInstant.INVALID_LOG_INSTANT.

A well defined value of an invalid log instant.

MAX_LOGFILE_NUMBERback to summary
public static final long MAX_LOGFILE_NUMBER
MAX_LOGFILE_SIZEback to summary
public static final long MAX_LOGFILE_SIZE

Constructor Detail

LogCounterback to summary
public LogCounter(long value)
LogCounterback to summary
public LogCounter(long fileNumber, long position)
LogCounterback to summary
public LogCounter()

Public niladic constructor needed for Formatable interface.

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Implements org.apache.derby.iapi.store.access.DatabaseInstant.equals.

Doc from org.apache.derby.iapi.store.access.DatabaseInstant.equals.

Return true if this DatabaseInstant equals DatabaseInstant from the same database.

Parameters
other:Object

a DatabaseInstant from the same database as this.

Returns:boolean

the comparison result. If 'other' is from another database the result is undefined.

getLogFileNumberback to summary
public static final long getLogFileNumber(long valueAsLong)
getLogFileNumberback to summary
public long getLogFileNumber()
getLogFilePositionback to summary
public static final long getLogFilePosition(long valueAsLong)
getLogFilePositionback to summary
public long getLogFilePosition()
getTypeFormatIdback to summary
public int getTypeFormatId()

Implements org.apache.derby.iapi.services.io.TypedFormat.getTypeFormatId.

Get the formatID which corresponds to this class.

Returns:int

the formatID of this class

getValueAsLongback to summary
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.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

lessThanback to summary
public boolean lessThan(DatabaseInstant other)

Implements org.apache.derby.iapi.store.access.DatabaseInstant.lessThan.

LogScan methods

Parameters
other:DatabaseInstant

Doc from org.apache.derby.iapi.store.access.DatabaseInstant.lessThan.

a DatabaseInstant from the same database as this.

Returns:boolean

Doc from org.apache.derby.iapi.store.access.DatabaseInstant.lessThan.

the comparison result. If 'other' is from another database the result is undefined.

makeLogInstantAsLongback to summary
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

nextback to summary
public DatabaseInstant next()

Implements org.apache.derby.iapi.store.access.DatabaseInstant.next.

Doc from org.apache.derby.iapi.store.access.DatabaseInstant.next.

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.

Returns:DatabaseInstant

the next possible DatabaseInstant

priorback to summary
public DatabaseInstant prior()

Implements org.apache.derby.iapi.store.access.DatabaseInstant.prior.

Doc from org.apache.derby.iapi.store.access.DatabaseInstant.prior.

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.

Returns:DatabaseInstant

the prior possible DatabaseInstant

readExternalback to summary
public void readExternal(ObjectInput oi) throws IOException, ClassNotFoundException

Implements java.io.Externalizable.readExternal.

Read this in.

Parameters
oi:ObjectInput

Doc from java.io.Externalizable.readExternal.

the stream to read data from in order to restore the object

Exceptions
IOException:
error reading from log stream
ClassNotFoundException:
corrupted log stream
toDebugStringback to summary
public static String toDebugString(long instant)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements org.apache.derby.iapi.store.access.DatabaseInstant.toString.

Doc from org.apache.derby.iapi.store.access.DatabaseInstant.toString.

Convert the database instant to a string. This is mainly used for debugging.

Returns:String

a string representation of the instant.

writeExternalback to summary
public void writeExternal(ObjectOutput oo) throws IOException

Implements java.io.Externalizable.writeExternal.

Write this out.

Parameters
oo:ObjectOutput

Doc from java.io.Externalizable.writeExternal.

the stream to write the object to

Exceptions
IOException:
error writing to log stream