public class LongDoubleHashMapEdges extends Object implements StrictRandomAccessOutEdges<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>, ReuseObjectsOutEdges<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>, MutableOutEdges<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>, Trimmable
OutEdges
implementation with long ids and double edge values,
backed by a Long2DoubleOpenHashMap
.
Parallel edges are not allowed.
Note: this implementation is optimized for fast random access and mutations,
and uses less space than a generic HashMapEdges
(but more than
LongDoubleArrayEdges
.Constructor and Description |
---|
LongDoubleHashMapEdges() |
Modifier and Type | Method and Description |
---|---|
void |
add(Edge<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable> edge)
Add an edge.
|
org.apache.hadoop.io.DoubleWritable |
getEdgeValue(org.apache.hadoop.io.LongWritable targetVertexId)
Return the edge value for the given target vertex id (or null if there
is no edge pointing to it).
|
void |
initialize()
Initialize the data structure with the default initial capacity.
|
void |
initialize(int capacity)
Initialize the data structure with the specified initial capacity.
|
void |
initialize(Iterable<Edge<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>> edges)
Initialize the data structure and set the edges from an iterable.
|
Iterator<Edge<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>> |
iterator() |
Iterator<MutableEdge<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>> |
mutableIterator()
Returns an iterator over edges that can be modified in-place,
either by changing the current edge value or by removing the current edge.
|
void |
readFields(DataInput in) |
void |
remove(org.apache.hadoop.io.LongWritable targetVertexId)
Remove all edges to the given target vertex.
|
void |
setEdgeValue(org.apache.hadoop.io.LongWritable targetVertexId,
org.apache.hadoop.io.DoubleWritable edgeValue)
Set the edge value for the given target vertex id (if an edge to that
vertex exists).
|
int |
size()
Return the number of edges.
|
void |
trim()
Compacts all recent updates to this object.
|
void |
write(DataOutput out) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public void initialize(Iterable<Edge<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>> edges)
OutEdges
initialize
in interface OutEdges<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>
edges
- Iterable of edgespublic void initialize(int capacity)
OutEdges
initialize
in interface OutEdges<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>
capacity
- Initial capacitypublic void initialize()
OutEdges
initialize
in interface OutEdges<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>
public void add(Edge<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable> edge)
OutEdges
public void remove(org.apache.hadoop.io.LongWritable targetVertexId)
OutEdges
public org.apache.hadoop.io.DoubleWritable getEdgeValue(org.apache.hadoop.io.LongWritable targetVertexId)
StrictRandomAccessOutEdges
getEdgeValue
in interface StrictRandomAccessOutEdges<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>
targetVertexId
- Target vertex idpublic void setEdgeValue(org.apache.hadoop.io.LongWritable targetVertexId, org.apache.hadoop.io.DoubleWritable edgeValue)
StrictRandomAccessOutEdges
setEdgeValue
in interface StrictRandomAccessOutEdges<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>
targetVertexId
- Target vertex idedgeValue
- Edge valuepublic int size()
OutEdges
public Iterator<Edge<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>> iterator()
public void trim()
Trimmable
public Iterator<MutableEdge<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>> mutableIterator()
MutableOutEdges
mutableIterator
in interface MutableOutEdges<org.apache.hadoop.io.LongWritable,org.apache.hadoop.io.DoubleWritable>
public void write(DataOutput out) throws IOException
write
in interface org.apache.hadoop.io.Writable
IOException
public void readFields(DataInput in) throws IOException
readFields
in interface org.apache.hadoop.io.Writable
IOException
Copyright © 2011-2020 The Apache Software Foundation. All Rights Reserved.