@Override public AnyValue value( int offset ) { return Values.intValue( value[offset] ); }
private void addIfNonZero( MapValueBuilder builder, String name, int count ) { if ( count > 0 ) { builder.add( name, intValue( count ) ); } }
/** * @see RandomValues */ public IntValue nextIntValue() { return intValue( generator.nextInt() ); }
@Override public Value valueOf( long x ) { return intValue( 10 + (int) x ); } } );
@Override public Value value( PropertyBlock block, PropertyStore store ) { return Values.intValue( block.getSingleValueInt() ); } },
/** * Returns the next {@link IntValue} between 0 (inclusive) and the specified value (exclusive) * * @param bound the upper bound (exclusive). Must be positive. * @return {@link IntValue} * @see RandomValues */ public IntValue nextIntValue( int bound ) { return intValue( generator.nextInt( bound ) ); }
@Test void getIfAbsentPut() { assertEquals( intValue( 10 ), map.getIfAbsentPut( 0, intValue( 10 ) ) ); assertEquals( intValue( 10 ), map.getIfAbsentPut( 0, intValue( 100 ) ) ); assertEquals( intValue( 11 ), map.getIfAbsentPut( 1, intValue( 11 ) ) ); assertEquals( intValue( 11 ), map.getIfAbsentPut( 1, intValue( 110 ) ) ); assertEquals( intValue( 12 ), map.getIfAbsentPut( 2, intValue( 12 ) ) ); assertEquals( intValue( 12 ), map.getIfAbsentPut( 2, intValue( 120 ) ) ); }
@Test void putAll() { map.putAll( LongObjectHashMap.newWithKeysValues( 0, intValue( 10 ), 1, intValue( 11 ), 2, intValue( 12 ) ) ); assertEquals( 3, map.size() ); assertEquals( intValue( 10 ), map.get( 0 ) ); assertEquals( intValue( 11 ), map.get( 1 ) ); assertEquals( intValue( 12 ), map.get( 2 ) ); }
@Test public void shouldSerializeNode() throws Throwable { NodeValue nodeValue = nodeValue( 12L, stringArray( "User", "Banana" ), VirtualValues .map( new String[]{"name", "age"}, new AnyValue[]{stringValue( "Bob" ), intValue( 14 )} ) ); assertThat( serialized( nodeValue ), equalTo( "B1 71 91 B3 4E 0C 92 84 55 73 65 72 86 42 61 6E" + lineSeparator() + "61 6E 61 A2 84 6E 61 6D 65 83 42 6F 62 83 61 67" + lineSeparator() + "65 0E" ) ); }
@Test public void shouldSerializeNode() throws Throwable { NodeValue nodeValue = nodeValue( 12L, stringArray( "User", "Banana" ), map( new String[]{"name", "age"}, new AnyValue[]{stringValue( "Bob" ), intValue( 14 )} ) ); assertThat( serialized( nodeValue ), equalTo( "B1 71 91 B3 4E 0C 92 84 55 73 65 72 86 42 61 6E" + lineSeparator() + "61 6E 61 A2 84 6E 61 6D 65 83 42 6F 62 83 61 67" + lineSeparator() + "65 0E" ) ); }
private void addDocumentToIndex( SchemaIndex index, int documents ) throws IOException { for ( int i = 0; i < documents; i++ ) { index.getIndexWriter().addDocument( LuceneDocumentStructure.documentRepresentingProperties( (long) i, Values.intValue( i ) ) ); } }
@Test void shouldHandleNodeValue() { // Given NodeValue node = VirtualValues.nodeValue( 42L, Values.stringArray( "L1", "L2", "L3" ), props( "foo", intValue( 42 ), "bar", list( intValue( 1337 ), stringValue( "baz" ) ) ) ); PrettyPrinter printer = new PrettyPrinter(); // When node.writeTo( printer ); // Then assertThat( printer.value(), equalTo( "(id=42 :L1:L2:L3 {bar: [1337, \"baz\"], foo: 42})" ) ); }
@Test void shouldHandleNodeValueWithoutLabels() { // Given NodeValue node = VirtualValues.nodeValue( 42L, Values.stringArray(), props( "foo", intValue( 42 ), "bar", list( intValue( 1337 ), stringValue( "baz" ) ) ) ); PrettyPrinter printer = new PrettyPrinter(); // When node.writeTo( printer ); // Then assertThat( printer.value(), equalTo( "(id=42 {bar: [1337, \"baz\"], foo: 42})" ) ); }
private void createNodeWithProperty( Transaction tx, int propId1 ) throws KernelException { long node = tx.dataWrite().nodeCreate(); tx.dataWrite().nodeSetProperty( node, propId1, Values.intValue( 42 ) ); }
@Test public void shouldSerializeRelationship() throws Throwable { RelationshipValue rel = relationshipValue( 12L, nodeValue( 1L, stringArray(), VirtualValues.EMPTY_MAP ), nodeValue( 2L, stringArray(), VirtualValues.EMPTY_MAP ), stringValue( "KNOWS" ), VirtualValues.map( new String[]{"name", "age"}, new AnyValue[]{stringValue( "Bob" ), intValue( 14 )} ) ); assertThat( serialized( rel ), equalTo( "B1 71 91 B5 52 0C 01 02 85 4B 4E 4F 57 53 A2 84" + lineSeparator() + "6E 61 6D 65 83 42 6F 62 83 61 67 65 0E" ) ); }
private PropertyRecord propertyRecordWithSingleIntProperty( long id, int propertyKeyId, long prev, long next ) { PropertyRecord record = new PropertyRecord( id ).initialize( true, prev, next ); PropertyBlock block = new PropertyBlock(); PropertyStore.encodeValue( block, propertyKeyId, Values.intValue( 10 ), null, null, false ); record.addPropertyBlock( block ); return record; } } );
@Test void remove() { final long ref = container.add( intValue( 42 ) ); container.remove( ref ); assertThrows( IllegalArgumentException.class, () -> container.get( ref ) ); }
@Test void getFailsOnInvalidRef() { final long ref = container.add( intValue( 42 ) ); container.get( ref ); assertThrows( IllegalArgumentException.class, () -> container.get( 128L ), "invalid chunk offset" ); assertThrows( IllegalArgumentException.class, () -> container.get( 1L << 32 ), "invalid chunk index" ); }