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

📄 statistics.java

📁 Java的面向对象数据库系统的源代码
💻 JAVA
字号:
// You can redistribute this software and/or modify it under the terms of
// the Ozone Library License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
// $Id: Statistics.java,v 1.3 2002/12/29 11:15:58 per_nyfelt Exp $

package org.ozoneDB.tools;

import org.ozoneDB.DxLib.DxObject;
import org.ozoneDB.io.stream.ResolvingObjectInputStream;

import java.io.*;


public class Statistics extends Object {
    static String dir = File.separator + "stats";
    public static String clusp = new String( "clusp" );


    public static void main( String[] args ) {
        try {
            String odbdir = args[0].toString();
            System.out.println( "ODB3X statistics" );
            System.out.println( "----------------" );
            printLastOID( odbdir );
            printStats( odbdir );
        } catch (Exception e) {
            System.out.println( "\nusage: java Statistics <dir>" );
            System.exit( 1 );
        }
    }


    public static void printLastOID( String odbdir ) {
    // FIXME:
    //        try {
    //            File f = new File (odbdir, Env.OID_FILE);
    //            RandomAccessFile rf = new RandomAccessFile (f, "rw");
    //            long id = rf.readLong ();
    //            System.out.println ("DatabaseID          : " + (id>>40));
    //            System.out.println ("ObjectID count      : " + (id & 0xFFFFF));
    //            System.out.println ("ClusterID count     : " + (rf.readLong() & 0xFFFFF));
    //            System.out.println ("TransactionID count : " + (rf.readLong() & 0xFFFFF));
    //            rf.close ();
    //        } catch (IOException e) {
    //            System.err.println (e);
    //            }
    }


    public static void printStats( String odbdir ) {
        System.out.print( "\nClusterSpace stats:" );
        System.out.println( readClusterStats( odbdir ) );
    }


    public static void writeStats( DxObject cs, String path, String file ) {
        try {
            File f = new File( path + dir );
            if (!f.exists()) {
                f.mkdir();
            }
            f = new File( path + dir, file );
            FileOutputStream fo = new FileOutputStream( f );
            ObjectOutputStream os = new ObjectOutputStream( fo );
            os.writeObject( cs );
            os.close();
        } catch (Exception e) {
            System.out.println( e );
        }
    }


    public static DxObject readStats( String path, String file ) {
        try {
            File f = new File( path + dir, file );
            FileInputStream fi = new FileInputStream( f );
            ObjectInputStream is = new ResolvingObjectInputStream( fi );
            DxObject obj = (DxObject)is.readObject();
            fi.close();
            return obj;
        } catch (FileNotFoundException e) {
        // nichts tun, wenn file nicht da, wird spaeter angelegt
        } catch (Exception e) {
            System.out.println( e );
        }
        return null;
    }


    public static void writeClusterStats( ClusterStats cs, String path ) {
        writeStats( cs, path, clusp );
    }


    public static ClusterStats readClusterStats( String path ) {
        ClusterStats cs = (ClusterStats)Statistics.readStats( path, clusp );
        if (cs == null) {
            cs = new ClusterStats();
            writeClusterStats( cs, path );
        }
        return cs;
    }
}

⌨️ 快捷键说明

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