use of com.baidu.hugegraph.util.collection.IntIterator in project incubator-hugegraph by apache.
the class KneighborRecords method ids.
@Override
public List<Id> ids(long limit) {
List<Id> ids = CollectionFactory.newList(CollectionType.EC);
Stack<Record> records = this.records();
// Not include record(i=0) to ignore source vertex
for (int i = 1; i < records.size(); i++) {
IntIterator iterator = records.get(i).keys();
while ((limit == NO_LIMIT || limit > 0L) && iterator.hasNext()) {
ids.add(this.id(iterator.next()));
limit--;
}
}
return ids;
}
use of com.baidu.hugegraph.util.collection.IntIterator in project incubator-hugegraph by apache.
the class KoutRecords method paths.
@Override
public PathSet paths(long limit) {
PathSet paths = new PathSet();
Stack<Record> records = this.records();
IntIterator iterator = records.peek().keys();
while ((limit == NO_LIMIT || limit-- > 0L) && iterator.hasNext()) {
paths.add(this.linkPath(records.size() - 1, iterator.next()));
}
return paths;
}
use of com.baidu.hugegraph.util.collection.IntIterator in project incubator-hugegraph by apache.
the class IntMapTest method testIntFixedMapBySegmentsValues.
@Test
public void testIntFixedMapBySegmentsValues() {
IntMap map = fixedBySegments(Integer.MAX_VALUE, 40);
map.put(Integer.MAX_VALUE - 1, 1);
Assert.assertEquals(1, IteratorUtils.count(map.values().asIterator()));
for (int i = 0; i < 10; i++) {
IntIterator iter = map.values();
Assert.assertTrue(iter.hasNext());
Assert.assertEquals(1, 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 DoubleWayMultiPathsRecords method parentsContain.
public boolean parentsContain(int id) {
Record parentRecord = this.parentRecord();
if (parentRecord == null) {
return false;
}
IntIterator parents = parentRecord.get(this.currentKey);
while (parents.hasNext()) {
int parent = parents.next();
if (parent == id) {
// Find backtrace path, stop
return true;
}
}
return false;
}
use of com.baidu.hugegraph.util.collection.IntIterator in project incubator-hugegraph by apache.
the class DoubleWayMultiPathsRecords method linkPathLayer.
private PathSet linkPathLayer(Stack<Record> all, int id, int layerIndex) {
PathSet results = new PathSet();
if (layerIndex == 0) {
Id sid = this.id(id);
results.add(new Path(Lists.newArrayList(sid)));
return results;
}
Id current = this.id(id);
Record layer = all.elementAt(layerIndex);
IntIterator iterator = layer.get(id);
while (iterator.hasNext()) {
int parent = iterator.next();
PathSet paths = this.linkPathLayer(all, parent, layerIndex - 1);
paths.append(current);
results.addAll(paths);
}
return results;
}
Aggregations