Package logformat.slog2.update

Examples of logformat.slog2.update.UpdateToLatest


    private static short              depth_max;

    public static final void main( String[] args )
    throws IOException
    {
        InputLog          slog_ins;
        CategoryMap       objdefs;
        TreeTrunk         treetrunk;
        TreeNode          treeroot;
        TimeBoundingBox   timeframe_old, timeframe;
        short             depth;
        String            err_msg;

        parseCmdLineArgs( args );

        slog_ins   = new InputLog( in_slog2filename );
        if ( slog_ins == null ) {
            System.err.println( "Null input logfile!" );
            System.exit( 1 );
        }
        if ( ! slog_ins.isSLOG2() ) {
            System.err.println( in_slog2filename + " is NOT SLOG-2 file!." );
            System.exit( 1 );
        }
        if ( (err_msg = slog_ins.getCompatibleHeader()) != null ) {
            System.err.print( err_msg );
            InputLog.stdoutConfirmation();
        }
        slog_ins.initialize();
        // System.out.println( slog_ins );

        long         time1, time2;
        StringBuffer timing_str;

        // Initialize the TreeTrunk with same order as in Jumpshot.
        treetrunk  = new TreeTrunk( slog_ins, Drawable.INCRE_STARTTIME_ORDER );
        treetrunk.setDebuggingEnabled( isVerbose );
        treetrunk.initFromTreeTop();
        treeroot   = treetrunk.getTreeRoot();
        if ( treeroot == null ) {
            System.out.println( "SLOG-2 file, " + in_slog2filename + " "
                              + "contains no drawables" );
            slog_ins.close();
            System.exit( 0 );
        }
        timeframe_root  = new TimeBoundingBox( treeroot );
        depth_max       = treeroot.getTreeNodeID().depth;
        System.out.println( "# TimeWindow = " + timeframe_root
                          + " @ dmax = " + depth_max );

        File         data_file = new File( in_datafilename );
        TimeBoxList  tbox_list = new TimeBoxList( data_file );
        Iterator     itr_times = tbox_list.iterator();

        timeframe = timeframe_root;
        if ( itr_times.hasNext() )
            timeframe = (TimeBoundingBox) itr_times.next();
        else {
            System.out.println( "No more timeframe in datafile "
                              + in_datafilename + ".  Exiting..." );
            System.exit( 0 );
        }

        System.out.println( "# Srolling Duration = "
                          + timeframe.getDuration() );

        // Append xmgrace description of the graph
        StringBuffer xmgrace_strbuf = new StringBuffer();
        xmgrace_strbuf.append( "@with g0\n" );
        xmgrace_strbuf.append( "@    title \"" + in_slog2filename + "\"\n" );
        xmgrace_strbuf.append( "@    legend 0.4, 0.8\n" );
        xmgrace_strbuf.append( "@    xaxis label " );
        xmgrace_strbuf.append( "\"Time location in logfile (sec).\"\n" );
        xmgrace_strbuf.append( "@    yaxis label " );
        xmgrace_strbuf.append( "\"Time taken per scroll (msec).\"\n" );
        xmgrace_strbuf.append( "@    s0 symbol 1\n" );
        xmgrace_strbuf.append( "@    s0 symbol size 0.25\n" );
        xmgrace_strbuf.append( "@    s0 line type 0\n" );
        xmgrace_strbuf.append( "@    s0 legend " );
        xmgrace_strbuf.append( "\"Duration of each scroll = "
                             + (float)timeframe.getDuration() + " sec.\"\n" );
        xmgrace_strbuf.append( "@target G0.S0\n" );
        xmgrace_strbuf.append( "@type xy\n" );
        System.out.println( xmgrace_strbuf.toString() );

        timing_str = new StringBuffer();
        // timing_str.append( timeframe + " @ d = " + depth + ": " );
        timing_str.append( timeframe.getEarliestTime() + " " );
        time1  = System.nanoTime();

        // Grow to a fixed size first
        // depth           = depth_max;
        depth           = 0;
        treetrunk.growInTreeWindow( treeroot, depth, timeframe );
        switch (print_opt) {
            case PRINT_ALL :
                System.out.println( treetrunk.toString( timeframe ) );
                break;
            case PRINT_STUB :
                System.out.println( treetrunk.toStubString() );
                break;
            case PRINT_NONE :
            default :
        }
        timeframe_old = timeframe;

        time2  = System.nanoTime();
        // timing_str.append( (1.0e-6 * (time2 - time1)) + " msec." );
        timing_str.append( (1.0e-6 * (time2 - time1)) );
        System.out.println( timing_str.toString() );

        // Navigate the slog2 tree
        while ( itr_times.hasNext() ) {
            timeframe = (TimeBoundingBox) itr_times.next();
            timing_str = new StringBuffer();
            // timing_str.append( timeframe + " @ d = " + depth + ": " );
            timing_str.append( timeframe.getEarliestTime() + " " );
            time1  = System.nanoTime();

            if (   treetrunk.updateTimeWindow( timeframe_old, timeframe )
                 > TreeTrunk.TIMEBOX_EQUAL ) {
                switch (print_opt) {
                    case PRINT_ALL :
                        // System.out.println(
                        // treetrunk.toFloorString( timeframe ) );
                        System.out.println( treetrunk.toString( timeframe ) );
                        // System.out.println( treetrunk.toString() );
                        break;
                    case PRINT_STUB :
                        System.out.println( treetrunk.toStubString() );
                        break;
                    case PRINT_NONE :
                    default :
                }
                timeframe_old = timeframe;
            }

            time2  = System.nanoTime();
            // timing_str.append( (1.0e-6 * (time2 - time1)) + " msec." );
            timing_str.append( (1.0e-6 * (time2 - time1)) );
            System.out.println( timing_str.toString() );
        }

        slog_ins.close();
    }
