Package stallone.doubles.fastutils

Examples of stallone.doubles.fastutils.LongArrayList


        };

        // reset inputfile pointer to start position
        this.randomAccessFile.seek(0);

        LongArrayList tempFramePositions = new LongArrayList(50000); // tmp vector to store the starting position of the
        // frames randomAccessFile input file (length of
        // vector can be increased, the length of a array
        // not !)
        int framesDetected = 0;
        long pos = 0;

        int magicRead; // frameHeader
        int noOfAtomsRead; // frameHeader

        int noOfAtomsRead2; // coordinates header
        int sizeOfCoordinates; // coordinates header

        /*
         * double realExpectedTime = 0.0d; double expectedTime = 0.0d; double
         * eps = 0.1d;
         */

        do
        {
            pos = randomAccessFile.getFilePointer();
            tempFramePositions.add(pos);

            // System.out.println("Frame " + framesDetected + " at " + pos );
            framesDetected++;

            magicRead = randomAccessFile.readInt(); // 4

            if (magicRead == this.magicNrFileVersion)
            {
                noOfAtomsRead = randomAccessFile.readInt(); // 4

                // frameNoRead = randomAccessFile.readInt(); // 4
                // simulationTime = randomAccessFile.readFloat();// 4 is simulation time
                // 36 is 3x3 cell axis a 4bytes each
                randomAccessFile.skipBytes(4 + 4 + 36);
                // 52 randomAccessFile total

                /*
                 * //200 - 0.4 System.out.println( "off: " +
                 * randomAccessFile.getFilePointer() + " frame# " + frameNoRead
                 * + " sim t: " + simulationTime + " expected t after reset: " +
                 * expectedTime + " real t: " + realExpectedTime); if (
                 * Math.abs( (double)simulationTime - expectedTime ) > eps ) {
                 * System.out.println( "Missing: off: " +
                 * randomAccessFile.getFilePointer() + " frame# " + frameNoRead
                 * + " sim t: " + simulationTime + " expected t after reset: " +
                 * expectedTime + " real t: " + realExpectedTime); expectedTime
                 * = simulationTime; } expectedTime += 0.2d; realExpectedTime +=
                 * 0.2d;
                 *
                 */


                // now entering coordinates header
                noOfAtomsRead2 = randomAccessFile.readInt();

                if (noOfAtomsRead == noOfAtomsRead2)
                {

                    if (noOfAtomsRead > 9)
                    { // compressed format (case b)

                        // 4 is precision
                        // 24 = (4 * 2 * 3 ) is min and max of x, y and z
                        // 4 is number of bits used for compression
                        randomAccessFile.skipBytes(4 + 24 + 4);

                        sizeOfCoordinates = randomAccessFile.readInt();

                        int mod4 = sizeOfCoordinates % 4;

                        if (mod4 > 0)
                        {
                            sizeOfCoordinates += (4 - mod4);
                        }

                        randomAccessFile.skipBytes(sizeOfCoordinates); // skip coordinates
                    }
                    else
                    { // uncompressed format (case a)

                        // x, y and z per atom a 4 bytes each
                        randomAccessFile.skipBytes(noOfAtomsRead * 3 * 4);
                    }
                }
                else
                {
                    throw new RuntimeException("Problem with atom sizes");
                } // end if-else
            }
            else
            {
                throw new RuntimeException("No magic bytes found. Error in trajectory.");
            } // end if-else
        }
        while (randomAccessFile.getFilePointer() < randomAccessFile.length());

        this.numOfFrames = framesDetected;

        // copy starting postion of frames from vector into an array and check their size
        int numberOfFrames = tempFramePositions.size();
        this.framePos = new long[numberOfFrames];
        this.frameBroken = new BitSet(numberOfFrames);

        long tmpPosition_old = 0; // tmp variable to calculate the size of a frame

        for (int i = 0; i < numberOfFrames; i++)
        {
            long tmpPosition = tempFramePositions.getLong(i);

            if (((tmpPosition - tmpPosition_old) % 4) != 0)
            { // check if the frame size is a multiple of 4 bytes
                this.frameBroken.set(i); // mark frame as broken
                System.err.println("WARNING: Frame " + i
View Full Code Here


        if (scanned)
            return;
       
        final int INITIAL_SIZE = 1000000;

        final LongArrayList lineOffsets = new LongArrayList(INITIAL_SIZE);

            long currentPos = 0;
            int currentLineNumber = 0;
            long oldPos;
            String textline;

            while ((textline = randomAccessFile.readLine()) != null)
            {
                // save old position
                oldPos = currentPos;

                // if commentPattern active, then read away comment lines
                if (usedCommentPattern != null)
                {
//                    while (usedCommentPattern.matcher(textline).matches()) {
//                        textline = randomAccessFile.readLine(); // skip line
//                    }
                    if (usedCommentPattern.matcher(textline).matches())
                    {
                        continue;
                    }
                }

                scanLine(textline, currentLineNumber);

                currentLineNumber++;
                currentPos = randomAccessFile.getFilePointer();
                lineOffsets.add(oldPos);
               
                // garbage collection is one solution
                // if ( (currentLineNumber % 1000000) == 0) {
                //    System.out.println("Scanned up to line: " + currentLineNumber);
                //    System.gc();
                // }
            }
            scanEnd(currentLineNumber);

            lineOffsets.trim();

        // determine line offsets
        lineStartOffsets = lineOffsets.toLongArray();
        relevantLines = lineStartOffsets.length;
       
        scanned = true;
    }
View Full Code Here

TOP

Related Classes of stallone.doubles.fastutils.LongArrayList

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.