1 24 25 package com.mckoi.database; 26 27 import com.mckoi.store.*; 28 import java.io.IOException ; 29 import java.util.HashMap ; 30 31 37 38 class V1HeapStoreSystem implements StoreSystem { 39 40 43 private HashMap name_store_map; 44 45 48 private HashMap store_name_map; 49 50 51 54 V1HeapStoreSystem() { 55 name_store_map = new HashMap (); 56 store_name_map = new HashMap (); 57 } 58 59 60 public boolean storeExists(String name) { 61 return (name_store_map.get(name) != null); 62 } 63 64 public Store createStore(String name) { 65 if (!storeExists(name)) { 66 HeapStore store = new HeapStore(); 67 name_store_map.put(name, store); 68 store_name_map.put(store, name); 69 return store; 70 } 71 else { 72 throw new RuntimeException ("Store exists: " + name); 73 } 74 } 75 76 public Store openStore(String name) { 77 HeapStore store = (HeapStore) name_store_map.get(name); 78 if (store == null) { 79 throw new RuntimeException ("Store does not exist: " + name); 80 } 81 return store; 82 } 83 84 public boolean closeStore(Store store) { 85 if (store_name_map.get(store) == null) { 86 throw new RuntimeException ("Store does not exist."); 87 } 88 return true; 89 } 90 91 public boolean deleteStore(Store store) { 92 String name = (String ) store_name_map.remove(store); 93 name_store_map.remove(name); 94 return true; 95 } 96 97 public void setCheckPoint() { 98 } 100 101 103 public void lock(String lock_name) throws IOException { 104 } 107 108 public void unlock(String lock_name) throws IOException { 109 } 112 113 } 114 115 | Popular Tags |