1 21 22 package org.apache.derby.impl.store.access.conglomerate; 23 24 import org.apache.derby.iapi.reference.Property; 25 26 import org.apache.derby.iapi.services.sanity.SanityManager; 27 import org.apache.derby.iapi.services.io.Formatable; 28 import org.apache.derby.iapi.services.io.FormatIdUtil; 29 30 import org.apache.derby.iapi.error.StandardException; 31 32 import org.apache.derby.iapi.store.access.Qualifier; 33 import org.apache.derby.iapi.store.access.RowUtil; 34 import org.apache.derby.iapi.store.access.TransactionController; 35 import org.apache.derby.iapi.store.raw.ContainerHandle; 36 import org.apache.derby.iapi.store.raw.FetchDescriptor; 37 import org.apache.derby.iapi.store.raw.Page; 38 import org.apache.derby.iapi.store.raw.RawStoreFactory; 39 import org.apache.derby.iapi.store.raw.RecordHandle; 40 41 import org.apache.derby.iapi.types.DataValueDescriptor; 42 43 import org.apache.derby.iapi.services.io.FormatableBitSet; 44 45 import java.io.IOException ; 46 import java.io.ObjectInput ; 47 import java.io.ObjectOutput ; 48 49 import java.util.Hashtable ; 50 import java.util.Properties ; 51 52 59 public final class ConglomerateUtil 60 { 61 62 63 64 83 public static Properties createRawStorePropertySet( 84 Properties prop) 85 { 86 prop = createUserRawStorePropertySet(prop); 87 88 prop.put(RawStoreFactory.PAGE_REUSABLE_RECORD_ID, ""); 89 90 return(prop); 91 } 92 93 111 public static Properties createUserRawStorePropertySet( 112 Properties prop) 113 { 114 if (prop == null) 115 prop = new Properties (); 116 117 prop.put(Property.PAGE_SIZE_PARAMETER, ""); 118 prop.put(RawStoreFactory.MINIMUM_RECORD_SIZE_PARAMETER, ""); 119 prop.put(RawStoreFactory.PAGE_RESERVED_SPACE_PARAMETER, ""); 120 prop.put(RawStoreFactory.CONTAINER_INITIAL_PAGES, ""); 121 122 return(prop); 123 } 124 125 126 135 public static int[] createFormatIds( 136 DataValueDescriptor[] template) 137 { 138 139 142 int[] format_ids = new int[template.length]; 143 144 for (int i = 0; i < template.length; i++) 145 { 146 if (SanityManager.DEBUG) 147 { 148 if (template[i] == null) 149 { 150 SanityManager.THROWASSERT("row template is null for "+ 151 "column["+i+"]."); 152 } 153 if (!(template[i] instanceof Formatable)) 154 { 155 SanityManager.THROWASSERT("row template is not formatable "+ 156 "column["+i+"]. Type is "+template[i].getClass().getName()); 157 } 158 } 159 160 format_ids[i] = ((Formatable) template[i]).getTypeFormatId(); 161 } 162 163 return(format_ids); 164 } 165 166 177 public static int[] readFormatIdArray( 178 int num, 179 ObjectInput in) 180 throws IOException 181 { 182 184 int[] format_ids = new int[num]; 185 for (int i = 0; i < num; i++) 186 { 187 format_ids[i] = FormatIdUtil.readFormatIdInteger(in); 188 } 189 190 return(format_ids); 191 } 192 193 202 public static void writeFormatIdArray( 203 int[] format_id_array, 204 ObjectOutput out) 205 throws IOException 206 { 207 for (int i = 0; i < format_id_array.length; i++) 208 { 209 FormatIdUtil.writeFormatIdInteger(out, format_id_array[i]); 210 } 211 } 212 213 216 217 public static String debugPage( 218 Page page, 219 int start_slot, 220 boolean full_rh, 221 DataValueDescriptor[] template) 222 { 223 if (SanityManager.DEBUG) 224 { 225 StringBuffer string = new StringBuffer (4096); 226 227 string.append("PAGE:("); 228 string.append(page.getPageNumber()); 229 string.append(")------------------------------------------:\n"); 230 231 try 232 { 233 if (page != null) 234 { 235 int numrows = page.recordCount(); 236 237 for (int slot_no = start_slot; slot_no < numrows; slot_no++) 238 { 239 RecordHandle rh = 240 page.fetchFromSlot( 241 (RecordHandle) null, slot_no, template, 242 (FetchDescriptor) null, 243 true); 244 245 string.append( 247 page.isDeletedAtSlot(slot_no) ? "D:" : " :"); 248 249 string.append("row["); 251 string.append(slot_no); 252 string.append("](id:"); 253 string.append(rh.getId()); 254 string.append("):\t"); 255 256 if (full_rh) 259 { 260 string.append("["); 261 string.append(rh.toString()); 262 string.append("]:"); 263 } 264 265 string.append(RowUtil.toString(template)); 267 string.append("\n"); 268 } 269 270 } 272 } 273 catch (Throwable t) 274 { 275 string.append("Error encountered while building string"); 276 } 277 278 return(string.toString()); 279 } 280 else 281 { 282 return(null); 283 } 284 } 285 } 286 | Popular Tags |