Skip to content

Commit

Permalink
Provides LabelScanKey constructor for convenience
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint committed Jan 12, 2017
1 parent 2f1ac18 commit 100a6ac
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
Expand Up @@ -25,8 +25,18 @@
*/
class LabelScanKey
{
int labelId = -1;
long idRange = -1;
int labelId;
long idRange;

LabelScanKey()
{
clear();
}

LabelScanKey( int labelId, long idRange )
{
set( labelId, idRange );
}

/**
* Sets this key.
Expand All @@ -42,9 +52,14 @@ LabelScanKey set( int labelId, long idRange )
return this;
}

void clear()
{
set( -1, -1 );
}

@Override
public String toString()
{
return "[lbl:" + labelId + ",range:" + idRange + "]";
return "[label:" + labelId + ",range:" + idRange + "]";
}
}
Expand Up @@ -135,8 +135,8 @@ private List<PrimitiveLongIterator> iteratorsForLabels( int[] labelIds )

private RawCursor<Hit<LabelScanKey,LabelScanValue>,IOException> seekerForLabel( int labelId ) throws IOException
{
LabelScanKey from = new LabelScanKey().set( labelId, 0 );
LabelScanKey to = new LabelScanKey().set( labelId, Long.MAX_VALUE );
LabelScanKey from = new LabelScanKey( labelId, 0 );
LabelScanKey to = new LabelScanKey( labelId, Long.MAX_VALUE );
return index.seek( from, to );
}

Expand Down
Expand Up @@ -248,8 +248,8 @@ public void start() throws IOException
private boolean isEmpty() throws IOException
{
try ( RawCursor<Hit<LabelScanKey,LabelScanValue>,IOException> cursor = index.seek(
new LabelScanKey().set( 0, 0 ),
new LabelScanKey().set( Integer.MAX_VALUE, Long.MAX_VALUE ) ) )
new LabelScanKey( 0, 0 ),
new LabelScanKey( Integer.MAX_VALUE, Long.MAX_VALUE ) ) )
{
return !cursor.next();
}
Expand Down
Expand Up @@ -167,7 +167,7 @@ private void flushPendingChanges() throws IOException

long currentLabelId = lowestLabelId;
value.clear();
key.set( -1, -1 );
key.clear();
while ( currentLabelId != Long.MAX_VALUE )
{
long nextLabelId = Long.MAX_VALUE;
Expand Down
Expand Up @@ -72,7 +72,7 @@ public void shouldFindMultipleNodesInEachRange() throws Exception

private static Hit<LabelScanKey,LabelScanValue> hit( long baseNodeId, long bits )
{
LabelScanKey key = new LabelScanKey().set( LABEL_ID, baseNodeId );
LabelScanKey key = new LabelScanKey( LABEL_ID, baseNodeId );
LabelScanValue value = new LabelScanValue();
value.bits = bits;
return new MutableHit<>( key, value );
Expand Down
Expand Up @@ -173,7 +173,7 @@ private static LabelScanValue clone( LabelScanValue value )

private static LabelScanKey clone( LabelScanKey key )
{
return new LabelScanKey().set( key.labelId, key.idRange );
return new LabelScanKey( key.labelId, key.idRange );
}

@Override
Expand Down

0 comments on commit 100a6ac

Please sign in to comment.