|
| 1 | +/* |
| 2 | + * Copyright (c) 2017-2020 "Neo4j," |
| 3 | + * Neo4j Sweden AB [http://neo4j.com] |
| 4 | + * |
| 5 | + * This file is part of Neo4j. |
| 6 | + * |
| 7 | + * Neo4j is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU General Public License as published by |
| 9 | + * the Free Software Foundation, either version 3 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License |
| 18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | + */ |
| 20 | +package org.neo4j.graphalgo.core.loading; |
| 21 | + |
| 22 | +import org.junit.jupiter.api.Test; |
| 23 | +import org.neo4j.graphalgo.core.utils.paged.AllocationTracker; |
| 24 | +import org.neo4j.graphalgo.core.utils.paged.HugeLongArray; |
| 25 | + |
| 26 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 27 | + |
| 28 | +class IdMapBuilderTest { |
| 29 | + |
| 30 | + @Test |
| 31 | + void buildSparseNodeMappingWithPageSizeEntries() { |
| 32 | + long nodeId = 4096; // equals the PAGE_SIZE in a HugeSparseLongArray |
| 33 | + |
| 34 | + HugeLongArray hugeLongArray = HugeLongArray.newArray(1, AllocationTracker.EMPTY); |
| 35 | + hugeLongArray.set(0, nodeId); |
| 36 | + |
| 37 | + SparseNodeMapping hugeSparseLongArray = IdMapBuilder.buildSparseNodeMapping( |
| 38 | + hugeLongArray, |
| 39 | + nodeId, |
| 40 | + 1, |
| 41 | + AllocationTracker.EMPTY |
| 42 | + ); |
| 43 | + |
| 44 | + assertTrue(hugeSparseLongArray.contains(nodeId)); |
| 45 | + } |
| 46 | +} |
0 commit comments