Package org.ozoneDB.core.wizardStore

Source Code of org.ozoneDB.core.wizardStore.IDTableNodeLeaf

// 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: IDTableNodeLeaf.java,v 1.1 2001/12/18 10:31:31 per_nyfelt Exp $

package org.ozoneDB.core.wizardStore;

import java.io.*;
import org.ozoneDB.DxLib.*;
import org.ozoneDB.core.ObjectID;


/**
* This extension of the DxDiskHashNodeLeaf class assumes that the key and data
* member of the stored DxKayData pairs are ObjectIDs. Thus is casts and writes
* them directly to the stream for better performance.
*/
class IDTableNodeLeaf extends DxDiskHashNodeLeaf implements Externalizable {
   
    final static long serialVersionUID = 1L;
   
   
    public IDTableNodeLeaf( DxDiskHashMap _grandParent ) {
        super( _grandParent );
    }
   
   
    public void writeExternal( ObjectOutput out ) throws IOException {
        byte c = 0;
        for (DxKeyData elem = element; elem != null; elem = elem.next) {
            c++;
        }
        out.writeByte( c );
       
        DxKeyData elem = element;
        while (elem != null) {
            ((ObjectID)elem.key).writeExternal( out );
            ((ObjectID)elem.data).writeExternal( out );
            elem = elem.next;
        }
    }
   
   
    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException {
        byte c = in.readByte();
       
        ObjectID key = ((IDTable)grandParent).newObjectID();
        key.readExternal( in );
        ClusterID data = ((IDTable)grandParent).newClusterID();
        data.readExternal( in );
        element = grandParent.newKeyData();
        element.set( key, data );
       
        DxKeyData elem = element;
        for (int i = 1; i < c; i++) {
            key = ((IDTable)grandParent).newObjectID();
            key.readExternal( in );
            data = ((IDTable)grandParent).newClusterID();
            data.readExternal( in );
            elem.next = ((IDTable)grandParent).newKeyData();
            elem.next.set( key, data );
            elem = elem.next;
        }
    }
}
TOP

Related Classes of org.ozoneDB.core.wizardStore.IDTableNodeLeaf

TOP
Copyright © 2018 www.massapi.com. 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.