use of tl.lin.data.array.ArrayListOfIntsWritable in project Cloud9 by lintool.
the class PageRankNodeTest method testToString.
@Test
public void testToString() throws Exception {
PageRankNode node = new PageRankNode();
node.setType(Type.Complete);
node.setNodeId(1);
node.setPageRank(0.1f);
assertEquals("{1 0.1000 []}", node.toString());
node.setAdjacencyList(new ArrayListOfIntsWritable(new int[] { 1, 2, 3, 4, 5, 6 }));
assertEquals("{1 0.1000 [1, 2, 3, 4, 5, 6]}", node.toString());
node.setAdjacencyList(new ArrayListOfIntsWritable(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }));
assertEquals("{1 0.1000 [1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ... (2 more) ]}", node.toString());
}
use of tl.lin.data.array.ArrayListOfIntsWritable in project Cloud9 by lintool.
the class PageRankNodeTest method testSerialize.
@Test
public void testSerialize() throws IOException {
PageRankNode node1 = new PageRankNode();
node1.setType(Type.Complete);
node1.setNodeId(1);
node1.setPageRank(0.1f);
node1.setAdjacencyList(new ArrayListOfIntsWritable(new int[] { 1, 2, 3, 4, 5, 6 }));
byte[] bytes = node1.serialize();
PageRankNode node2 = PageRankNode.create(bytes);
assertEquals(0.1f, node2.getPageRank(), 10e-6);
assertEquals(Type.Complete, node2.getType());
ArrayListOfIntsWritable adj = node2.getAdjacenyList();
assertEquals(6, adj.size());
assertEquals(1, adj.get(0));
assertEquals(2, adj.get(1));
assertEquals(3, adj.get(2));
assertEquals(4, adj.get(3));
assertEquals(5, adj.get(4));
assertEquals(6, adj.get(5));
}
Aggregations