use of com.baidu.hugegraph.util.collection.IntIterator in project incubator-hugegraph by apache.
the class KoutRecords method ids.
@Override
public List<Id> ids(long limit) {
List<Id> ids = CollectionFactory.newList(CollectionType.EC);
IntIterator iterator = this.records().peek().keys();
while ((limit == NO_LIMIT || limit-- > 0L) && iterator.hasNext()) {
ids.add(this.id(iterator.next()));
}
return ids;
}
use of com.baidu.hugegraph.util.collection.IntIterator in project incubator-hugegraph by apache.
the class KneighborRecords method paths.
@Override
public PathSet paths(long limit) {
PathSet paths = new PathSet();
Stack<Record> records = this.records();
for (int i = 1; i < records.size(); i++) {
IntIterator iterator = records.get(i).keys();
while ((limit == NO_LIMIT || limit > 0L) && iterator.hasNext()) {
paths.add(this.linkPath(i, iterator.next()));
limit--;
}
}
return paths;
}
use of com.baidu.hugegraph.util.collection.IntIterator in project incubator-hugegraph by apache.
the class IntMapTest method testIntFixedMapBySegmentsValuesWithMultiSegs.
@Test
public void testIntFixedMapBySegmentsValuesWithMultiSegs() {
int segments = 400;
int segmentSize = Integer.MAX_VALUE / segments;
int step = 50;
IntMap map = fixedBySegments(Integer.MAX_VALUE, segments);
for (int k = 0; k < segments; k += step) {
map.put(segmentSize * k, k);
}
Assert.assertEquals(map.size(), IteratorUtils.count(map.values().asIterator()));
for (int i = 0; i < 10; i++) {
IntIterator iter = map.values();
for (int k = 0; k < segments; k += step) {
Assert.assertTrue(iter.hasNext());
Assert.assertEquals(k, iter.next());
}
Assert.assertFalse(iter.hasNext());
Assert.assertThrows(NoSuchElementException.class, () -> {
iter.next();
}, e -> {
Assert.assertNull(e.getMessage());
});
}
}
use of com.baidu.hugegraph.util.collection.IntIterator in project incubator-hugegraph by apache.
the class IntMapTest method testIntFixedMapBySegmentsKeysWithMultiSegs.
@Test
public void testIntFixedMapBySegmentsKeysWithMultiSegs() {
int segments = 400;
int segmentSize = Integer.MAX_VALUE / segments;
int step = 50;
IntMap map = fixedBySegments(Integer.MAX_VALUE, segments);
for (int k = 0; k < segments; k += step) {
map.put(segmentSize * k, k);
}
Assert.assertEquals(map.size(), IteratorUtils.count(map.keys().asIterator()));
for (int i = 0; i < 10; i++) {
IntIterator iter = map.keys();
for (int k = 0; k < segments; k += step) {
Assert.assertTrue(iter.hasNext());
Assert.assertEquals(segmentSize * k, iter.next());
}
Assert.assertFalse(iter.hasNext());
Assert.assertThrows(NoSuchElementException.class, () -> {
iter.next();
}, e -> {
Assert.assertNull(e.getMessage());
});
}
}
use of com.baidu.hugegraph.util.collection.IntIterator in project incubator-hugegraph by apache.
the class IntMapTest method testIntFixedMapBySegmentsKeys.
@Test
public void testIntFixedMapBySegmentsKeys() {
IntMap map = fixedBySegments(Integer.MAX_VALUE, 40);
map.put(Integer.MAX_VALUE - 1, 1);
Assert.assertEquals(1, IteratorUtils.count(map.keys().asIterator()));
for (int i = 0; i < 10000; i++) {
IntIterator iter = map.keys();
Assert.assertTrue(iter.hasNext());
Assert.assertEquals(Integer.MAX_VALUE - 1, iter.next());
Assert.assertFalse(iter.hasNext());
Assert.assertThrows(NoSuchElementException.class, () -> {
iter.next();
}, e -> {
Assert.assertNull(e.getMessage());
});
}
}
Aggregations