Skip to content

Commit

Permalink
Move all value creation one step down
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusmelke committed Aug 23, 2017
1 parent 1b8d89a commit e2d5cf1
Showing 1 changed file with 35 additions and 27 deletions.
Expand Up @@ -31,6 +31,14 @@
import org.neo4j.kernel.impl.store.record.Record; import org.neo4j.kernel.impl.store.record.Record;
import org.neo4j.kernel.impl.util.Bits; import org.neo4j.kernel.impl.util.Bits;
import org.neo4j.string.UTF8; import org.neo4j.string.UTF8;
import org.neo4j.values.storable.BooleanValue;
import org.neo4j.values.storable.ByteValue;
import org.neo4j.values.storable.CharValue;
import org.neo4j.values.storable.DoubleValue;
import org.neo4j.values.storable.FloatValue;
import org.neo4j.values.storable.IntValue;
import org.neo4j.values.storable.LongValue;
import org.neo4j.values.storable.ShortValue;
import org.neo4j.values.storable.TextValue; import org.neo4j.values.storable.TextValue;
import org.neo4j.values.storable.Value; import org.neo4j.values.storable.Value;
import org.neo4j.values.storable.Values; import org.neo4j.values.storable.Values;
Expand Down Expand Up @@ -136,60 +144,60 @@ int propertyKeyId()
return PropertyBlock.keyIndexId( currentHeader() ); return PropertyBlock.keyIndexId( currentHeader() );
} }


boolean booleanValue() private BooleanValue booleanValue()
{ {
assertOfType( BOOL ); assertOfType( BOOL );
return PropertyBlock.fetchByte( currentHeader() ) == 1; return Values.booleanValue( PropertyBlock.fetchByte( currentHeader() ) == 1 );
} }


byte byteValue() private ByteValue byteValue()
{ {
assertOfType( BYTE ); assertOfType( BYTE );
return PropertyBlock.fetchByte( currentHeader() ); return Values.byteValue( PropertyBlock.fetchByte( currentHeader() ) );
} }


short shortValue() private ShortValue shortValue()
{ {
assertOfType( SHORT ); assertOfType( SHORT );
return PropertyBlock.fetchShort( currentHeader() ); return Values.shortValue( PropertyBlock.fetchShort( currentHeader() ) );
} }


char charValue() private CharValue charValue()
{ {
assertOfType( CHAR ); assertOfType( CHAR );
return (char) PropertyBlock.fetchShort( currentHeader() ); return Values.charValue( (char) PropertyBlock.fetchShort( currentHeader() ) );
} }


int intValue() private IntValue intValue()
{ {
assertOfType( INT ); assertOfType( INT );
return PropertyBlock.fetchInt( currentHeader() ); return Values.intValue( PropertyBlock.fetchInt( currentHeader() ) );
} }


float floatValue() private FloatValue floatValue()
{ {
assertOfType( FLOAT ); assertOfType( FLOAT );
return Float.intBitsToFloat( PropertyBlock.fetchInt( currentHeader() ) ); return Values.floatValue( Float.intBitsToFloat( PropertyBlock.fetchInt( currentHeader() ) ) );
} }


long longValue() private LongValue longValue()
{ {
assertOfType( LONG ); assertOfType( LONG );
if ( PropertyBlock.valueIsInlined( currentHeader() ) ) if ( PropertyBlock.valueIsInlined( currentHeader() ) )
{ {
return PropertyBlock.fetchLong( currentHeader() ) >>> 1; return Values.longValue( PropertyBlock.fetchLong( currentHeader() ) >>> 1 );
} }


return data[position + 1]; return Values.longValue( data[position + 1] );
} }


double doubleValue() private DoubleValue doubleValue()
{ {
assertOfType( DOUBLE ); assertOfType( DOUBLE );
return Double.longBitsToDouble( data[position + 1] ); return Values.doubleValue( Double.longBitsToDouble( data[position + 1] ) );
} }


TextValue shortStringValue() private TextValue shortStringValue()
{ {
assertOfType( SHORT_STRING ); assertOfType( SHORT_STRING );
return LongerShortString.decode( data, position, currentBlocksUsed() ); return LongerShortString.decode( data, position, currentBlocksUsed() );
Expand All @@ -203,7 +211,7 @@ TextValue stringValue()
return Values.stringValue( UTF8.decode( buffer.array(), 0, buffer.limit() ) ); return Values.stringValue( UTF8.decode( buffer.array(), 0, buffer.limit() ) );
} }


Value shortArrayValue() private Value shortArrayValue()
{ {
assertOfType( SHORT_ARRAY ); assertOfType( SHORT_ARRAY );
Bits bits = valueAsBits(); Bits bits = valueAsBits();
Expand All @@ -223,21 +231,21 @@ Value value()
switch ( type() ) switch ( type() )
{ {
case BOOL: case BOOL:
return Values.booleanValue( booleanValue() ); return booleanValue();
case BYTE: case BYTE:
return Values.byteValue( byteValue() ); return byteValue();
case SHORT: case SHORT:
return Values.shortValue( shortValue() ); return shortValue();
case CHAR: case CHAR:
return Values.charValue( charValue() ); return charValue();
case INT: case INT:
return Values.intValue( intValue() ); return intValue();
case LONG: case LONG:
return Values.longValue( longValue() ); return longValue();
case FLOAT: case FLOAT:
return Values.floatValue( floatValue() ); return floatValue();
case DOUBLE: case DOUBLE:
return Values.doubleValue( doubleValue() ); return doubleValue();
case SHORT_STRING: case SHORT_STRING:
return shortStringValue(); return shortStringValue();
case STRING: case STRING:
Expand Down

0 comments on commit e2d5cf1

Please sign in to comment.