1 package com.daffodilwoods.daffodildb.server.datasystem.persistentsystem; 2 3 import java.text.*; 4 import java.util.*; 5 6 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.*; 7 import com.daffodilwoods.daffodildb.server.datasystem.interfaces.Utility; 8 import com.daffodilwoods.daffodildb.server.datasystem.utility.*; 9 import com.daffodilwoods.daffodildb.utils.*; 10 import com.daffodilwoods.daffodildb.utils.byteconverter.*; 11 import com.daffodilwoods.daffodildb.utils.field.*; 12 import com.daffodilwoods.database.resource.*; 13 import com.daffodilwoods.database.utility.*; 14 15 19 public class TableCharacteristics implements _TableCharacteristics,Datatype{ 20 21 24 private String [] columnNames; 25 26 29 private CbCzufIboemfs [] byteHandler; 30 31 34 private int[] columnTypes; 35 36 39 private int [] columnSizes; 40 41 44 private int columnCount; 45 46 49 private boolean[] blobClob; 50 53 private boolean [] isFixedColumn; 54 55 58 private ArrayList blobClobList; 59 60 private Collator collator; 61 64 private int[] startAddrsesses; 65 66 public TableCharacteristics(String [] columnNames1,int [] columnTypes1,int [] columnSizes1,boolean[] blobClob0,ArrayList blobClobList0,boolean [] fixedColumn0,int[] startAddrsesses0) { 67 columnNames = columnNames1; 68 columnTypes = columnTypes1; 69 columnSizes = columnSizes1; 70 columnCount = columnNames.length; 71 blobClob = blobClob0; 72 blobClobList = blobClobList0; 73 isFixedColumn = fixedColumn0; 74 startAddrsesses = startAddrsesses0; 75 } 76 82 public boolean isBlobClob(int index) { 83 return blobClob[index]; 84 } 85 89 Object [][] columnInfo ; 90 91 public TableCharacteristics(String [] columnNames1,int [] columnTypes1,int [] columnSizes1) throws DException{ 92 columnNames = columnNames1; 93 columnTypes = columnTypes1; 94 columnSizes = columnSizes1; 95 columnCount = columnNames.length; 96 byteHandler = new CbCzufIboemfs[columnCount]; 97 for(int i = 0 ; i < columnCount ; i++ ) 98 byteHandler[i] = ByteHandler.getByteHandler(columnTypes[i],columnSizes[i],null); 99 columnInfo = new Object [columnCount][4]; 100 for( int i = 0 ; i < columnCount ; i++ ){ 101 columnInfo[i][0] = columnNames[i]; 102 columnInfo[i][1] = new Long (columnTypes[i]); 103 columnInfo[i][2] = new Long (columnSizes[i]); 104 columnInfo[i][3] = new Long (i); 105 } 106 int len = columnTypes.length; 107 isFixedColumn = new boolean[len]; 108 for (int i = 0; i < len; i++) { 109 isFixedColumn[i] = Utility.isFixed(columnTypes[i]); 110 } 111 } 112 117 public Object getColumnInformation() { 118 ColumnInformation ci = new ColumnInformation(); 119 if(columnInfo == null){ 120 columnInfo = new Object [columnCount][4]; 121 for( int i = 0 ; i < columnCount ; i++ ){ 122 columnInfo[i][0] = columnNames[i]; 123 columnInfo[i][1] = new Long (columnTypes[i]); 124 columnInfo[i][2] = new Integer (columnSizes[i]); 125 columnInfo[i][3] = new Long (i); 126 } 127 } 128 ci.setObjects(columnInfo); 129 return ci; 130 } 131 132 133 137 public int getColumnCount() { 138 return columnCount; 139 } 140 141 145 public String [] getColumnNames() { 146 return columnNames; 147 } 148 152 public int[] getColumnSizes(){ 153 return columnSizes; 154 } 155 159 public int[] getColumnTypes() { 160 return columnTypes; 161 } 162 163 164 public int getMemoryUsage(Object [] values){ 165 int memoryUsage = 0 ; 166 return memoryUsage ; 167 } 168 169 178 179 public int getIndexForColumnName(String columnName) throws DException{ 180 for(int i = 0,len = columnNames.length ; i < len ; i++) 181 if( columnName.equalsIgnoreCase(columnNames[i])) 182 return i; 183 throw new DException("DSE256",new Object [] {columnName}); 184 } 185 186 public String toString() { 187 return " columnNames == "+P.print(columnNames)+" columnNames == "+P.print(columnSizes)+" columnNames == "+P.print(columnTypes)+" HashCode == "+hashCode(); 188 } 189 190 198 199 public int[] getColumnTypes(int[] indexes) { 200 int len = indexes.length; 201 int[] types = new int[len]; 202 for(int i = 0; i < len ; i++) 203 types[i] = columnTypes[indexes[i]]; 204 return types; 205 } 206 210 public int getColumnType(int index) { 211 return columnTypes[index]; 212 } 213 217 public int isBlobClobTable(){ 218 return blobClobList.size(); 219 } 220 221 222 223 229 public boolean isFixedColumn(int index){ 230 return isFixedColumn[index]; 231 } 232 235 public int getColumnSize(int index){ 236 return columnSizes[index]; 237 } 238 242 public CbCzufIboemfs getHandler(int index){ 243 return byteHandler[index]; 244 } 245 246 252 253 public Object getObject(int columnIndex,BufferRange bytes)throws DException{ 254 try{ 255 return byteHandler[columnIndex].getObject(bytes,columnTypes[columnIndex]); 256 }catch(Exception ex) { 257 throw new RuntimeException (" <<<<<<<<<<<<<<<<< CHECK THE PROBLEM >>>>>>>>>>>>>>>>>> "+hashCode()); 258 } 259 } 260 261 266 267 public Object getObject(BufferRange[] bytes)throws DException { 268 int len = bytes.length ; 269 Object [] values = new Object [len]; 270 for(int i = 0 ; i < len ; i++) 271 values[i] = getObject(i,bytes[i]); 272 return values; 273 } 274 275 281 282 public Object getObject(int[] columns,BufferRange[] bytes)throws DException{ 283 int len = columns.length; 284 Object [] values = new Object [len]; 285 for(int i = 0 ; i < len ; i++) 286 values[i] = getObject(columns[i],bytes[i]); 287 return values; 288 } 289 297 public BufferRange getBufferRange(int columnIndex, Object values) throws DException { 298 return ((FieldBase)values).getBufferRange(); 299 } 300 308 public BufferRange[] getBufferRange(int[] columnIndexes, Object [] values) throws DException { 309 int len = values.length ; 310 BufferRange[] columnBytes = new BufferRange[len]; 311 for(int i = 0 ; i < len ; i++) 312 columnBytes[i] = ((FieldBase)values[i]).getBufferRange(); 313 return columnBytes; 314 } 315 322 323 public BufferRange[] getBufferRange(Object [] values) throws DException { 324 int len = values.length ; 325 BufferRange[] columnBytes = new BufferRange[len]; 326 for(int i = 0 ; i < len ; i++) 327 columnBytes[i] = ((FieldBase)values[i]).getBufferRange(); 328 return columnBytes; 329 } 330 335 public void setCollator(Collator collator0) throws DException{ 336 collator = collator0; 337 byteHandler = new CbCzufIboemfs[columnCount]; 338 for(int i = 0 ; i < columnCount ; i++ ) 339 byteHandler[i] = ByteHandler.getByteHandler(columnTypes[i],columnSizes[i],collator); 340 } 341 344 public Collator getCollator() { 345 return collator; 346 } 347 350 public int[] getStartAddressesOfBlobColumns() { 351 return startAddrsesses; 352 } 353 } 354 | Popular Tags |