View Full Code Here


    private static boolean        printDrawables    = true;


    public static final void main( String[] args )
    {
        InputLog         slog_ins;
        TreeDir          treedir;
        TimeBoundingBox  timeframe;
        String           err_msg;

        parseCmdLineArgs( args );

        slog_ins   = new InputLog( in_filename );
        if ( slog_ins == null ) {
            System.err.println( "Null input logfile!" );
            System.exit( 1 );
        }
        if ( ! slog_ins.isSLOG2() ) {
            System.err.println( in_filename + " is NOT SLOG-2 file!." );
            System.exit( 1 );
        }
        if ( (err_msg = slog_ins.getCompatibleHeader()) != null ) {
            System.err.print( err_msg );
            InputLog.stdoutConfirmation();
        }
        slog_ins.initialize();
        System.out.println( slog_ins.toString( printCategoryMap,
                                               printTreeDir,
                                               printLineIDMaps ) );
        if ( !printDrawables ) {
            slog_ins.close();
            System.exit( 0 );
        }

        treedir = slog_ins.getTreeDir();
        // System.out.println( treedir );

        TreeDirValue  root_dir;
        root_dir  = (TreeDirValue) treedir.get( treedir.firstKey() );
        timeframe = new TimeBoundingBox( root_dir.getTimeBoundingBox() );
        scaleTimeBounds( timeframe );

        boolean   isStartTimeOrdered;
        boolean   isIncreTimeOrdered;
        double    prev_bordertime;

        Iterator  dobj_itr;
        Drawable  dobj;
        double    dobj_bordertime;
        int       dobj_count;

        isStartTimeOrdered = dobj_order.isStartTimeOrdered();
        isIncreTimeOrdered = dobj_order.isIncreasingTimeOrdered();
        prev_bordertime    = isIncreTimeOrdered ?
                             Double.NEGATIVE_INFINITY :
                             Double.POSITIVE_INFINITY;
        dobj_count         = 0;

        dobj_itr = slog_ins.iteratorOfRealDrawables( timeframe, dobj_order,
                                                     itrTopoLevel );
        while ( dobj_itr.hasNext() ) {
            dobj            = (Drawable) dobj_itr.next();
            dobj_bordertime = dobj.getBorderTime( isStartTimeOrdered );
            if ( isIncreTimeOrdered ) {
                if ( prev_bordertime > dobj_bordertime )
                    System.out.print( "  *****  " );
            }
            else {
                if ( prev_bordertime < dobj_bordertime )
                    System.out.print( "  *****  " );
            }


            System.out.println( (++dobj_count) + ": " + dobj );
            // System.out.println( dobj + " <=> " + (++dobj_count) );
            // System.out.println( dobj  );
            // printClogArrowMessageSize( dobj );
            prev_bordertime  = dobj_bordertime;
        }

        slog_ins.close();
    }
View Full Code Here

    private static short              depth_max;

    public static final void main( String[] args )
    throws java.io.IOException
    {
        InputLog          slog_ins;
        CategoryMap       objdefs;
        TreeTrunk         treetrunk;
        TreeNode          treeroot;
        TimeBoundingBox   timeframe;
        String            err_msg;

        parseCmdLineArgs( args );

        slog_ins   = new InputLog( in_filename );
        if ( slog_ins == null ) {
            System.err.println( "Null input logfile!" );
            System.exit( 1 );
        }
        if ( ! slog_ins.isSLOG2() ) {
            System.err.println( in_filename + " is NOT SLOG-2 file!." );
            System.exit( 1 );
        }
        if ( (err_msg = slog_ins.getCompatibleHeader()) != null ) {
            System.err.print( err_msg );
            InputLog.stdoutConfirmation();
        }
        slog_ins.initialize();
        // System.out.println( slog_ins );

        // Initialize the TreeTrunk with same order as in Jumpshot.
        treetrunk  = new TreeTrunk( slog_ins, Drawable.INCRE_STARTTIME_ORDER );
        treetrunk.setDebuggingEnabled( isVerbose );
        treetrunk.initFromTreeTop();
        treeroot   = treetrunk.getTreeRoot();
        if ( treeroot == null ) {
            System.out.println( "SLOG-2 file, " + in_filename + " "
                              + "contains no drawables" );
            slog_ins.close();
            System.exit( 0 );
        }
        timeframe_root  = new TimeBoundingBox( treeroot );
        depth_max       = treeroot.getTreeNodeID().depth;
        System.out.println( "# TimeWindow = " + timeframe_root
                          + " @ dmax = " + depth_max );

        File             out_file;
        FileOutputStream out_fos;
        DataOutputStream out_dos;
        Iterator         itr_times;

        System.out.println( "****  Foreward  ****" );
        out_file = new File( append_name( in_filename, "_fscroll.dat" ) );
        out_fos  = new FileOutputStream( out_file );
        out_dos  = new DataOutputStream( out_fos );
        itr_times = new ItrOfForeScrollTimes( timeframe_root );
        while ( itr_times.hasNext() ) {
             timeframe = (TimeBoundingBox) itr_times.next();
             timeframe.writeObject( out_dos );
             System.out.println( timeframe );
        }
        out_fos.close();

        System.out.println( "****  Backward  ****" );
        out_file = new File( append_name( in_filename, "_bscroll.dat" ) );
        out_fos  = new FileOutputStream( out_file );
        out_dos  = new DataOutputStream( out_fos );
        itr_times = new ItrOfBackScrollTimes( timeframe_root );
        while ( itr_times.hasNext() ) {
             timeframe = (TimeBoundingBox) itr_times.next();
             timeframe.writeObject( out_dos );
             System.out.println( timeframe );
        }
        out_fos.close();

        System.out.println( "****  Alternate Zoom  ****" );
        out_file = new File( append_name( in_filename, "_altzoom.dat" ) );
        out_fos  = new FileOutputStream( out_file );
        out_dos  = new DataOutputStream( out_fos );
        itr_times = new ItrOfAltZoomTimes( timeframe_root );
        while ( itr_times.hasNext() ) {
             timeframe = (TimeBoundingBox) itr_times.next();
             timeframe.writeObject( out_dos );
             System.out.println( timeframe );
        }
        out_fos.close();

        slog_ins.close();
    }
