Skip to content

Commit

Permalink
Safe StringLayout.readKey
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Feb 15, 2018
1 parent 2688a4c commit 6bd0c15
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.neo4j.io.pagecache.PageCursor;

import static java.lang.String.format;

import static org.neo4j.kernel.impl.index.schema.StringSchemaKey.ENTITY_ID_SIZE;

/**
Expand Down Expand Up @@ -81,6 +80,11 @@ public void writeValue( PageCursor cursor, NativeSchemaValue value )
public void readKey( PageCursor cursor, StringSchemaKey into, int keySize )
{
// TODO consider reusing byte[] instances somehow
if ( keySize < ENTITY_ID_SIZE )
{
into.bytes = null;
return;
}
into.setEntityId( cursor.getLong() );
into.bytes = new byte[keySize - ENTITY_ID_SIZE];
cursor.getBytes( into.bytes );
Expand Down

0 comments on commit 6bd0c15

Please sign in to comment.