You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2010/02/22 12:19:53 UTC
svn commit: r912534 - in
/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman: Location.java
RecordHeader.java TranslationPage.java
Author: akarasulu
Date: Mon Feb 22 11:19:52 2010
New Revision: 912534
URL: http://svn.apache.org/viewvc?rev=912534&view=rev
Log:
some more formatting while reading the code
Modified:
directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Location.java
directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordHeader.java
directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/TranslationPage.java
Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Location.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Location.java?rev=912534&r1=912533&r2=912534&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Location.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/Location.java Mon Feb 22 11:19:52 2010
@@ -44,78 +44,102 @@
*
* $Id: Location.java,v 1.2 2003/11/01 14:17:21 dranatunga Exp $
*/
-
package jdbm.recman;
+
/**
* This class represents a location within a file. Both physical and
* logical rowids are based on locations internally - this version is
* used when there is no file block to back the location's data.
*/
-final class Location {
+final class Location
+{
private long block;
private short offset;
+
/**
* Creates a location from a (block, offset) tuple.
*/
- Location(long block, short offset) {
+ Location( long block, short offset )
+ {
this.block = block;
this.offset = offset;
}
+
/**
- * Creates a location from a combined block/offset long, as
- * used in the external representation of logical rowids.
- *
- * @see #toLong()
+ * Creates a location from a combined block/offset long, as used in the
+ * external representation of logical rowids. A recid is a logical rowid.
*/
- Location(long blockOffset) {
- this.offset = (short) (blockOffset & 0xffff);
+ Location( long blockOffset )
+ {
+ this.offset = ( short ) ( blockOffset & 0xffff );
this.block = blockOffset >> 16;
}
+
/**
* Creates a location based on the data of the physical rowid.
*/
- Location(PhysicalRowId src) {
+ Location( PhysicalRowId src )
+ {
block = src.getBlock();
offset = src.getOffset();
}
+
/**
* Returns the file block of the location
*/
- long getBlock() {
+ long getBlock()
+ {
return block;
}
+
/**
* Returns the offset within the block of the location
*/
- short getOffset() {
+ short getOffset()
+ {
return offset;
}
+
/**
* Returns the external representation of a location when used
* as a logical rowid, which combines the block and the offset
* in a single long.
*/
- long toLong() {
- return (block << 16) + (long) offset;
+ long toLong()
+ {
+ return ( block << 16 ) + ( long ) offset;
}
- // overrides of java.lang.Object
-
- public boolean equals(Object o) {
- if (o == null || !(o instanceof Location))
+
+ // -----------------------------------------------------------------------
+ // java.lang.Object Overrides
+ // -----------------------------------------------------------------------
+
+
+ public boolean equals( Object o )
+ {
+ if ( o == null || ! ( o instanceof Location ) )
+ {
return false;
- Location ol = (Location) o;
+ }
+
+ Location ol = ( Location ) o;
return ol.block == block && ol.offset == offset;
}
- public String toString() {
- return "PL(" + block + ":" + offset + ")";
+
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append( "Location ( " ).append( block ).append( " : " );
+ sb.append( offset ).append( " ) " );
+ return sb.toString();
}
}
Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordHeader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordHeader.java?rev=912534&r1=912533&r2=912534&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordHeader.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/RecordHeader.java Mon Feb 22 11:19:52 2010
@@ -51,11 +51,11 @@
/**
- * The data that comes at the start of a record of data. It stores
- * both the current size and the available size for the record - the latter
- * can be bigger than the former, which allows the record to grow without
- * needing to be moved and which allows the system to put small records
- * in larger free spots.
+ * The data that comes at the start of a record of data. It stores both the
+ * current size and the available size for the record - the latter can be
+ * bigger than the former, which allows the record to grow without needing to
+ * be moved and which allows the system to put small records in larger free
+ * spots.
*/
class RecordHeader
{
@@ -70,13 +70,14 @@
/**
- * Constructs a record header from the indicated data starting at
- * the indicated position.
+ * Constructs a record header from the indicated data starting at the
+ * indicated position.
*/
RecordHeader( BlockIo block, short pos )
{
this.block = block;
this.pos = pos;
+
if ( pos > ( RecordFile.BLOCK_SIZE - SIZE ) )
{
throw new Error( I18n.err( I18n.ERR_562, block.getBlockId(), pos ) );
Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/TranslationPage.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/TranslationPage.java?rev=912534&r1=912533&r2=912534&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/TranslationPage.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/TranslationPage.java Mon Feb 22 11:19:52 2010
@@ -44,48 +44,59 @@
*
* $Id: TranslationPage.java,v 1.1 2000/05/06 00:00:31 boisvert Exp $
*/
-
package jdbm.recman;
+
/**
- * Class describing a page that holds translations from physical rowids
- * to logical rowids. In fact, the page just holds physical rowids - the
- * page's block is the block for the logical rowid, the offset serve
- * as offset for the rowids.
+ * Class describing a page that holds translations from physical rowids
+ * to logical rowids. In fact, the page just holds physical rowids - the
+ * page's block is the block for the logical rowid, the offset serve
+ * as offset for the rowids.
*/
-final class TranslationPage extends PageHeader {
+final class TranslationPage extends PageHeader
+{
// offsets
static final short O_TRANS = PageHeader.SIZE; // short count
- static final short ELEMS_PER_PAGE =
- (RecordFile.BLOCK_SIZE - O_TRANS) / PhysicalRowId.SIZE;
+ static final short ELEMS_PER_PAGE = ( RecordFile.BLOCK_SIZE - O_TRANS ) / PhysicalRowId.SIZE;
// slots we returned.
final PhysicalRowId[] slots = new PhysicalRowId[ELEMS_PER_PAGE];
+
/**
- * Constructs a data page view from the indicated block.
+ * Constructs a data page view from the indicated block.
*/
- TranslationPage(BlockIo block) {
- super(block);
+ TranslationPage( BlockIo block )
+ {
+ super( block );
}
+
/**
- * Factory method to create or return a data page for the
- * indicated block.
+ * Factory method to create or return a data page for the indicated block.
*/
- static TranslationPage getTranslationPageView(BlockIo block) {
+ static TranslationPage getTranslationPageView( BlockIo block )
+ {
BlockView view = block.getView();
- if (view != null && view instanceof TranslationPage)
- return (TranslationPage) view;
+ if ( view != null && view instanceof TranslationPage )
+ {
+ return ( TranslationPage ) view;
+ }
else
- return new TranslationPage(block);
+ {
+ return new TranslationPage( block );
+ }
}
+
/** Returns the value of the indicated rowid on the page */
- PhysicalRowId get(short offset) {
- int slot = (offset - O_TRANS) / PhysicalRowId.SIZE;
- if (slots[slot] == null)
- slots[slot] = new PhysicalRowId(block, offset);
+ PhysicalRowId get( short offset )
+ {
+ int slot = ( offset - O_TRANS ) / PhysicalRowId.SIZE;
+ if ( slots[slot] == null )
+ {
+ slots[slot] = new PhysicalRowId( block, offset );
+ }
return slots[slot];
}
}