クラス org.objectweb.cjdbc.controller.cache.metadata.MetadataCache

すべてのメンバ一覧

説明

This class implements a ResultSet metadata cache.

ResultSet Fields are kept here to prevent recomputing them and allocating them each time a query is executed.

作者:
Emmanuel Cecchet
バージョン:
1.0

MetadataCache.java43 行で定義されています。

Public メソッド

 MetadataCache (int maxNbOfMetadata, int maxNbOfField)
Field[] getMetadata (AbstractRequest request)
void addMetadata (AbstractRequest request, Field[] metadata)
Field getField (String columnName)
void addField (String columnName, Field field)
String getXml ()

Private 変数

Hashtable metadataCache
Hashtable fieldCache
int maxNbOfMetadata
int maxNbOfField


コンストラクタとデストラクタ

org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.MetadataCache int  maxNbOfMetadata,
int  maxNbOfField
 

Constructor for MetadataCache.

引数:
maxNbOfMetadata maximum nb of entries in metadata cache
maxNbOfField maximum nb of entries in field cache
MetadataCache.java56 行で定義されています。

参照先 org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.fieldCache, と org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.metadataCache.

00057 { 00058 metadataCache = new Hashtable(maxNbOfMetadata == 0 00059 ? 10000 00060 : maxNbOfMetadata); 00061 fieldCache = new Hashtable(maxNbOfField == 0 ? 100 : maxNbOfField); 00062 if (maxNbOfMetadata < 0) 00063 throw new RuntimeException(Translate.get("cache.metadata.invalid.size", 00064 maxNbOfMetadata)); 00065 if (maxNbOfMetadata == 0) 00066 this.maxNbOfMetadata = Integer.MAX_VALUE; 00067 else 00068 this.maxNbOfMetadata = maxNbOfMetadata; 00069 if (maxNbOfField < 0) 00070 throw new RuntimeException(Translate.get("cache.metadata.invalid.size", 00071 maxNbOfField)); 00072 if (maxNbOfField == 0) 00073 this.maxNbOfField = Integer.MAX_VALUE; 00074 else 00075 this.maxNbOfField = maxNbOfField; 00076 }


メソッド

void org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.addField String  columnName,
Field  field
 

Add a Field entry to the cache and associate it to the given column name.

引数:
columnName column name to which the Field belong
field field to cache
MetadataCache.java151 行で定義されています。

参照先 org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.fieldCache, と org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.maxNbOfField.

00152 { 00153 // Note that the underlying cache Hashtable is synchronized and we usually 00154 // do not need to synchronize on it. 00155 // As we will have to add a cache entry, check if the cache size is ok 00156 // else remove the first entry of the hashtable. 00157 while (fieldCache.size() > maxNbOfField) 00158 { // Remove first entry from Hashtable. We need to synchronize here to be 00159 // sure that we are not trying to concurrently remove the first cache 00160 // entry. 00161 synchronized (fieldCache) 00162 { 00163 try 00164 { 00165 fieldCache.remove(fieldCache.keys().nextElement()); 00166 } 00167 catch (Exception ignore) 00168 { 00169 break; 00170 } 00171 } 00172 } 00173 // Add to cache 00174 fieldCache.put(columnName, field); 00175 }

void org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.addMetadata AbstractRequest  request,
Field[]  metadata
 

Add a metadata entry to the cache and associate it to the given request.

引数:
request request to which the metadata belong
metadata metadata to cache
MetadataCache.java101 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.AbstractRequest.getSQL(), org.objectweb.cjdbc.common.sql.AbstractRequest.getSqlSkeleton(), org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.maxNbOfMetadata, と org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.metadataCache.

00102 { 00103 // Note that the underlying cache Hashtable is synchronized and we usually 00104 // do not need to synchronize on it. 00105 // As we will have to add a cache entry, check if the cache size is ok 00106 // else remove the first entry of the hashtable. 00107 while (metadataCache.size() > maxNbOfMetadata) 00108 { // Remove first entry from Hashtable. We need to synchronize here to be 00109 // sure that we are not trying to concurrently remove the first cache 00110 // entry. 00111 synchronized (metadataCache) 00112 { 00113 try 00114 { 00115 metadataCache.remove(metadataCache.keys().nextElement()); 00116 } 00117 catch (Exception ignore) 00118 { 00119 break; 00120 } 00121 } 00122 } 00123 00124 // Add to cache 00125 String sqlSkeleton = request.getSqlSkeleton(); 00126 if (sqlSkeleton != null) 00127 metadataCache.put(sqlSkeleton, metadata); 00128 else 00129 metadataCache.put(request.getSQL(), metadata); 00130 }

Field org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.getField String  columnName  ) 
 

Get the field corresponding to a column name.

Returns null if the cache contains no field for the given name.

引数:
columnName the column name to look for
戻り値:
the corresponding Field or null if not in cache
MetadataCache.java140 行で定義されています。

参照先 org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.fieldCache.

00141 { 00142 return (Field) fieldCache.get(columnName); 00143 }

Field [] org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.getMetadata AbstractRequest  request  ) 
 

Get metadata associated to a request.

Returns null if the cache contains no metadata for the given request.

引数:
request the request we look for
戻り値:
the metadata or null if not in cache
MetadataCache.java86 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.AbstractRequest.getSQL(), org.objectweb.cjdbc.common.sql.AbstractRequest.getSqlSkeleton(), と org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.metadataCache.

00087 { 00088 String sqlSkeleton = request.getSqlSkeleton(); 00089 if (sqlSkeleton != null) 00090 return (Field[]) metadataCache.get(sqlSkeleton); 00091 else 00092 return (Field[]) metadataCache.get(request.getSQL()); 00093 }

String org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.getXml  ) 
 

Get xml information about this ParsingCache

戻り値:
String in xml formatted text
MetadataCache.java182 行で定義されています。

参照先 org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.maxNbOfField, と org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.maxNbOfMetadata.

00183 { 00184 return "<" + DatabasesXmlTags.ELT_MetadataCache + " " 00185 + DatabasesXmlTags.ATT_maxNbOfMetadata + "=\"" + maxNbOfMetadata 00186 + "\" " + DatabasesXmlTags.ATT_maxNbOfField + "=\"" + (maxNbOfField == Integer.MAX_VALUE ? 0 : maxNbOfField) 00187 + "\"/>"; 00188 }


変数

Hashtable org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.fieldCache [private]
 

MetadataCache.java46 行で定義されています。

参照元 org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.addField(), org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.getField(), と org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.MetadataCache().

int org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.maxNbOfField [private]
 

MetadataCache.java48 行で定義されています。

参照元 org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.addField(), と org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.getXml().

int org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.maxNbOfMetadata [private]
 

MetadataCache.java47 行で定義されています。

参照元 org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.addMetadata(), と org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.getXml().

Hashtable org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.metadataCache [private]
 

MetadataCache.java45 行で定義されています。

参照元 org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.addMetadata(), org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.getMetadata(), と org.objectweb.cjdbc.controller.cache.metadata.MetadataCache.MetadataCache().


このクラスの説明は次のファイルから生成されました:
CJDBCversion1.0.4に対してTue Oct 12 15:16:36 2004に生成されました。 doxygen 1.3.8