1 21 22 package org.apache.derby.iapi.store.raw; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 26 import org.apache.derby.iapi.store.access.Qualifier; 27 28 import org.apache.derby.iapi.services.io.FormatableBitSet; 29 30 41 42 public final class FetchDescriptor 43 { 44 45 49 private int row_length; 50 private FormatableBitSet validColumns; 51 private Qualifier[][] qualifier_list; 52 private int[] materialized_cols; 53 private int maxFetchColumnId; 54 55 private static final int ZERO_FILL_LENGTH = 100; 56 private static final int[] zero_fill_array = new int[ZERO_FILL_LENGTH]; 57 58 private int[] validColumnsArray; 61 62 66 FetchDescriptor() 67 { 68 } 69 70 public FetchDescriptor( 71 int input_row_length) 72 { 73 row_length = input_row_length; 74 } 75 76 public FetchDescriptor( 77 int input_row_length, 78 int single_valid_column_number) 79 { 80 row_length = input_row_length; 81 maxFetchColumnId = single_valid_column_number; 82 validColumnsArray = new int[maxFetchColumnId + 1]; 83 validColumnsArray[single_valid_column_number] = 1; 84 } 85 86 public FetchDescriptor( 87 int input_row_length, 88 FormatableBitSet input_validColumns, 89 Qualifier[][] input_qualifier_list) 90 { 91 row_length = input_row_length; 92 qualifier_list = input_qualifier_list; 93 94 if (qualifier_list != null) 95 { 96 materialized_cols = new int[row_length]; 97 } 98 99 setValidColumns(input_validColumns); 100 } 101 102 103 107 108 120 public final FormatableBitSet getValidColumns() 121 { 122 return(validColumns); 123 } 124 125 public final int[] getValidColumnsArray() 126 { 127 return(validColumnsArray); 128 } 129 130 public final void setValidColumns( 131 FormatableBitSet input_validColumns) 132 { 133 validColumns = input_validColumns; 134 135 setMaxFetchColumnId(); 136 137 if (validColumns != null) 138 { 139 validColumnsArray = new int[maxFetchColumnId + 1]; 140 for (int i = maxFetchColumnId; i >= 0; i--) 141 { 142 validColumnsArray[i] = ((validColumns.isSet(i)) ? 1 : 0); 143 } 144 } 145 } 146 147 164 public final Qualifier[][] getQualifierList() 165 { 166 return(qualifier_list); 167 } 168 169 170 173 public final int[] getMaterializedColumns() 174 { 175 return(materialized_cols); 176 } 177 178 179 182 public final int getMaxFetchColumnId() 183 { 184 return(maxFetchColumnId); 185 } 186 187 private final void setMaxFetchColumnId() 188 { 189 maxFetchColumnId = row_length - 1; 190 191 if (validColumns != null) 192 { 193 int vCol_length = validColumns.getLength(); 194 195 if (vCol_length < maxFetchColumnId + 1) 196 maxFetchColumnId = vCol_length - 1; 197 198 for (; maxFetchColumnId >= 0; maxFetchColumnId--) 199 { 200 if (validColumns.isSet(maxFetchColumnId)) 201 break; 202 } 203 } 204 } 205 206 209 public final void reset() 210 { 211 int[] cols = materialized_cols; 212 213 if (cols != null) 214 { 215 217 225 226 if (cols.length <= ZERO_FILL_LENGTH) 227 { 228 System.arraycopy( 230 zero_fill_array, 0, 231 cols, 0, 232 cols.length); 233 } 234 else 235 { 236 int offset = 0; 237 int howMany = cols.length; 238 239 while (howMany > 0) 240 { 241 int count = 242 howMany > zero_fill_array.length ? 243 zero_fill_array.length : howMany; 244 245 System.arraycopy( 246 zero_fill_array, 0, cols, offset, count); 247 howMany -= count; 248 offset += count; 249 } 250 } 251 } 252 } 253 } 254 | Popular Tags |