List of usage examples for org.apache.hadoop.io IntWritable get
public int get()
From source file:org.apache.giraph.combiner.MinimumIntCombiner.java
License:Apache License
@Override public void combine(IntWritable vertexIndex, IntWritable originalMessage, IntWritable messageToCombine) { if (originalMessage.get() > messageToCombine.get()) { originalMessage.set(messageToCombine.get()); }//from w ww . ja v a 2s . c o m }
From source file:org.apache.giraph.combiner.MinimumIntMessageCombiner.java
License:Apache License
@Override public void combine(WritableComparable vertexIndex, IntWritable originalMessage, IntWritable messageToCombine) { if (originalMessage.get() > messageToCombine.get()) { originalMessage.set(messageToCombine.get()); }//from w w w.jav a 2s . co m }
From source file:org.apache.giraph.combiner.SimpleSumCombiner.java
License:Apache License
@Override public void combine(LongWritable vertexIndex, IntWritable originalMessage, IntWritable messageToCombine) { originalMessage.set(originalMessage.get() + messageToCombine.get()); }
From source file:org.apache.giraph.combiner.SimpleSumMessageCombiner.java
License:Apache License
@Override public void combine(WritableComparable vertexIndex, IntWritable originalMessage, IntWritable messageToCombine) { originalMessage.set(originalMessage.get() + messageToCombine.get()); }
From source file:org.apache.giraph.comm.messages.primitives.IntByteArrayMessageStore.java
License:Apache License
@Override public boolean hasMessagesForVertex(IntWritable vertexId) { return getPartitionMap(vertexId).containsKey(vertexId.get()); }
From source file:org.apache.giraph.comm.messages.primitives.IntByteArrayMessageStore.java
License:Apache License
@Override public Iterable<M> getVertexMessages(IntWritable vertexId) throws IOException { DataInputOutput dataInputOutput = getPartitionMap(vertexId).get(vertexId.get()); if (dataInputOutput == null) { return EmptyIterable.get(); } else {/*from ww w . j a v a 2s . c o m*/ return new MessagesIterable<M>(dataInputOutput, messageValueFactory); } }
From source file:org.apache.giraph.comm.messages.primitives.IntByteArrayMessageStore.java
License:Apache License
@Override public void clearVertexMessages(IntWritable vertexId) throws IOException { getPartitionMap(vertexId).remove(vertexId.get()); }
From source file:org.apache.giraph.comm.messages.primitives.IntFloatMessageStore.java
License:Apache License
@Override public Iterable<FloatWritable> getVertexMessages(IntWritable vertexId) throws IOException { Int2FloatOpenHashMap partitionMap = getPartitionMap(vertexId); if (!partitionMap.containsKey(vertexId.get())) { return EmptyIterable.get(); } else {// www .j a va 2 s . co m return Collections.singleton(new FloatWritable(partitionMap.get(vertexId.get()))); } }
From source file:org.apache.giraph.comm.messages.TestIntFloatPrimitiveMessageStores.java
License:Apache License
@Before public void prepare() throws IOException { service = Mockito.mock(CentralizedServiceWorker.class); Mockito.when(service.getPartitionId(Mockito.any(IntWritable.class))).thenAnswer(new Answer<Integer>() { @Override/*from w w w. ja v a 2 s. co m*/ public Integer answer(InvocationOnMock invocation) { IntWritable vertexId = (IntWritable) invocation.getArguments()[0]; return vertexId.get() % NUM_PARTITIONS; } }); PartitionStore partitionStore = Mockito.mock(PartitionStore.class); Mockito.when(service.getPartitionStore()).thenReturn(partitionStore); Mockito.when(partitionStore.getPartitionIds()).thenReturn(Lists.newArrayList(0, 1)); Partition partition = Mockito.mock(Partition.class); Mockito.when(partition.getVertexCount()).thenReturn(Long.valueOf(1)); Mockito.when(partitionStore.getOrCreatePartition(0)).thenReturn(partition); Mockito.when(partitionStore.getOrCreatePartition(1)).thenReturn(partition); }
From source file:org.apache.giraph.comm.RequestFailureTest.java
License:Apache License
private void checkResult(int numRequests) throws IOException { // Check the output Iterable<IntWritable> vertices = serverData.getIncomingMessageStore().getPartitionDestinationVertices(0); int keySum = 0; int messageSum = 0; for (IntWritable vertexId : vertices) { keySum += vertexId.get(); Iterable<IntWritable> messages = serverData.<IntWritable>getIncomingMessageStore() .getVertexMessages(vertexId); synchronized (messages) { for (IntWritable message : messages) { messageSum += message.get(); }// ww w. j a v a2 s . co m } } assertEquals(21, keySum); assertEquals(35 * numRequests, messageSum); }