From 54b09992663108197155dfc01c6c496ac8d169fd Mon Sep 17 00:00:00 2001 From: Anton Persson Date: Tue, 14 Aug 2018 15:45:47 +0200 Subject: [PATCH] Small cleanup --- .../impl/index/schema/GenericKeyState.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/GenericKeyState.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/GenericKeyState.java index 90f1cf8a07e77..4614e4a1c49d9 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/GenericKeyState.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/index/schema/GenericKeyState.java @@ -916,11 +916,6 @@ private ArrayElementWriter numberArrayElementWriter( long long1 ) } } - interface ArrayElementWriter - { - void write( PageCursor cursor, int i ); - } - private void putArray( PageCursor cursor, ArrayElementWriter writer ) { cursor.putInt( arrayLength ); @@ -1065,13 +1060,7 @@ boolean read( PageCursor cursor, int size ) case BOOLEAN_ARRAY: return readArray( cursor, ArrayType.BOOLEAN, this::readBoolean ); case NUMBER_ARRAY: - long1 = cursor.getByte(); // number type, like: byte, int, short a.s.o. - ArrayType numberType = numberArrayTypeOf( (byte) long1 ); - if ( numberType == null ) - { - return false; - } - return readArray( cursor, numberType, numberArrayElementReader( long1 ) ); + return readNumberArray( cursor ); default: return false; } @@ -1095,6 +1084,17 @@ private boolean readArray( PageCursor cursor, ArrayType type, ArrayElementReader return true; } + private boolean readNumberArray( PageCursor cursor ) + { + long1 = cursor.getByte(); // number type, like: byte, int, short a.s.o. + ArrayType numberType = numberArrayTypeOf( (byte) long1 ); + if ( numberType == null ) + { + return false; + } + return readArray( cursor, numberType, numberArrayElementReader( long1 ) ); + } + private ArrayElementReader numberArrayElementReader( long long1 ) { switch ( (int) long1 ) @@ -1862,8 +1862,6 @@ private static long[] ensureBigEnough( long[] array, int targetLength ) private static NumberValue numberAsValue( long long0, long long1 ) { - // There's a difference between composing a single text value and a array text value - // and there's therefore no common "raw" variant of it return RawBits.asNumberValue( long0, (byte) long1 ); } @@ -1879,7 +1877,7 @@ private static boolean booleanAsValueRaw( long long0 ) private static Value textAsValue( byte[] byteArray, long long0 ) { - // There's a difference between composing a single text value and a array text value + // There's a difference between composing a single text value and a array text values // and there's therefore no common "raw" variant of it return byteArray == null ? NO_VALUE : Values.utf8Value( byteArray, 0, (int) long0 ); } @@ -1982,6 +1980,12 @@ interface ArrayElementReader boolean readFrom( PageCursor cursor ); } + @FunctionalInterface + interface ArrayElementWriter + { + void write( PageCursor cursor, int i ); + } + @FunctionalInterface interface ArrayElementValueFactory {