Skip to content

Commit

Permalink
Remove minKey and maxKey from layout interface
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Nov 23, 2016
1 parent 56eac96 commit 461b3c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 43 deletions.
Expand Up @@ -59,11 +59,7 @@ class ConsistencyChecker<KEY>

public boolean check( PageCursor cursor ) throws IOException
{
KEY leftSideOfRange = layout.newKey();
layout.minKey( leftSideOfRange );
KEY rightSideOfRange = layout.newKey();
layout.maxKey( rightSideOfRange );
KeyRange<KEY> openRange = new KeyRange<>( comparator, leftSideOfRange, rightSideOfRange, layout, null );
KeyRange<KEY> openRange = new KeyRange<>( comparator, null, null, layout, null );
boolean result = checkSubtree( cursor, openRange, 0 );

// Assert that rightmost node on each level has empty right sibling.
Expand Down Expand Up @@ -181,10 +177,8 @@ private KeyRange( Comparator<KEY> comparator, KEY fromInclusive, KEY toExclusive
{
this.comparator = comparator;
this.superRange = superRange;
this.fromInclusive = layout.newKey();
layout.copyKey( fromInclusive, this.fromInclusive );
this.toExclusive = layout.newKey();
layout.copyKey( toExclusive, this.toExclusive );
this.fromInclusive = fromInclusive == null ? null : layout.copyKey( fromInclusive, layout.newKey() );
this.toExclusive = toExclusive == null ? null : layout.copyKey( toExclusive, layout.newKey() );
this.layout = layout;
}

Expand All @@ -203,7 +197,7 @@ boolean inRange( KEY key )

KeyRange<KEY> restrictLeft( KEY left )
{
if ( comparator.compare( fromInclusive, left ) < 0 )
if ( fromInclusive == null || comparator.compare( fromInclusive, left ) < 0 )
{
return new KeyRange<>( comparator, left, toExclusive, layout, this );
}
Expand All @@ -212,7 +206,7 @@ KeyRange<KEY> restrictLeft( KEY left )

KeyRange<KEY> restrictRight( KEY right )
{
if ( comparator.compare( toExclusive, right ) > 0 )
if ( toExclusive == null || comparator.compare( toExclusive, right ) > 0 )
{
return new KeyRange<>( comparator, fromInclusive, right, layout, this );
}
Expand Down
19 changes: 2 additions & 17 deletions community/index/src/main/java/org/neo4j/index/gbptree/Layout.java
Expand Up @@ -39,29 +39,14 @@ public interface Layout<KEY,VALUE> extends Comparator<KEY>
*/
KEY newKey();

/**
* Populates {@code into} with minimum key that can ever exist in a tree with this layout.
*
* @param into instance to write minimum key into.
* @return the provided {@code into} instance for convenience.
*/
KEY minKey( KEY into );

/**
* Populates {@code into} with maximum key that can ever exist in a tree with this layout.
*
* @param into instance to write maximum key into.
* @return the provided {@code into} instance for convenience.
*/
KEY maxKey( KEY into );

/**
* Copies contents of {@code key} to {@code into}.
*
* @param key key (left unchanged as part of this call) to copy contents from.
* @param into key (changed as part of this call) to copy contents into.
* @return the provided {@code into} instance for convenience.
*/
void copyKey( KEY key, KEY into );
KEY copyKey( KEY key, KEY into );

/**
* @return new value instance.
Expand Down
Expand Up @@ -52,23 +52,10 @@ public MutableLong newKey()
}

@Override
public MutableLong minKey( MutableLong into )
{
into.setValue( Long.MIN_VALUE );
return into;
}

@Override
public MutableLong maxKey( MutableLong into )
{
into.setValue( Long.MAX_VALUE );
return into;
}

@Override
public void copyKey( MutableLong key, MutableLong into )
public MutableLong copyKey( MutableLong key, MutableLong into )
{
into.setValue( key.longValue() );
return into;
}

@Override
Expand Down

0 comments on commit 461b3c4

Please sign in to comment.