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

📄 idtable.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-2000 by SMB GmbH. All rights reserved.//// $Id: IDTable.java,v 1.3 2000/11/10 17:05:04 daniela Exp $package org.ozoneDB.core.wizardStore;import java.io.*;import org.ozoneDB.DxLib.*;import org.ozoneDB.core.*;import org.ozoneDB.util.LogWriter;/** * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.3 $Date: 2000/11/10 17:05:04 $ */public final class IDTable extends DxDiskHashMap {        final static long serialVersionUID = 1L;        public final static int MAX_CACHE_SIZE = 2000;        //    protected DxDeque		leafCache;    //    //    protected DxDeque		branchCache;    //    //    protected DxDeque		keyDataCache;            public IDTable( String _baseFileName, int _maxBufferSize, int _cacheBits, int _tableBitSize ) {        super( _baseFileName, _maxBufferSize, _cacheBits, _tableBitSize );        //        leafCache = new DxArrayDeque (MAX_CACHE_SIZE);        //        branchCache = new DxArrayDeque (MAX_CACHE_SIZE);        //        keyDataCache = new DxArrayDeque (MAX_CACHE_SIZE);    }    public synchronized void close() throws Exception {        writeDirtyTables();        setReusable( true );    }     public synchronized void writeDirtyTables() throws Exception {        DxIterator it = buffer.iterator();        DxDiskSubTable table = null;        while ((table = (DxDiskSubTable)it.next()) != null) {            if (table.isDirty()) {                Env.currentEnv().logWriter.newEntry( this, "write dirty table: " + table.filename(), LogWriter.DEBUG);                table.writeTable();            }        }     }         public boolean isDirtyTable( DxDiskSubTable table ) {        boolean result = table.isDirty();        Env.currentEnv().logWriter.newEntry( this, "isDirtyTable(): name=" + table.filename() + ", dirty=" + result, LogWriter.DEBUG);        return result;    }        public void printStatistics() {        Env.currentEnv().logWriter.newEntry( this, "Statistics:", LogWriter.INFO );        Env.currentEnv().logWriter.newEntry( this, "    sub-table accesses: " + bufferAccesses + "  hits: " + bufferHits + " loads: " + (bufferAccesses - bufferHits), LogWriter.INFO );        Env.currentEnv().logWriter.newEntry( this, "    cache accesses: " + cacheAccesses + "  hits: " + cacheHits, LogWriter.INFO );    }                     public DxDiskHashNodeLeaf newNodeLeaf() {        return new IDTableNodeLeaf( this );        //        System.out.print ("newNodeLeaf()... ");    //        if (leafCache.isEmpty()) {    //            System.out.println ("new");    //            return new IDTableNodeLeaf (this);    //            }    //        else {    //            System.out.println ("cache");    //            return (DxDiskHashNodeLeaf)leafCache.popTop();    //            }    }             public DxDiskHashNodeBranch newNodeBranch() {        return new IDTableNodeBranch();        //        System.out.print ("newNodeBranch()... ");    //        if (branchCache.isEmpty()) {    //            System.out.println ("new");    //            return new IDTableNodeBranch();    //            }    //        else {    //            System.out.println ("cache");    //            return (DxDiskHashNodeBranch)branchCache.popTop();    //            }    }             public DxKeyData newKeyData() {        return new DxKeyData();        //        System.out.print ("newKeyData()... ");    //        if (keyDataCache.isEmpty()) {    //            System.out.println ("new");    //            return new DxKeyData();    //            }    //        else {    //            System.out.println ("cache");    //            return (DxKeyData)keyDataCache.popTop();    //            }    }             public ObjectID newObjectID() {        //        System.out.println ("newObjectID()");        return new ObjectID();    }             public ClusterID newClusterID() {        //        System.out.println ("newClusterID()");        return new ClusterID();    }             /**     * The specified sub-table was deleted from the tree. So we have     * to delete it from the table buffer too.     */    public synchronized void deleteRequest( DxDiskSubTable subTable ) {        //        System.out.println ("deleteRequest()");        //        //        DxDiskHashNode[] table = subTable.table();        //        for (int i=0; i<table.length; i++) {        //            if (table[i] instanceof IDTableNodeLeaf) {        //                DxKeyData element = ((IDTableNodeLeaf)table[i]).element();        //                while (element != null) {        //                    if (keyDataCache.count() < MAX_CACHE_SIZE) {        //                        System.out.print ("keydata cached");        //                        keyDataCache.pushTop (element);        //                        element = element.next;        //                        }        //                    else        //                        System.out.print ("keydata cache full");        //                    }        //        //                if (leafCache.count() < MAX_CACHE_SIZE) {        //                    System.out.print ("leaf cached");        //                    leafCache.pushTop (table[i]);        //                    table[i].empty();        //                    table[i] = null;        //                    }        //                else        //                    System.out.print ("leaf cache full");        //                }        //            else  if (table[i] instanceof IDTableNodeBranch){        //                if (branchCache.count() < MAX_CACHE_SIZE) {        //                    System.out.print ("branch cached");        //                    branchCache.pushTop (table[i]);        //                    table[i].empty();        //                    table[i] = null;        //                    }        //                else        //                    System.out.print ("branch cache full");        //                }        //            else {        //                throw new RuntimeException ("Unknown node type.");        //                }        //            }                super.deleteRequest( subTable );    }     }

⌨️ 快捷键说明

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