Search in sources :

Example 1 with ArrayListOfIntsWritable

use of tl.lin.data.array.ArrayListOfIntsWritable in project Cloud9 by lintool.

the class BfsNode method readFields.

/**
 * Deserializes this object.
 *
 * @param in source for raw byte representation
 */
@Override
public void readFields(DataInput in) throws IOException {
    type = mapping[in.readByte()];
    nodeid = in.readInt();
    if (type.equals(Type.Distance)) {
        distance = in.readInt();
        return;
    }
    if (type.equals(Type.Complete)) {
        distance = in.readInt();
    }
    adjacenyList = new ArrayListOfIntsWritable();
    adjacenyList.readFields(in);
}
Also used : ArrayListOfIntsWritable(tl.lin.data.array.ArrayListOfIntsWritable)

Example 2 with ArrayListOfIntsWritable

use of tl.lin.data.array.ArrayListOfIntsWritable in project Cloud9 by lintool.

the class HITSNode method readFields.

/**
 * Deserializes this object.
 *
 * @param in
 *            source for raw byte representation
 */
public void readFields(DataInput in) throws IOException {
    mType = in.readByte();
    mNodeId = in.readInt();
    mInlinks = new ArrayListOfIntsWritable();
    mOutlinks = new ArrayListOfIntsWritable();
    if (mType == TYPE_HUB_MASS || mType == TYPE_NODE_MASS) {
        mHRank = in.readFloat();
        return;
    }
    if (mType == TYPE_AUTH_MASS || mType == TYPE_NODE_MASS) {
        mARank = in.readFloat();
        return;
    }
    if (mType == TYPE_HUB_COMPLETE || mType == TYPE_NODE_COMPLETE) {
        mHRank = in.readFloat();
    }
    if (mType == TYPE_AUTH_COMPLETE || mType == TYPE_NODE_COMPLETE) {
        mARank = in.readFloat();
    }
    // if (mType == TYPE_HUB_STRUCTURE || mType == TYPE_NODE_STRUCTURE || mType == TYPE_NODE_COMPLETE)
    // {
    // mOutlinks.readFields(in);
    mInlinks.readFields(in);
    // }
    // is this right -- inlinks go with hub and outlinks go with auth??? no -- other way around
    // if (mType == TYPE_AUTH_STRUCTURE || mType == TYPE_NODE_STRUCTURE || mType == TYPE_NODE_COMPLETE)
    // {
    mOutlinks.readFields(in);
// mInlinks.readFields(in);
// }
}
Also used : ArrayListOfIntsWritable(tl.lin.data.array.ArrayListOfIntsWritable)

Example 3 with ArrayListOfIntsWritable

use of tl.lin.data.array.ArrayListOfIntsWritable in project Cloud9 by lintool.

the class PageRankNode method readFields.

/**
 * Deserializes this object.
 *
 * @param in source for raw byte representation
 */
@Override
public void readFields(DataInput in) throws IOException {
    int b = in.readByte();
    type = mapping[b];
    nodeid = in.readInt();
    if (type.equals(Type.Mass)) {
        pagerank = in.readFloat();
        return;
    }
    if (type.equals(Type.Complete)) {
        pagerank = in.readFloat();
    }
    adjacenyList = new ArrayListOfIntsWritable();
    adjacenyList.readFields(in);
}
Also used : ArrayListOfIntsWritable(tl.lin.data.array.ArrayListOfIntsWritable)

Example 4 with ArrayListOfIntsWritable

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));
}
Also used : ArrayListOfIntsWritable(tl.lin.data.array.ArrayListOfIntsWritable) Test(org.junit.Test)

Example 5 with ArrayListOfIntsWritable

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());
}
Also used : ArrayListOfIntsWritable(tl.lin.data.array.ArrayListOfIntsWritable) Test(org.junit.Test)

Aggregations

ArrayListOfIntsWritable (tl.lin.data.array.ArrayListOfIntsWritable)7 Test (org.junit.Test)4