@Override protected void internalPut( long keyAddress, long key, VALUE value ) { assert (int) key == key : "Illegal key " + key + ", it's bigger than int"; // We can "safely" cast to int here, assuming that this call trickles in via a PrimitiveIntCollection UnsafeUtil.putInt( keyAddress, (int) key ); }
private void putInt( long p, int value ) { if ( UnsafeUtil.allowUnalignedMemoryAccess ) { UnsafeUtil.putInt( p, value ); } else { UnsafeUtil.putIntByteWiseLittleEndian( p, value ); } }
putInt( obj, anIntOffset, 1 ); assertThat( obj.anInt, is( 1 ) ); assertThat( getInt( obj, anIntOffset ), is( 1 ) );
protected static void alignmentSafePutLongAsTwoInts( long address, long value ) { if ( UnsafeUtil.allowUnalignedMemoryAccess ) { UnsafeUtil.putLong( address, value ); } else { // See javadoc in constructor as to why we do this UnsafeUtil.putInt( address, (int) value ); UnsafeUtil.putInt( address + Integer.BYTES, (int) (value >>> Integer.SIZE) ); } }
assertThat( getCharVolatile( address ), is( (char) 0 ) ); putInt( address, 1 ); assertThat( getInt( address ), is( 1 ) ); setMemory( address, sizeInBytes, (byte) 0 );
private void putInt( long p, int value ) { if ( UnsafeUtil.allowUnalignedMemoryAccess ) { UnsafeUtil.putInt( p, value ); } else { UnsafeUtil.putIntByteWiseLittleEndian( p, value ); } }
private void putIntAt( long p, int value ) { if ( UnsafeUtil.allowUnalignedMemoryAccess ) { UnsafeUtil.putInt( p, UnsafeUtil.storeByteOrderIsNative ? value : Integer.reverseBytes( value ) ); } else { putIntBigEndian( value, p ); } }
@Override public void set( long index, int value ) { UnsafeUtil.putInt( addressOf( index ), value ); }
protected void putInt( long address, int offset, int value ) { UnsafeUtil.putInt( address + offset, value ); }
@Override public void removeHopBit( int index, int hd ) { long adr = hopBitsAddress( index ); int hopBits = UnsafeUtil.getInt( adr ); hopBits |= 1 << hd; UnsafeUtil.putInt( adr, hopBits ); }
@Override public void putHopBit( int index, int hd ) { long adr = hopBitsAddress( index ); int hopBits = UnsafeUtil.getInt( adr ); hopBits &= ~(1 << hd); UnsafeUtil.putInt( adr, hopBits ); }
@Override public void moveHopBit( int index, int hd, int delta ) { long adr = hopBitsAddress( index ); int hopBits = UnsafeUtil.getInt( adr ); hopBits ^= (1 << hd) | (1 << (hd + delta)); UnsafeUtil.putInt( adr, hopBits ); }
@Override public void clear() { if ( isByteUniform( defaultValue ) ) { UnsafeUtil.setMemory( address, length << shift, (byte)defaultValue ); } else { for ( long i = 0, adr = address; i < length; i++, adr += itemSize ) { UnsafeUtil.putInt( adr, defaultValue ); } } } }
protected long createPage( int cachePageSize ) { long address = mman.allocateAligned( cachePageSize + Integer.BYTES, 1 ); UnsafeUtil.putInt( address, cachePageSize ); return address + Integer.BYTES; }
scale = arrayIndexScale( ints.getClass() ); base = arrayBaseOffset( ints.getClass() ); putInt( ints, arrayOffset( 1, base, scale ), -1 ); assertThat( ints[0], is( 0 ) ); assertThat( ints[1], is( -1 ) );
@Override protected void internalPut( long keyAddress, long key, VALUE value ) { assert (int)key == key : "Illegal key " + key + ", it's bigger than int"; // We can "safely" cast to int here, assuming that this call trickles in via a PrimitiveIntCollection UnsafeUtil.putInt( keyAddress, (int) key ); }
@Override public void set( long index, int value ) { UnsafeUtil.putInt( addressOf( index ), value ); }
private void putIntAt( long p, int value ) { if ( UnsafeUtil.allowUnalignedMemoryAccess ) { UnsafeUtil.putInt( p, UnsafeUtil.storeByteOrderIsNative ? value : Integer.reverseBytes( value ) ); } else { putIntBigEndian( value, p ); } }
@Override public void removeHopBit( int index, int hd ) { long adr = hopBitsAddress( index ); int hopBits = UnsafeUtil.getInt( adr ); hopBits |= 1 << hd; UnsafeUtil.putInt( adr, hopBits ); }
@Override public void putHopBit( int index, int hd ) { long adr = hopBitsAddress( index ); int hopBits = UnsafeUtil.getInt( adr ); hopBits &= ~(1 << hd); UnsafeUtil.putInt( adr, hopBits ); }