⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inputlog.java

📁 fortran并行计算包
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        TreeNode  treenode;        treenode  = new TreeNode();        err_str   = readFilePart( blockptr, "TreeNode", treenode );        if ( err_str != null ) {            System.err.println( err_str );            System.exit( 1 );        }        return treenode;    }*/    public TreeNode readTreeNode( final FileBlockPtr blockptr )    {        // Checks for Error!        if ( blockptr.isNULL() ) {            System.err.println( "The file block pointer to the TreeNode "                              + "is NOT initialized!, can't read it." );            return null;        }        if ( blockptr.getBlockSize() > filehdr.getMaxBufferByteSize() ) {            System.err.println( "Oops! Unexpected Error: "                              + "The block size of the TreeNode is "                              + "too big to read into buffer for processing." );            return null;        }        TreeNode     treenode;        long blk_fptr = blockptr.getFilePointer();        int  blk_size = blockptr.getBlockSize();        try {            rand_file.seek( blk_fptr );            rand_file.readFully( buffer, 0, blk_size );            bary_ins  = new ByteArrayInputStream( buffer, 0, blk_size );            data_ins  = new MixedDataInputStream( bary_ins );            treenode  = new TreeNode( data_ins, objdefs );            data_ins.close();        } catch ( IOException ioerr ) {            System.err.println( "InputLog: Non-recoverable IOException! "                              + "Program continues ..." );            ioerr.printStackTrace();            treenode  = null;        }        return treenode;    }    public void close()    {        try {            rand_file.close();        } catch ( IOException ioerr ) {            System.err.println( "InputLog: Non-recoverable IOException! "                              + "Exiting ..." );            ioerr.printStackTrace();            System.exit( 1 );        }    }    protected void finalize() throws Throwable    {        try {            close();        } finally {            super.finalize();        }    }    public String toString()    {        StringBuffer rep = new StringBuffer();        rep.append( filehdr.toString() + "\n" );        rep.append( objdefs.toString() + "\n" );        rep.append( treedir.toString() + "\n" );        rep.append( lineIDmaps.toString() + "\n" );        return rep.toString();    }    public String toString( boolean printCategoryMap,                            boolean printTreeDir,                            boolean printLineIDMaps )    {        StringBuffer rep = new StringBuffer();        rep.append( filehdr.toString() + "\n" );        if ( printCategoryMap )            rep.append( objdefs.toString() + "\n" );        if ( printTreeDir )            rep.append( treedir.toString() + "\n" );        if ( printLineIDMaps )            rep.append( lineIDmaps.toString() + "\n" );        return rep.toString();    }    // "dobj_order" can be any one of the 4 predefined Drawable.Orders.    // i.e. INCRE_STARTTIME_ORDER, DECRE_STARTTIME_ORDER    //      INCRE_FINALTIME_ORDER, DECRE_FINALTIME_ORDER.    // where INCRE_STARTTIME_ORDER is the drawing order required by Jumpshot    // and   DECRE_STARTTIME_ORDER is the clickable search order in Jumpshot.    // and   INCRE_FINALTIME_ORDER is the drawable order iterated by TRACE-API    public Iterator iteratorOfRealDrawables( TimeBoundingBox timeframe,                                             Drawable.Order  dobj_order,                                             int             itrTopoLevel )    {         return new ItrOfAllRealDobjs( timeframe, dobj_order, itrTopoLevel );    }    private class ItrOfAllRealDobjs extends IteratorOfGroupObjects    {        private static final boolean  IS_COMPOSITE = true;        private static final short    LOWEST_DEPTH = 0;        private int              iterateTopoLevel;        private Drawable.Order   dobj_order;        private TimeBoundingBox  current_timebox;        private TreeTrunk        treetrunk;        private SortedSet        timebox_set;        private Iterator         timeboxes;        private boolean          isStartTimeOrdered;        private Drawable         next_drawable;        public ItrOfAllRealDobjs( final TimeBoundingBox timeframe,                                  final Drawable.Order  itrOrder,                                        int             itrTopoLevel )        {            super( timeframe );            iterateTopoLevel   = itrTopoLevel;            dobj_order         = itrOrder;                            isStartTimeOrdered = dobj_order.isStartTimeOrdered();            TreeNode         treeroot;            TimeBoundingBox  timebox_root;            treetrunk    = new TreeTrunk( InputLog.this, dobj_order );            treetrunk.initFromTreeTop();            treeroot     = treetrunk.getTreeRoot();            if ( treeroot == null ) {                next_drawable = null;                return;            }            timebox_root = new TimeBoundingBox( treeroot );            // System.err.println( "Time Window is " + timebox_root );            Iterator         entries;            Map.Entry        entry;            TreeNodeID       ID;            TreeDirValue     val;            TimeBoundingBox  timebox;             /*                timebox_set stores the TimeBoundingBoxes of all the leaf                TreeNodes, these TimeBoundingBoxes are non-overlapping,                so both TimeBoundingBox's INCRE_STARTTIME_ORDER and                DECRE_FINALTIME_ORDER will arrange the non-overlapping                timeboxes in the same increasing time order.  Similarly,                TimeBoundingBox's DECRE_STARTTIME_ORDER and                DECRE_FINALTIME_ORDER will arrange the non-overlapping                in the same decreasing time order.            */            timebox_set = new TreeSet( dobj_order.getTimeBoundingBoxOrder() );             entries      = treedir.entrySet().iterator();            while ( entries.hasNext() ) {                entry    = (Map.Entry) entries.next();                ID       = (TreeNodeID) entry.getKey();                val      = (TreeDirValue) entry.getValue();                if ( ID.isLeaf() ) {                    timebox = new TimeBoundingBox( val.getTimeBoundingBox() );                    timebox_set.add( timebox );                    // System.out.println( ID + " -> " + timebox );                }            }            if ( dobj_order.isIncreasingTimeOrdered() ) {                timebox = (TimeBoundingBox) timebox_set.first();                timebox.setEarliestTime( timebox_root.getEarliestTime() );                // System.out.println( "first_timebox -> " + timebox );                timebox = (TimeBoundingBox) timebox_set.last();                timebox.setLatestTime( timebox_root.getLatestTime() );                // System.out.println( "last_timebox -> " + timebox );            }            else {                timebox = (TimeBoundingBox) timebox_set.first();                timebox.setLatestTime( timebox_root.getLatestTime() );                // System.out.println( "first_timebox -> " + timebox );                timebox = (TimeBoundingBox) timebox_set.last();                timebox.setEarliestTime( timebox_root.getEarliestTime() );                // System.out.println( "last_timebox -> " + timebox );            }            // Setup the iterator, timeboxes, to be used by nextObjGrpItr()            timeboxes   = timebox_set.iterator();            timebox     = (TimeBoundingBox) timebox_set.first();            treetrunk.growInTreeWindow( treeroot, LOWEST_DEPTH, timebox );            super.setObjGrpItr( this.nextObjGrpItr( timeframe ) );            next_drawable  = this.getNextInQueue();        }        protected Iterator nextObjGrpItr( final TimeBoundingBox tframe )        {            TimeBoundingBox  timebox;            Iterator         nestable_itr, nestless_itr;            Iterator         dobj_itr;            while ( timeboxes.hasNext() ) {                timebox    = (TimeBoundingBox) timeboxes.next();                current_timebox = timebox.getIntersection( tframe );                if ( current_timebox != null ) {                    treetrunk.scrollTimeWindowTo( current_timebox );                    // System.out.println( current_timebox + ":" );                    // System.out.println( treetrunk.toStubString() );                    nestable_itr = null;                    if (    iterateTopoLevel == ITERATE_ALL                         || iterateTopoLevel == ITERATE_STATES ) {                        nestable_itr                        = treetrunk.iteratorOfRealDrawables( current_timebox,                                                             dobj_order,                                                             IS_COMPOSITE,                                                             true );                    }                    nestless_itr = null;                    if (    iterateTopoLevel == ITERATE_ALL                         || iterateTopoLevel == ITERATE_ARROWS ) {                        nestless_itr                        = treetrunk.iteratorOfRealDrawables( current_timebox,                                                             dobj_order,                                                             IS_COMPOSITE,                                                             false );                    }                    dobj_itr = null;                    if ( nestable_itr != null && nestless_itr != null )                        dobj_itr = new IteratorOfAllDrawables( nestable_itr,                                                               nestless_itr,                                                               dobj_order );                    else {                        if ( nestable_itr != null )                            dobj_itr = nestable_itr;                        if ( nestless_itr != null )                            dobj_itr = nestless_itr;                    }                    return dobj_itr;                }            }            // return NULL when all timeboxes have been exhausted            return null;        }        private Drawable getNextInQueue()        {            Drawable  dobj;            if ( isStartTimeOrdered ) {                while ( super.hasNext() ) {                    dobj = (Drawable) super.next();                    if ( current_timebox.containsWithinLeft(                                         dobj.getEarliestTime() ) )                        return dobj;                }            }            else {                while ( super.hasNext() ) {                    dobj = (Drawable) super.next();                    if ( current_timebox.containsWithinRight(                                         dobj.getLatestTime() ) )                        return dobj;                }            }            return null;        }        public boolean hasNext()        {            return next_drawable != null;        }        public Object next()        {            Drawable  returning_dobj;            returning_dobj  = next_drawable;            next_drawable   = this.getNextInQueue();            return returning_dobj;        }    }   // End of ForeItrOfAllRealDobjs}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -