1 package com.daffodilwoods.daffodildb.server.datasystem.persistentsystem; 2 3 import com.daffodilwoods.database.resource.DException; 4 import com.daffodilwoods.daffodildb.utils.BufferRange; 5 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*; 6 import java.util.*; 7 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference; 8 9 18 public class RecordBytesTableHashMap implements _TableList { 19 20 HashMap recordBytesHashMap; 21 _TableList table; 22 int CODE; 23 24 public RecordBytesTableHashMap(HashMap recordBytesHashMap1,int CODE1) { 25 recordBytesHashMap = recordBytesHashMap1; 26 CODE = CODE1; 27 } 28 29 public Object insert(_DatabaseUser user, _RecordCluster recordCluster,Object values) throws DException { 30 TableKey tableKey = (TableKey)table.insert(user,recordCluster,values); 31 Object mapKey = new Long (tableKey.getStartAddress()); 32 Object obj = recordBytesHashMap.get(mapKey); 33 ArrayList retrieveValues = obj == null ? initializeArrayList(recordCluster.getRecordCount()) 34 :(ArrayList)obj; 35 retrieveValues.set(tableKey.getRecordNumber() - 1,values); 36 if(obj == null) 37 recordBytesHashMap.put(mapKey,retrieveValues); 38 return tableKey; 39 } 40 41 public _TableList getTable() { 42 return table; 43 } 44 45 public _TableList getTable(int num) { 46 return CODE == num ? table : table.getTable(num); 47 } 48 49 public Object update(_DatabaseUser user ,_RecordCluster recordCluster,Object key, Object values) throws DException { 50 TableKey tableKey = (TableKey)table.update(user,recordCluster, key,values); 51 Object mapKey = new Long (tableKey.getStartAddress()); 52 boolean flag = recordBytesHashMap.containsKey(mapKey); 53 ArrayList retrieveValues = !flag ? initializeArrayList(recordCluster.getRecordCount()) 54 :(ArrayList)recordBytesHashMap.get(mapKey); 55 retrieveValues.set(tableKey.getRecordNumber() - 1,values); 56 if(!flag) 57 recordBytesHashMap.put(mapKey,retrieveValues); 58 return tableKey; 59 } 60 61 public Object delete(_DatabaseUser user, _RecordCluster recordCluster, Object key)throws DException { 62 TableKey tableKey = (TableKey)table.delete(user,recordCluster,key); 63 Object mapKey = new Long (tableKey.getStartAddress()); 64 boolean flag = recordBytesHashMap.containsKey(mapKey); 65 if(!flag) 66 return tableKey; 67 ArrayList retrieveValues = (ArrayList)recordBytesHashMap.get(mapKey); 68 retrieveValues.set(tableKey.getRecordNumber() - 1,null); 69 return tableKey; 70 } 71 72 public void setTable(_TableList table1){ 73 table = table1; 74 } 75 76 private ArrayList initializeArrayList(int size){ 77 ArrayList retrievedObjects = new ArrayList(size); 78 for(int i= 0; i < size ; i++) 79 retrievedObjects.add(null); 80 return retrievedObjects; 81 } 82 83 public int getColumnCount() throws DException{ 84 return table.getColumnCount(); 85 } 86 87 88 89 public TableProperties getTableProperties() throws DException{ 90 throw new java.lang.UnsupportedOperationException ("Method update() not yet implemented."); 91 } 92 93 public void checkValidity(_RecordCluster recordCluster, Object key) throws DException{ 94 table.checkValidity(recordCluster,key); 95 } 96 97 public _TableCharacteristics getTableCharacteristics() throws DException { 98 99 throw new java.lang.UnsupportedOperationException ("Method getTableCharacteristics() not yet implemented."); 100 } 101 102 public void rollBack() throws DException { 103 table.rollBack(); 104 } 105 public Object getColumnObjects(_RecordCluster recordCluster, Object key) throws DException { 106 return getColumnObjects(recordCluster,key); 107 } 108 public Object getColumnObjects(_RecordCluster recordCluster, Object key, int column) throws DException { 109 return getColumnObjects(recordCluster,key,column); 110 } 111 112 public Object getColumnValues(TableKey key,_RecordCluster cluster)throws DException{ 113 114 throw new java.lang.UnsupportedOperationException ("Method getColumnValues() not yet implemented."); 115 } 116 117 public Object getColumnValues(TableKey key,_RecordCluster cluster,int column) throws DException{ 118 119 throw new java.lang.UnsupportedOperationException ("Method getColumnValues() not yet implemented."); 120 } 121 122 public Object getColumnValues(TableKey key,_RecordCluster cluster,int[] columns) throws DException{ 123 124 throw new java.lang.UnsupportedOperationException ("Method getColumnValues() not yet implemented."); 125 } 126 127 } 128 | Popular Tags |