Skip to content

Commit

Permalink
Moved offheap collections to kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Koval committed Jul 31, 2018
1 parent c7c5616 commit 66f3078
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 27 deletions.
Expand Up @@ -34,10 +34,10 @@
import java.util.List;
import javax.annotation.Nonnull;

import org.neo4j.collection.offheap.Memory;
import org.neo4j.collection.offheap.MemoryAllocator;
import org.neo4j.graphdb.Resource;
import org.neo4j.io.ByteUnit;
import org.neo4j.kernel.impl.util.collection.Memory;
import org.neo4j.kernel.impl.util.collection.MemoryAllocator;
import org.neo4j.unsafe.impl.internal.dragons.UnsafeUtil;
import org.neo4j.util.VisibleForTesting;
import org.neo4j.values.storable.ArrayValue;
Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.collection.offheap;
package org.neo4j.kernel.impl.util.collection;

import org.apache.commons.lang3.mutable.MutableInt;
import org.eclipse.collections.api.block.function.primitive.LongToObjectFunction;
Expand Down
Expand Up @@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.neo4j.collection.offheap;
package org.neo4j.kernel.impl.util.collection;

import org.apache.commons.lang3.mutable.MutableInt;
import org.eclipse.collections.api.LazyLongIterable;
Expand Down
Expand Up @@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.neo4j.collection.offheap;
package org.neo4j.kernel.impl.util.collection;

import java.nio.ByteBuffer;

Expand Down
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.collection.offheap;
package org.neo4j.kernel.impl.util.collection;

@FunctionalInterface
public interface MemoryAllocator
Expand Down
Expand Up @@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.neo4j.collection.offheap;
package org.neo4j.kernel.impl.util.collection;

import org.eclipse.collections.api.LongIterable;
import org.eclipse.collections.api.block.procedure.primitive.LongProcedure;
Expand Down
Expand Up @@ -25,9 +25,6 @@
import java.util.ArrayList;
import java.util.Collection;

import org.neo4j.collection.offheap.LinearProbeLongLongHashMap;
import org.neo4j.collection.offheap.MemoryAllocator;
import org.neo4j.collection.offheap.MutableLinearProbeLongHashSet;
import org.neo4j.graphdb.Resource;
import org.neo4j.kernel.impl.api.state.AppendOnlyValuesContainer;
import org.neo4j.kernel.impl.api.state.ValuesContainer;
Expand Down
Expand Up @@ -22,8 +22,6 @@

import java.nio.ByteBuffer;

import org.neo4j.collection.offheap.Memory;
import org.neo4j.collection.offheap.MemoryAllocator;
import org.neo4j.kernel.impl.util.collection.OffHeapBlockAllocator.MemoryBlock;
import org.neo4j.memory.MemoryAllocationTracker;
import org.neo4j.unsafe.impl.internal.dragons.UnsafeUtil;
Expand Down
Expand Up @@ -23,8 +23,8 @@
import java.nio.ByteBuffer;
import java.util.Arrays;

import org.neo4j.collection.offheap.Memory;
import org.neo4j.collection.offheap.MemoryAllocator;
import org.neo4j.kernel.impl.util.collection.Memory;
import org.neo4j.kernel.impl.util.collection.MemoryAllocator;
import org.neo4j.memory.LocalMemoryTracker;
import org.neo4j.memory.MemoryAllocationTracker;

Expand Down
Expand Up @@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.neo4j.collection.offheap;
package org.neo4j.kernel.impl.util.collection;

import org.eclipse.collections.api.block.function.primitive.LongFunction;
import org.eclipse.collections.api.block.function.primitive.LongFunction0;
Expand All @@ -43,6 +43,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.function.Executable;
import org.mockito.Mockito;

import java.util.Collection;
import java.util.ConcurrentModificationException;
Expand All @@ -67,8 +68,8 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.neo4j.collection.offheap.LinearProbeLongLongHashMap.DEFAULT_CAPACITY;
import static org.neo4j.collection.offheap.LinearProbeLongLongHashMap.REMOVALS_FACTOR;
import static org.neo4j.kernel.impl.util.collection.LinearProbeLongLongHashMap.DEFAULT_CAPACITY;
import static org.neo4j.kernel.impl.util.collection.LinearProbeLongLongHashMap.REMOVALS_FACTOR;

class LinearProbeLongLongHashMapTest
{
Expand Down Expand Up @@ -490,7 +491,7 @@ Collection<DynamicTest> failFastIterator()
@Test
void grow()
{
map = spy( map );
map = Mockito.spy( map );

for ( int i = 0; i < DEFAULT_CAPACITY; i++ )
{
Expand All @@ -502,7 +503,7 @@ void grow()
@Test
void rehashWhenTooManyRemovals()
{
map = spy( map );
map = Mockito.spy( map );

final int numOfElements = DEFAULT_CAPACITY / 2;
final int removalsToTriggerRehashing = (int) (DEFAULT_CAPACITY * REMOVALS_FACTOR);
Expand Down
Expand Up @@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.neo4j.collection.offheap;
package org.neo4j.kernel.impl.util.collection;

import org.eclipse.collections.api.block.procedure.primitive.LongProcedure;
import org.eclipse.collections.api.iterator.LongIterator;
Expand All @@ -34,6 +34,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.function.Executable;
import org.mockito.Mockito;

import java.util.Collection;
import java.util.ConcurrentModificationException;
Expand All @@ -57,12 +58,11 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.neo4j.collection.offheap.MutableLinearProbeLongHashSet.DEFAULT_CAPACITY;
import static org.neo4j.collection.offheap.MutableLinearProbeLongHashSet.REMOVALS_RATIO;
import static org.neo4j.kernel.impl.util.collection.MutableLinearProbeLongHashSet.DEFAULT_CAPACITY;
import static org.neo4j.kernel.impl.util.collection.MutableLinearProbeLongHashSet.REMOVALS_RATIO;

class MutableLinearProbeLongHashSetTest
{
Expand All @@ -79,7 +79,7 @@ void tearDown()
@Test
void addRemoveContains()
{
set = spy( set );
set = Mockito.spy( set );

assertFalse( set.contains( 0 ) );
assertTrue( set.add( 0 ) );
Expand Down Expand Up @@ -155,7 +155,7 @@ void clear()
@Test
void grow()
{
set = spy( set );
set = Mockito.spy( set );

for ( int i = 0; i < DEFAULT_CAPACITY; i++ )
{
Expand All @@ -167,7 +167,7 @@ void grow()
@Test
void rehashWhenTooManyRemovals()
{
set = spy( set );
set = Mockito.spy( set );

final int numOfElements = DEFAULT_CAPACITY / 2;
final int removalsToTriggerRehashing = DEFAULT_CAPACITY / REMOVALS_RATIO;
Expand Down
Expand Up @@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.neo4j.collection.offheap;
package org.neo4j.kernel.impl.util.collection;

import java.nio.ByteBuffer;
import java.util.Arrays;
Expand Down

0 comments on commit 66f3078

Please sign in to comment.