Package edu.cmu.graphchi.datablocks

Examples of edu.cmu.graphchi.datablocks.FloatConverter


     * @return
     * @throws IOException
     */
    public static TreeSet<IdFloat> topListFloat(String baseFilename, int numVertices, final int topN) throws IOException{
        final TreeSet<IdFloat> topList = new TreeSet<IdFloat>(new IdFloat.Comparator());
        VertexAggregator.foreach(numVertices, baseFilename, new FloatConverter(), new ForeachCallback<Float>()  {
            IdFloat least;
            public void callback(int vertexId, Float vertexValue) {
                if (topList.size() < topN) {
                    topList.add(new IdFloat(vertexId, vertexValue));
                    least = topList.last();
View Full Code Here


        logger.info("Loading ranks...");
        long st = System.currentTimeMillis();
        int numVertices = ChiFilenames.numVertices(baseFilename, numShards);
        ranks = new float[numVertices];
        Iterator<VertexIdValue<Float>> iter = VertexAggregator.vertexIterator(numVertices, baseFilename,
                new FloatConverter(), VertexIdTranslate.identity());
        while(iter.hasNext()) {
            VertexIdValue<Float> idVal = iter.next();
            ranks[idVal.getVertexId()] = idVal.getValue();
        }
        logger.info("Loaded ranks to memory in " + (System.currentTimeMillis() - st) + " ms");
View Full Code Here

    public void testVertexValue() {
        DataBlockManager blockMgr = new DataBlockManager();

        int blockId = blockMgr.allocateBlock(1024* 1024);

        FloatConverter floatConv = new FloatConverter();

        ChiVertex.edgeValueConverter = floatConv;
        ChiVertex.vertexValueConverter = floatConv;
        ChiVertex.blockManager = blockMgr;
        ChiVertex<Float, Float> vertex = new ChiVertex<Float, Float>(1, new VertexDegree(0, 0));
View Full Code Here

    public void testInEdges() {
        DataBlockManager blockMgr = new DataBlockManager();

        int blockId = blockMgr.allocateBlock(1024 * 1024);

        FloatConverter floatConv = new FloatConverter();
        int nInedges = 1000;

        ChiVertex.edgeValueConverter = floatConv;
        ChiVertex.vertexValueConverter = floatConv;
        ChiVertex.blockManager = blockMgr;
View Full Code Here

    public void testOutEdges() {
        DataBlockManager blockMgr = new DataBlockManager();

        int blockId = blockMgr.allocateBlock(1024 * 1024);

        FloatConverter floatConv = new FloatConverter();
        int nOutedges = 5559;

        ChiVertex.edgeValueConverter = floatConv;
        ChiVertex.vertexValueConverter = floatConv;
        ChiVertex.blockManager = blockMgr;
View Full Code Here

    public void testSortWithValues() {
        long[] ids = new long[] {7,4,5,8,2,9};
        float[] valuef = new float[] {7.0f, 4.0f, 5.0f, 8.0f, 2.0f, 9.0f};
        byte[] valuedat = new byte[4 * valuef.length];

        FloatConverter floatConv = new FloatConverter();
        for(int i=0; i < valuef.length; i++) {
            byte[] tmp = new byte[4];
            floatConv.setValue(tmp, valuef[i]);
            System.arraycopy(tmp, 0, valuedat, i * 4, 4);
        }

        FastSharder.sortWithValues(ids, valuedat, 4);

        for(int i=0; i < valuef.length; i++) {
             byte[] tmp = new byte[4];
             System.arraycopy(valuedat, i * 4, tmp, 0, 4);
             float f = floatConv.getValue(tmp);
             assertEquals(ids[i] * 1.0f, f);
             assertTrue(i == 0 || ids[i] > ids[i-1]);
        }
    }
View Full Code Here

TOP

Related Classes of edu.cmu.graphchi.datablocks.FloatConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.