View Full Code Here

                           String[]            yaxis_colnames,
                           Method[]            dobj_methods )
    {
        super( time_model );

        TreeNode   treeroot;
        short      depth_max, depth_init;

        t_model         = time_model;
        treetrunk       = treebody;
        y_maps          = yaxis_maps;
        tree_view       = y_maps.getTreeView();
        y_model         = yaxis_model;
        y_colnames      = yaxis_colnames;
        methods         = dobj_methods;
        treeroot        = treetrunk.getTreeRoot();
        depth_max       = treeroot.getTreeNodeID().depth;
        nesting_stacks  = new NestingStacks( tree_view );
        map_line2row    = null;
        drawn_boxes     = new DrawnBoxSet( tree_view );
        // timeframe4imgs to be initialized later in initializeAllOffImages()
        timeframe4imgs  = null;
View Full Code Here

                          ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS );
        y_scrollbar = y_scroller.getVerticalScrollBar();
        y_model     = y_scrollbar.getModel();

        /* Initialize the ModelTime slog.input.InputLog().getTreeRoot() */
        treetrunk     = new TreeTrunk( slog_ins,
                                       Drawable.INCRE_STARTTIME_ORDER );
        treetrunk.initFromTreeTop();
        treeroot      = treetrunk.getTreeRoot();
        time_model    = new ModelTime( root_window,
                                       treeroot.getEarliestTime(),
View Full Code Here

    private static int[]    del_iobjdefs;

    public static final void main( String[] args )
    {
        PipedInputLog      dobj_ins;
        OutputLog          slog_outs;
        Kind               next_kind;
        Topology           topo;
        CategoryMap        objdefs;   // Drawable def'n
        Map                shadefs;   // Shadow   def'n
        Category           objdef;
        LineIDMapList      lineIDmaps;
        LineIDMap          lineIDmap;
        Primitive          prime_obj;
        Composite          cmplx_obj;
        long               Nobjs;

        TreeTrunk          treetrunk;
        double             prev_dobj_endtime;
        double             curr_dobj_endtime;
        long               offended_Nobjs;
        Drawable           offended_dobj;



        //  Initialize prev_dobj_endtime to avoid complaint by compiler
        prev_dobj_endtime = Double.NEGATIVE_INFINITY;
        offended_Nobjs    = Integer.MIN_VALUE;
        offended_dobj     = null;

        out_filename      = null;
        del_iobjdefs      = null;
        parseCmdLineArgs( args );
        if ( out_filename == null )
            out_filename  = TraceName.getDefaultSLOG2Name( in_filename );

        objdefs       = new CategoryMap();
        shadefs       = new HashMap();
        lineIDmaps    = new LineIDMapList();
        Nobjs         = 0;

        // Initialize the SLOG-2 file for piped-input, output for this program.
        dobj_ins   = new PipedInputLog( in_filename );
        if ( dobj_ins == null ) {
            System.err.println( "Null input logfile!" );
            System.exit( 1 );
        }
        if ( ! dobj_ins.isSLOG2() ) {
            System.err.println( in_filename + " is NOT SLOG-2 file!." );
            System.exit( 1 );
        }
        String err_msg;
        if ( (err_msg = dobj_ins.getCompatibleHeader()) != null ) {
            System.err.print( err_msg );
            PipedInputLog.stdoutConfirmation();
        }
        dobj_ins.initialize();

        /* */    Date time1 = new Date();
        slog_outs  = new OutputLog( out_filename );

        //  Set Tree properties, !optional!
        //  TreeNode's minimum size, without any drawable/shadow, is 38 bytes.
        //  Drawable;s minimum size is 32 bytes, whether it is state/arrow.
        //  Arrow( with 2 integer infovalues ) is 40 bytes long.
        //  So, for 1 state primitive leaf, the size is 38 + 40 = 78 .
        if ( leaf_bytesize > 0 )
            slog_outs.setTreeLeafByteSize( leaf_bytesize );
        else
            slog_outs.setTreeLeafByteSize( dobj_ins.getTreeLeafByteSize() );
        if ( num_children_per_node > 0 )
            slog_outs.setNumChildrenPerNode( num_children_per_node );
        else
            slog_outs.setNumChildrenPerNode( dobj_ins.getNumChildrenPerNode() );

        treetrunk = new TreeTrunk( slog_outs, shadefs );
        /* */    Date time2 = new Date();
        while ( ( next_kind = dobj_ins.peekNextKind() ) != Kind.EOF ) {
            if ( next_kind == Kind.TOPOLOGY ) {
                topo = dobj_ins.getNextTopology();
                // Put in the default Shadow categories in case the original
                // does not have any shadow categories, i.e no shadows.
                objdef = Category.getShadowCategory( topo );
                objdefs.put( new Integer( objdef.getIndex() ), objdef );
                shadefs.put( topo, objdef );
            }
            else if ( next_kind == Kind.YCOORDMAP ) {
                lineIDmap = new LineIDMap( dobj_ins.getNextYCoordMap() );
                lineIDmaps.add( lineIDmap );
            }
            else if ( next_kind == Kind.CATEGORY ) {
                objdef = dobj_ins.getNextCategory();
                if ( objdef.isShadowCategory() ) {
                    objdefs.put( new Integer( objdef.getIndex() ), objdef );
                    shadefs.put( objdef.getTopology(), objdef );
                }
                // Category can be removed here for efficiency reason.
                // Instead let CategoryMap.removeUnusedCategories() do the work.
                // if ( isCategoryToBeRemoved( objdef.getIndex() ) )
                //     continue;
                objdefs.put( new Integer( objdef.getIndex() ), objdef );
                objdef.setUsed( false );
            }
            else if ( next_kind == Kind.PRIMITIVE ) {
                prime_obj = dobj_ins.getNextPrimitive();
                // Undo InfoBox.resolveCategory() when the Drawable is read.
                prime_obj.releaseCategory();
                if ( isCategoryToBeRemoved( prime_obj.getCategoryIndex() ) ) {
                    // System.out.println( "Removing ... " + prime_obj );
                    continue;
                }
                prime_obj.resolveCategory( objdefs );
                // postponed, wait till on-demand decoding of InfoBuffer
                // prime_obj.decodeInfoBuffer();
                Nobjs++;
                // System.out.println( Nobjs + " : " + prime_obj );
                if ( enable_endtime_check ) {
                    if ( ! prime_obj.isTimeOrdered() ) {
                        System.out.println( "**** Primitive Time Error ****" );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    curr_dobj_endtime = prime_obj.getLatestTime();
                    if ( prev_dobj_endtime > curr_dobj_endtime ) {
                        System.err.println( "**** Violation of "
                                          + "Increasing Endtime Order ****\n"
                                          + "\t Offended Drawable -> "
                                          + offended_Nobjs + " : "
                                          + offended_dobj + "\n"
                                          + "\t Offending Primitive -> "
                                          + Nobjs + " : " + prime_obj + "\n"
                                          + "   previous drawable endtime ( "
                                          + prev_dobj_endtime + " ) "
                                          + " > current drawable endtiime ( "
                                          + curr_dobj_endtime + " ) " );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    offended_Nobjs    = Nobjs;
                    offended_dobj     = prime_obj;
                    prev_dobj_endtime = curr_dobj_endtime;
                }
                treetrunk.addDrawable( prime_obj );
            }
            else if ( next_kind == Kind.COMPOSITE ) {
                cmplx_obj = dobj_ins.getNextComposite();
                // Undo InfoBox.resolveCategory() when the Drawable is read.
                cmplx_obj.releaseCategory();
                if ( isCategoryToBeRemoved( cmplx_obj.getCategoryIndex() ) ) {
                    // System.out.println( "Removing ... " + cmplx_obj );
                    continue;
                }
                cmplx_obj.resolveCategory( objdefs );
                // postponed, wait till on-demand decoding of InfoBuffer
                // cmplx_obj.decodeInfoBuffer();
                Nobjs++;
                // System.out.println( Nobjs + " : " + cmplx_obj );
                if ( enable_endtime_check ) {
                    if ( ! cmplx_obj.isTimeOrdered() ) {
                        System.out.println( "**** Composite Time Error ****" );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    curr_dobj_endtime = cmplx_obj.getLatestTime();
                    if ( prev_dobj_endtime > curr_dobj_endtime ) {
                        System.err.println( "***** Violation of "
                                          + "Increasing Endtime Order! *****\n"
                                          + "\t Offended Drawable -> "
                                          + offended_Nobjs + " : "
                                          + offended_dobj + "\n"
                                          + "\t Offending Composite -> "
                                          + Nobjs + " : " + cmplx_obj + "\n"
                                          + "   previous drawable endtime ( "
                                          + prev_dobj_endtime + " ) "
                                          + " > current drawable endtiime ( "
                                          + curr_dobj_endtime + " ) " );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    offended_Nobjs    = Nobjs;
                    offended_dobj     = cmplx_obj;
                    prev_dobj_endtime = curr_dobj_endtime;
                }
                treetrunk.addDrawable( cmplx_obj );
            }
            else {
                System.err.println( "Slog2ToSlog2: Unrecognized return "
                                  + "from peekNextKind() = " + next_kind );
            }
        }   // Endof while ( dobj_ins.peekNextKind() )
        treetrunk.flushToFile();

        objdefs.removeUnusedCategories();
        slog_outs.writeCategoryMap( objdefs );

        // treetrunk's IdentityLineIDMap could be duplicate of the one
        // in the logfile
        // lineIDmaps.add( treetrunk.getIdentityLineIDMap() );
        slog_outs.writeLineIDMapList( lineIDmaps );

        slog_outs.close();
        dobj_ins.close();

        /* */    Date time3 = new Date();
        System.out.println( "\n" );
        System.out.println( "Number of Drawables = " + Nobjs );
View Full Code Here

    private static int[]    del_iobjdefs;

    public static final void main( String[] args )
    {
        WrappedInputLog    dobj_ins;
        OutputLog          slog_outs;
        Kind               next_kind;
        Topology           topo;
        CategoryMap        objdefs;   // Drawable def'n
        Map                shadefs;   // Shadow   def'n
        Category           objdef;
        LineIDMapList      lineIDmaps;
        LineIDMap          lineIDmap;
        Primitive          prime_obj;
        Composite          cmplx_obj;
        long               Nobjs;

        TreeTrunk          treetrunk;
        double             prev_dobj_endtime;
        double             curr_dobj_endtime;
        long               offended_Nobjs;
        Drawable           offended_dobj;



        //  Initialize prev_dobj_endtime to avoid complaint by compiler
        prev_dobj_endtime = Double.NEGATIVE_INFINITY;
        offended_Nobjs    = Integer.MIN_VALUE;
        offended_dobj     = null;

        out_filename      = null;
        del_iobjdefs      = null;
        parseCmdLineArgs( args );
        if ( out_filename == null )
            out_filename  = TraceName.getDefaultSLOG2Name( in_filename );

        objdefs       = new CategoryMap();
        shadefs       = new HashMap();
        lineIDmaps    = new LineIDMapList();
        Nobjs         = 0;

        // Initialize the SLOG-2 file for piped-input, output for this program.
        dobj_ins   = new WrappedInputLog( in_filename );
        if ( dobj_ins == null ) {
            System.err.println( "Null input logfile!" );
            System.exit( 1 );
        }
        if ( ! dobj_ins.isSLOG2() ) {
            System.err.println( in_filename + " is NOT SLOG-2 file!." );
            System.exit( 1 );
        }
        String err_msg;
        if ( (err_msg = dobj_ins.getCompatibleHeader()) != null ) {
            System.err.print( err_msg );
            WrappedInputLog.stdoutConfirmation();
        }
        dobj_ins.initialize();

        /* */    Date time1 = new Date();
        slog_outs  = new OutputLog( out_filename );

        //  Set Tree properties, !optional!
        //  TreeNode's minimum size, without any drawable/shadow, is 38 bytes.
        //  Drawable;s minimum size is 32 bytes, whether it is state/arrow.
        //  Arrow( with 2 integer infovalues ) is 40 bytes long.
        //  So, for 1 state primitive leaf, the size is 38 + 40 = 78 .
        if ( leaf_bytesize > 0 )
            slog_outs.setTreeLeafByteSize( leaf_bytesize );
        else
            slog_outs.setTreeLeafByteSize( dobj_ins.getTreeLeafByteSize() );
        if ( num_children_per_node > 0 )
            slog_outs.setNumChildrenPerNode( num_children_per_node );
        else
            slog_outs.setNumChildrenPerNode( dobj_ins.getNumChildrenPerNode() );

        treetrunk = new TreeTrunk( slog_outs, shadefs );
        /* */    Date time2 = new Date();
        while ( ( next_kind = dobj_ins.peekNextKind() ) != Kind.EOF ) {
            if ( next_kind == Kind.TOPOLOGY ) {
                topo = dobj_ins.getNextTopology();
                // Put in the default Shadow categories in case the original
                // does not have any shadow categories, i.e no shadows.
                objdef = Category.getShadowCategory( topo );
                objdefs.put( new Integer( objdef.getIndex() ), objdef );
                shadefs.put( topo, objdef );
            }
            else if ( next_kind == Kind.YCOORDMAP ) {
                lineIDmap = new LineIDMap( dobj_ins.getNextYCoordMap() );
                lineIDmaps.add( lineIDmap );
            }
            else if ( next_kind == Kind.CATEGORY ) {
                objdef = dobj_ins.getNextCategory();
                if ( objdef.isShadowCategory() ) {
                    objdefs.put( new Integer( objdef.getIndex() ), objdef );
                    shadefs.put( objdef.getTopology(), objdef );
                }
                // Category can be removed here for efficiency reason.
                // Instead let CategoryMap.removeUnusedCategories() do the work.
                // if ( isCategoryToBeRemoved( objdef.getIndex() ) )
                //     continue;
                objdefs.put( new Integer( objdef.getIndex() ), objdef );
                objdef.setUsed( false );
            }
            else if ( next_kind == Kind.PRIMITIVE ) {
                prime_obj = dobj_ins.getNextPrimitive();
                // Undo InfoBox.resolveCategory() when the Drawable is read.
                prime_obj.releaseCategory();
                if ( isCategoryToBeRemoved( prime_obj.getCategoryIndex() ) ) {
                    // System.out.println( "Removing ... " + prime_obj );
                    continue;
                }
                prime_obj.resolveCategory( objdefs );
                // postponed, wait till on-demand decoding of InfoBuffer
                // prime_obj.decodeInfoBuffer();
                Nobjs++;
                // System.out.println( Nobjs + " : " + prime_obj );
                if ( enable_endtime_check ) {
                    if ( ! prime_obj.isTimeOrdered() ) {
                        System.out.println( "**** Primitive Time Error ****" );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    curr_dobj_endtime = prime_obj.getLatestTime();
                    if ( prev_dobj_endtime > curr_dobj_endtime ) {
                        System.err.println( "**** Violation of "
                                          + "Increasing Endtime Order ****\n"
                                          + "\t Offended Drawable -> "
                                          + offended_Nobjs + " : "
                                          + offended_dobj + "\n"
                                          + "\t Offending Primitive -> "
                                          + Nobjs + " : " + prime_obj + "\n"
                                          + "   previous drawable endtime ( "
                                          + prev_dobj_endtime + " ) "
                                          + " > current drawable endtiime ( "
                                          + curr_dobj_endtime + " ) " );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    offended_Nobjs    = Nobjs;
                    offended_dobj     = prime_obj;
                    prev_dobj_endtime = curr_dobj_endtime;
                }
                treetrunk.addDrawable( prime_obj );
            }
            else if ( next_kind == Kind.COMPOSITE ) {
                cmplx_obj = dobj_ins.getNextComposite();
                // Undo InfoBox.resolveCategory() when the Drawable is read.
                cmplx_obj.releaseCategory();
                if ( isCategoryToBeRemoved( cmplx_obj.getCategoryIndex() ) ) {
                    // System.out.println( "Removing ... " + cmplx_obj );
                    continue;
                }
                cmplx_obj.resolveCategory( objdefs );
                // postponed, wait till on-demand decoding of InfoBuffer
                // cmplx_obj.decodeInfoBuffer();
                Nobjs++;
                // System.out.println( Nobjs + " : " + cmplx_obj );
                if ( enable_endtime_check ) {
                    if ( ! cmplx_obj.isTimeOrdered() ) {
                        System.out.println( "**** Composite Time Error ****" );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    curr_dobj_endtime = cmplx_obj.getLatestTime();
                    if ( prev_dobj_endtime > curr_dobj_endtime ) {
                        System.err.println( "***** Violation of "
                                          + "Increasing Endtime Order! *****\n"
                                          + "\t Offended Drawable -> "
                                          + offended_Nobjs + " : "
                                          + offended_dobj + "\n"
                                          + "\t Offending Composite -> "
                                          + Nobjs + " : " + cmplx_obj + "\n"
                                          + "   previous drawable endtime ( "
                                          + prev_dobj_endtime + " ) "
                                          + " > current drawable endtiime ( "
                                          + curr_dobj_endtime + " ) " );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    offended_Nobjs    = Nobjs;
                    offended_dobj     = cmplx_obj;
                    prev_dobj_endtime = curr_dobj_endtime;
                }
                treetrunk.addDrawable( cmplx_obj );
            }
            else {
                System.err.println( "Slog2ToSlog2: Unrecognized return "
                                  + "from peekNextKind() = " + next_kind );
            }
        }   // Endof while ( dobj_ins.peekNextKind() )
        treetrunk.flushToFile();

        objdefs.removeUnusedCategories();
        slog_outs.writeCategoryMap( objdefs );

        // treetrunk's IdentityLineIDMap could be duplicate of the one
        // in the logfile
        // lineIDmaps.add( treetrunk.getIdentityLineIDMap() );
        slog_outs.writeLineIDMapList( lineIDmaps );

        slog_outs.close();
        dobj_ins.close();

        /* */    Date time3 = new Date();
        System.out.println( "\n" );
        System.out.println( "Number of Drawables = " + Nobjs );
View Full Code Here

        LineIDMap          lineIDmap;
        Primitive          prime_obj;
        Composite          cmplx_obj;
        long               Nobjs;

        TreeTrunk          treetrunk;
        double             prev_dobj_endtime;
        double             curr_dobj_endtime;
        long               offended_Nobjs;
        Drawable           offended_dobj;



        //  Initialize prev_dobj_endtime to avoid complaint by compiler
        prev_dobj_endtime = Double.NEGATIVE_INFINITY;
        offended_Nobjs    = Integer.MIN_VALUE;
        offended_dobj     = null;

        out_filename      = null;
        del_iobjdefs      = null;
        parseCmdLineArgs( args );
        if ( out_filename == null )
            out_filename  = TraceName.getDefaultSLOG2Name( in_filename );

        objdefs       = new CategoryMap();
        shadefs       = new HashMap();
        lineIDmaps    = new LineIDMapList();
        Nobjs         = 0;

        // Initialize the SLOG-2 file for piped-input, output for this program.
        dobj_ins   = new PipedInputLog( in_filename );
        if ( dobj_ins == null ) {
            System.err.println( "Null input logfile!" );
            System.exit( 1 );
        }
        if ( ! dobj_ins.isSLOG2() ) {
            System.err.println( in_filename + " is NOT SLOG-2 file!." );
            System.exit( 1 );
        }
        String err_msg;
        if ( (err_msg = dobj_ins.getCompatibleHeader()) != null ) {
            System.err.print( err_msg );
            PipedInputLog.stdoutConfirmation();
        }
        dobj_ins.initialize();

        /* */    Date time1 = new Date();
        slog_outs  = new OutputLog( out_filename );

        //  Set Tree properties, !optional!
        //  TreeNode's minimum size, without any drawable/shadow, is 38 bytes.
        //  Drawable;s minimum size is 32 bytes, whether it is state/arrow.
        //  Arrow( with 2 integer infovalues ) is 40 bytes long.
        //  So, for 1 state primitive leaf, the size is 38 + 40 = 78 .
        if ( leaf_bytesize > 0 )
            slog_outs.setTreeLeafByteSize( leaf_bytesize );
        else
            slog_outs.setTreeLeafByteSize( dobj_ins.getTreeLeafByteSize() );
        if ( num_children_per_node > 0 )
            slog_outs.setNumChildrenPerNode( num_children_per_node );
        else
            slog_outs.setNumChildrenPerNode( dobj_ins.getNumChildrenPerNode() );

        treetrunk = new TreeTrunk( slog_outs, shadefs );
        /* */    Date time2 = new Date();
        while ( ( next_kind = dobj_ins.peekNextKind() ) != Kind.EOF ) {
            if ( next_kind == Kind.TOPOLOGY ) {
                topo = dobj_ins.getNextTopology();
                // Put in the default Shadow categories in case the original
                // does not have any shadow categories, i.e no shadows.
                objdef = Category.getShadowCategory( topo );
                objdefs.put( new Integer( objdef.getIndex() ), objdef );
                shadefs.put( topo, objdef );
            }
            else if ( next_kind == Kind.YCOORDMAP ) {
                lineIDmap = new LineIDMap( dobj_ins.getNextYCoordMap() );
                lineIDmaps.add( lineIDmap );
            }
            else if ( next_kind == Kind.CATEGORY ) {
                objdef = dobj_ins.getNextCategory();
                if ( objdef.isShadowCategory() ) {
                    objdefs.put( new Integer( objdef.getIndex() ), objdef );
                    shadefs.put( objdef.getTopology(), objdef );
                }
                // Category can be removed here for efficiency reason.
                // Instead let CategoryMap.removeUnusedCategories() do the work.
                // if ( isCategoryToBeRemoved( objdef.getIndex() ) )
                //     continue;
                objdefs.put( new Integer( objdef.getIndex() ), objdef );
                objdef.setUsed( false );
            }
            else if ( next_kind == Kind.PRIMITIVE ) {
                prime_obj = dobj_ins.getNextPrimitive();
                // Undo InfoBox.resolveCategory() when the Drawable is read.
                prime_obj.releaseCategory();
                if ( isCategoryToBeRemoved( prime_obj.getCategoryIndex() ) ) {
                    // System.out.println( "Removing ... " + prime_obj );
                    continue;
                }
                prime_obj.resolveCategory( objdefs );
                // postponed, wait till on-demand decoding of InfoBuffer
                // prime_obj.decodeInfoBuffer();
                Nobjs++;
                // System.out.println( Nobjs + " : " + prime_obj );
                if ( enable_endtime_check ) {
                    if ( ! prime_obj.isTimeOrdered() ) {
                        System.out.println( "**** Primitive Time Error ****" );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    curr_dobj_endtime = prime_obj.getLatestTime();
                    if ( prev_dobj_endtime > curr_dobj_endtime ) {
                        System.err.println( "**** Violation of "
                                          + "Increasing Endtime Order ****\n"
                                          + "\t Offended Drawable -> "
                                          + offended_Nobjs + " : "
                                          + offended_dobj + "\n"
                                          + "\t Offending Primitive -> "
                                          + Nobjs + " : " + prime_obj + "\n"
                                          + "   previous drawable endtime ( "
                                          + prev_dobj_endtime + " ) "
                                          + " > current drawable endtiime ( "
                                          + curr_dobj_endtime + " ) " );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    offended_Nobjs    = Nobjs;
                    offended_dobj     = prime_obj;
                    prev_dobj_endtime = curr_dobj_endtime;
                }
                treetrunk.addDrawable( prime_obj );
            }
            else if ( next_kind == Kind.COMPOSITE ) {
                cmplx_obj = dobj_ins.getNextComposite();
                // Undo InfoBox.resolveCategory() when the Drawable is read.
                cmplx_obj.releaseCategory();
                if ( isCategoryToBeRemoved( cmplx_obj.getCategoryIndex() ) ) {
                    // System.out.println( "Removing ... " + cmplx_obj );
                    continue;
                }
                cmplx_obj.resolveCategory( objdefs );
                // postponed, wait till on-demand decoding of InfoBuffer
                // cmplx_obj.decodeInfoBuffer();
                Nobjs++;
                // System.out.println( Nobjs + " : " + cmplx_obj );
                if ( enable_endtime_check ) {
                    if ( ! cmplx_obj.isTimeOrdered() ) {
                        System.out.println( "**** Composite Time Error ****" );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    curr_dobj_endtime = cmplx_obj.getLatestTime();
                    if ( prev_dobj_endtime > curr_dobj_endtime ) {
                        System.err.println( "***** Violation of "
                                          + "Increasing Endtime Order! *****\n"
                                          + "\t Offended Drawable -> "
                                          + offended_Nobjs + " : "
                                          + offended_dobj + "\n"
                                          + "\t Offending Composite -> "
                                          + Nobjs + " : " + cmplx_obj + "\n"
                                          + "   previous drawable endtime ( "
                                          + prev_dobj_endtime + " ) "
                                          + " > current drawable endtiime ( "
                                          + curr_dobj_endtime + " ) " );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    offended_Nobjs    = Nobjs;
                    offended_dobj     = cmplx_obj;
                    prev_dobj_endtime = curr_dobj_endtime;
                }
                treetrunk.addDrawable( cmplx_obj );
            }
            else {
                System.err.println( "Slog2ToSlog2: Unrecognized return "
                                  + "from peekNextKind() = " + next_kind );
            }
        }   // Endof while ( dobj_ins.peekNextKind() )
        treetrunk.flushToFile();

        objdefs.removeUnusedCategories();
        slog_outs.writeCategoryMap( objdefs );

        // treetrunk's IdentityLineIDMap could be duplicate of the one
View Full Code Here

        LineIDMap          lineIDmap;
        Primitive          prime_obj;
        Composite          cmplx_obj;
        long               Nobjs;

        TreeTrunk          treetrunk;
        double             prev_dobj_endtime;
        double             curr_dobj_endtime;
        long               offended_Nobjs;
        Drawable           offended_dobj;



        //  Initialize prev_dobj_endtime to avoid complaint by compiler
        prev_dobj_endtime = Double.NEGATIVE_INFINITY;
        offended_Nobjs    = Integer.MIN_VALUE;
        offended_dobj     = null;

        out_filename      = null;
        del_iobjdefs      = null;
        parseCmdLineArgs( args );
        if ( out_filename == null )
            out_filename  = TraceName.getDefaultSLOG2Name( in_filename );

        objdefs       = new CategoryMap();
        shadefs       = new HashMap();
        lineIDmaps    = new LineIDMapList();
        Nobjs         = 0;

        // Initialize the SLOG-2 file for piped-input, output for this program.
        dobj_ins   = new WrappedInputLog( in_filename );
        if ( dobj_ins == null ) {
            System.err.println( "Null input logfile!" );
            System.exit( 1 );
        }
        if ( ! dobj_ins.isSLOG2() ) {
            System.err.println( in_filename + " is NOT SLOG-2 file!." );
            System.exit( 1 );
        }
        String err_msg;
        if ( (err_msg = dobj_ins.getCompatibleHeader()) != null ) {
            System.err.print( err_msg );
            WrappedInputLog.stdoutConfirmation();
        }
        dobj_ins.initialize();

        /* */    Date time1 = new Date();
        slog_outs  = new OutputLog( out_filename );

        //  Set Tree properties, !optional!
        //  TreeNode's minimum size, without any drawable/shadow, is 38 bytes.
        //  Drawable;s minimum size is 32 bytes, whether it is state/arrow.
        //  Arrow( with 2 integer infovalues ) is 40 bytes long.
        //  So, for 1 state primitive leaf, the size is 38 + 40 = 78 .
        if ( leaf_bytesize > 0 )
            slog_outs.setTreeLeafByteSize( leaf_bytesize );
        else
            slog_outs.setTreeLeafByteSize( dobj_ins.getTreeLeafByteSize() );
        if ( num_children_per_node > 0 )
            slog_outs.setNumChildrenPerNode( num_children_per_node );
        else
            slog_outs.setNumChildrenPerNode( dobj_ins.getNumChildrenPerNode() );

        treetrunk = new TreeTrunk( slog_outs, shadefs );
        /* */    Date time2 = new Date();
        while ( ( next_kind = dobj_ins.peekNextKind() ) != Kind.EOF ) {
            if ( next_kind == Kind.TOPOLOGY ) {
                topo = dobj_ins.getNextTopology();
                // Put in the default Shadow categories in case the original
                // does not have any shadow categories, i.e no shadows.
                objdef = Category.getShadowCategory( topo );
                objdefs.put( new Integer( objdef.getIndex() ), objdef );
                shadefs.put( topo, objdef );
            }
            else if ( next_kind == Kind.YCOORDMAP ) {
                lineIDmap = new LineIDMap( dobj_ins.getNextYCoordMap() );
                lineIDmaps.add( lineIDmap );
            }
            else if ( next_kind == Kind.CATEGORY ) {
                objdef = dobj_ins.getNextCategory();
                if ( objdef.isShadowCategory() ) {
                    objdefs.put( new Integer( objdef.getIndex() ), objdef );
                    shadefs.put( objdef.getTopology(), objdef );
                }
                // Category can be removed here for efficiency reason.
                // Instead let CategoryMap.removeUnusedCategories() do the work.
                // if ( isCategoryToBeRemoved( objdef.getIndex() ) )
                //     continue;
                objdefs.put( new Integer( objdef.getIndex() ), objdef );
                objdef.setUsed( false );
            }
            else if ( next_kind == Kind.PRIMITIVE ) {
                prime_obj = dobj_ins.getNextPrimitive();
                // Undo InfoBox.resolveCategory() when the Drawable is read.
                prime_obj.releaseCategory();
                if ( isCategoryToBeRemoved( prime_obj.getCategoryIndex() ) ) {
                    // System.out.println( "Removing ... " + prime_obj );
                    continue;
                }
                prime_obj.resolveCategory( objdefs );
                // postponed, wait till on-demand decoding of InfoBuffer
                // prime_obj.decodeInfoBuffer();
                Nobjs++;
                // System.out.println( Nobjs + " : " + prime_obj );
                if ( enable_endtime_check ) {
                    if ( ! prime_obj.isTimeOrdered() ) {
                        System.out.println( "**** Primitive Time Error ****" );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    curr_dobj_endtime = prime_obj.getLatestTime();
                    if ( prev_dobj_endtime > curr_dobj_endtime ) {
                        System.err.println( "**** Violation of "
                                          + "Increasing Endtime Order ****\n"
                                          + "\t Offended Drawable -> "
                                          + offended_Nobjs + " : "
                                          + offended_dobj + "\n"
                                          + "\t Offending Primitive -> "
                                          + Nobjs + " : " + prime_obj + "\n"
                                          + "   previous drawable endtime ( "
                                          + prev_dobj_endtime + " ) "
                                          + " > current drawable endtiime ( "
                                          + curr_dobj_endtime + " ) " );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    offended_Nobjs    = Nobjs;
                    offended_dobj     = prime_obj;
                    prev_dobj_endtime = curr_dobj_endtime;
                }
                treetrunk.addDrawable( prime_obj );
            }
            else if ( next_kind == Kind.COMPOSITE ) {
                cmplx_obj = dobj_ins.getNextComposite();
                // Undo InfoBox.resolveCategory() when the Drawable is read.
                cmplx_obj.releaseCategory();
                if ( isCategoryToBeRemoved( cmplx_obj.getCategoryIndex() ) ) {
                    // System.out.println( "Removing ... " + cmplx_obj );
                    continue;
                }
                cmplx_obj.resolveCategory( objdefs );
                // postponed, wait till on-demand decoding of InfoBuffer
                // cmplx_obj.decodeInfoBuffer();
                Nobjs++;
                // System.out.println( Nobjs + " : " + cmplx_obj );
                if ( enable_endtime_check ) {
                    if ( ! cmplx_obj.isTimeOrdered() ) {
                        System.out.println( "**** Composite Time Error ****" );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    curr_dobj_endtime = cmplx_obj.getLatestTime();
                    if ( prev_dobj_endtime > curr_dobj_endtime ) {
                        System.err.println( "***** Violation of "
                                          + "Increasing Endtime Order! *****\n"
                                          + "\t Offended Drawable -> "
                                          + offended_Nobjs + " : "
                                          + offended_dobj + "\n"
                                          + "\t Offending Composite -> "
                                          + Nobjs + " : " + cmplx_obj + "\n"
                                          + "   previous drawable endtime ( "
                                          + prev_dobj_endtime + " ) "
                                          + " > current drawable endtiime ( "
                                          + curr_dobj_endtime + " ) " );
                        if ( ! continue_when_violation )
                            System.exit( 1 );
                    }
                    offended_Nobjs    = Nobjs;
                    offended_dobj     = cmplx_obj;
                    prev_dobj_endtime = curr_dobj_endtime;
                }
                treetrunk.addDrawable( cmplx_obj );
            }
            else {
                System.err.println( "Slog2ToSlog2: Unrecognized return "
                                  + "from peekNextKind() = " + next_kind );
            }
        }   // Endof while ( dobj_ins.peekNextKind() )
        treetrunk.flushToFile();

        objdefs.removeUnusedCategories();
        slog_outs.writeCategoryMap( objdefs );

        // treetrunk's IdentityLineIDMap could be duplicate of the one
View Full Code Here

TOP

Related Classes of logformat.slog2.update.UpdateToLatest

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.