private int getUnsignedShort( ReadableChannel channel ) throws IOException { int result = channel.getShort() & 0xFFFF; return result == 0xFFFF ? -1 : result; }
private int getUnsignedShort( ReadableChannel channel ) throws IOException { int result = channel.getShort() & 0xFFFF; return result == 0xFFFF ? -1 : result; }
private int getUnsignedShort( ReadableChannel channel ) throws IOException { int result = channel.getShort() & 0xFFFF; return result == 0xFFFF ? -1 : result; }
private int getUnsignedShort( ReadableChannel channel ) throws IOException { int result = channel.getShort() & 0xFFFF; return result == 0xFFFF ? -1 : result; }
public static String read2bLengthAndString( ReadableChannel channel ) throws IOException { short length = channel.getShort(); return readString( channel, length ); }
public static Map<String, String> read2bMap( ReadableChannel channel ) throws IOException { short size = channel.getShort(); Map<String, String> map = new HashMap<>( size ); for ( int i = 0; i < size; i++ ) { String key = read2bLengthAndString( channel ); String value = read2bLengthAndString( channel ); map.put( key, value ); } return map; }
public static String read3bLengthAndString( ReadableChannel channel ) throws IOException { short lengthShort = channel.getShort(); byte lengthByte = channel.get(); int length = (lengthByte << 16) | (lengthShort & 0xFFFF); byte[] chars = new byte[length]; channel.get( chars, length ); return UTF8.decode( chars ); }
private static ReadableChannel channelWithRelGroupRecord( long id, byte inUse, short type, long next, long firstOut, long firstIn, long firstLoop, long owningNode ) throws IOException { ReadableChannel channel = mock( ReadableChannel.class ); when( channel.get() ).thenReturn( NeoCommandType.REL_GROUP_COMMAND ).thenReturn( inUse ); when( channel.getLong() ).thenReturn( id ).thenReturn( next ).thenReturn( firstOut ).thenReturn( firstIn ) .thenReturn( firstLoop ).thenReturn( owningNode ); when( channel.getShort() ).thenReturn( type ); return channel; } }
private Object readIndexValue( byte valueType, ReadableChannel channel ) throws IOException { switch ( valueType ) { case IndexCommand.VALUE_TYPE_NULL: return null; case IndexCommand.VALUE_TYPE_SHORT: return channel.getShort(); case IndexCommand.VALUE_TYPE_INT: return channel.getInt(); case IndexCommand.VALUE_TYPE_LONG: return channel.getLong(); case IndexCommand.VALUE_TYPE_FLOAT: return channel.getFloat(); case IndexCommand.VALUE_TYPE_DOUBLE: return channel.getDouble(); case IndexCommand.VALUE_TYPE_STRING: return read3bLengthAndString( channel ); default: throw new RuntimeException( "Unknown value type " + valueType ); } } }
private Object readIndexValue( byte valueType, ReadableChannel channel ) throws IOException { switch ( valueType ) { case IndexCommand.VALUE_TYPE_NULL: return null; case IndexCommand.VALUE_TYPE_SHORT: return channel.getShort(); case IndexCommand.VALUE_TYPE_INT: return channel.getInt(); case IndexCommand.VALUE_TYPE_LONG: return channel.getLong(); case IndexCommand.VALUE_TYPE_FLOAT: return channel.getFloat(); case IndexCommand.VALUE_TYPE_DOUBLE: return channel.getDouble(); case IndexCommand.VALUE_TYPE_STRING: return read3bLengthAndString( channel ); default: throw new RuntimeException( "Unknown value type " + valueType ); } } }
private Object readIndexValue( byte valueType, ReadableChannel channel ) throws IOException { switch ( valueType ) { case IndexCommand.VALUE_TYPE_NULL: return null; case IndexCommand.VALUE_TYPE_SHORT: return channel.getShort(); case IndexCommand.VALUE_TYPE_INT: return channel.getInt(); case IndexCommand.VALUE_TYPE_LONG: return channel.getLong(); case IndexCommand.VALUE_TYPE_FLOAT: return channel.getFloat(); case IndexCommand.VALUE_TYPE_DOUBLE: return channel.getDouble(); case IndexCommand.VALUE_TYPE_STRING: return read3bLengthAndString( channel ); default: throw new RuntimeException( "Unknown value type " + valueType ); } } }
private Object readIndexValue( byte valueType, ReadableChannel channel ) throws IOException { switch ( valueType ) { case IndexCommand.VALUE_TYPE_NULL: return null; case IndexCommand.VALUE_TYPE_SHORT: return channel.getShort(); case IndexCommand.VALUE_TYPE_INT: return channel.getInt(); case IndexCommand.VALUE_TYPE_LONG: return channel.getLong(); case IndexCommand.VALUE_TYPE_FLOAT: return channel.getFloat(); case IndexCommand.VALUE_TYPE_DOUBLE: return channel.getDouble(); case IndexCommand.VALUE_TYPE_STRING: return read3bLengthAndString( channel ); default: throw new RuntimeException( "Unknown value type " + valueType ); } } }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); byte inUseByte = channel.get(); boolean inUse = inUseByte == Record.IN_USE.byteValue(); if ( inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseByte ); } int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); return new Command.RelationshipGroupCommand( null, record ); }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); byte inUseByte = channel.get(); boolean inUse = inUseByte == Record.IN_USE.byteValue(); if ( inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseByte ); } int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); return new Command.RelationshipGroupCommand( null, record ); }
private RelationshipGroupRecord readRelationshipGroupRecord( long id, ReadableChannel channel ) throws IOException { byte flags = channel.get(); boolean inUse = bitFlag( flags, Record.IN_USE.byteValue() ); boolean requireSecondaryUnit = bitFlag( flags, Record.REQUIRE_SECONDARY_UNIT ); boolean hasSecondaryUnit = bitFlag( flags, Record.HAS_SECONDARY_UNIT ); boolean usesFixedReferenceFormat = bitFlag( flags, Record.USES_FIXED_REFERENCE_FORMAT ); int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); record.setRequiresSecondaryUnit( requireSecondaryUnit ); if ( hasSecondaryUnit ) { record.setSecondaryUnitId( channel.getLong() ); } record.setUseFixedReferences( usesFixedReferenceFormat ); return record; }
private RelationshipGroupRecord readRelationshipGroupRecord( long id, ReadableChannel channel ) throws IOException { byte flags = channel.get(); boolean inUse = bitFlag( flags, Record.IN_USE.byteValue() ); boolean requireSecondaryUnit = bitFlag( flags, Record.REQUIRE_SECONDARY_UNIT ); boolean hasSecondaryUnit = bitFlag( flags, Record.HAS_SECONDARY_UNIT ); boolean usesFixedReferenceFormat = bitFlag( flags, Record.USES_FIXED_REFERENCE_FORMAT ); int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); record.setRequiresSecondaryUnit( requireSecondaryUnit ); if ( hasSecondaryUnit ) { record.setSecondaryUnitId( channel.getLong() ); } record.setUseFixedReferences( usesFixedReferenceFormat ); return record; }
private int getUnsignedShort( ReadableChannel channel ) throws IOException { int result = channel.getShort() & 0xFFFF; return result == 0xFFFF ? -1 : result; }
private int getUnsignedShort( ReadableChannel channel ) throws IOException { int result = channel.getShort() & 0xFFFF; return result == 0xFFFF ? -1 : result; }
private int getUnsignedShort( ReadableChannel channel ) throws IOException { int result = channel.getShort() & 0xFFFF; return result == 0xFFFF ? -1 : result; }
public static Map<String, String> read2bMap( ReadableChannel channel ) throws IOException { short size = channel.getShort(); Map<String, String> map = new HashMap<>( size ); for ( int i = 0; i < size; i++ ) { String key = read2bLengthAndString( channel ); String value = read2bLengthAndString( channel ); map.put( key, value ); } return map; }