KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > core > storage > wizardStore > WizardTransaction


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Core License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id$
8

9 package org.ozoneDB.core.storage.wizardStore;
10
11 import org.ozoneDB.DxLib.DxDeque;
12 import org.ozoneDB.DxLib.DxHashMap;
13 import org.ozoneDB.DxLib.DxListDeque;
14 import org.ozoneDB.DxLib.DxMap;
15 import org.ozoneDB.DxLib.DxSet;
16 import org.ozoneDB.core.Env;
17 import org.ozoneDB.core.Transaction;
18 import org.ozoneDB.core.TransactionID;
19 import org.ozoneDB.core.User;
20 import org.ozoneDB.core.storage.wizardStore.IDTableChange;
21 import org.ozoneDB.core.storage.wizardStore.NameTableChange;
22 import org.ozoneDB.core.storage.ClusterID;
23
24 /**
25  * @version $Id $
26  */

27 public class WizardTransaction extends Transaction {
28     
29     public final static int DEFAULT_TABLE_SIZE = 1024;
30
31     protected ClusterID lrucid;
32
33     protected DxMap idTable;
34
35     // initialized by WizardStore.nameContainer() if needed
36
protected DxMap nameTable;
37
38     protected DxSet commitClusterIDs;
39
40     private DxDeque idTableChanges;
41
42     private DxDeque nameTableChanges;
43
44     public WizardTransaction(Env env, User owner) {
45         super(env, owner);
46         idTable = new DxHashMap(DEFAULT_TABLE_SIZE);
47     }
48
49     /**
50      * Construct a new transaction. THIS TRANSACTION CAN BE USED FOR TESTING
51      * ONLY!
52      */

53     public WizardTransaction(TransactionID _taID) {
54         super(_taID);
55         idTable = new DxHashMap(DEFAULT_TABLE_SIZE);
56     }
57
58
59     public void nameTableChanges_push(NameTableChange change) {
60         if (nameTableChanges == null) {
61             nameTableChanges = new DxListDeque(/*DEFAULT_TABLE_SIZE*/);
62         }
63         nameTableChanges.pushTop(change);
64     }
65
66
67     public NameTableChange nameTableChanges_pop() {
68         return nameTableChanges != null ? (NameTableChange) nameTableChanges.popBottom() : null;
69     }
70
71
72     public void idTableChanges_push(IDTableChange change) {
73         if (idTableChanges == null) {
74             idTableChanges = new DxListDeque(/*DEFAULT_TABLE_SIZE*/);
75         }
76         idTableChanges.pushTop(change);
77     }
78
79
80     public IDTableChange idTableChanges_pop() {
81         return idTableChanges != null ? (IDTableChange) idTableChanges.popBottom() : null;
82     }
83
84 }
85
Popular Tags