comparison src/org/tmatesoft/hg/internal/RevlogStream.java @ 217:e39cf474ef94

Experimental support to mix-in start and end events for inspectors. Additionally, Lifecycle may serve as iteration control
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Tue, 17 May 2011 03:40:52 +0200
parents 706bcc7cfee4
children 80a3433ace91
comparison
equal deleted inserted replaced
216:c251bbc979cf 217:e39cf474ef94
198 if (end < start || end >= indexSize) { 198 if (end < start || end >= indexSize) {
199 throw new IllegalArgumentException(String.format("Bad right range boundary %d in [0..%d]", end, indexSize-1)); 199 throw new IllegalArgumentException(String.format("Bad right range boundary %d in [0..%d]", end, indexSize-1));
200 } 200 }
201 // XXX may cache [start .. end] from index with a single read (pre-read) 201 // XXX may cache [start .. end] from index with a single read (pre-read)
202 202
203 Lifecycle.BasicCallback cb = null;
203 DataAccess daIndex = null, daData = null; 204 DataAccess daIndex = null, daData = null;
204 daIndex = getIndexStream(); 205 daIndex = getIndexStream();
205 if (needData && !inline) { 206 if (needData && !inline) {
206 daData = getDataStream(); 207 daData = getDataStream();
207 } 208 }
216 } else { 217 } else {
217 i = start; 218 i = start;
218 } 219 }
219 220
220 daIndex.seek(getIndexOffsetInt(i)); 221 daIndex.seek(getIndexOffsetInt(i));
222
223 if (inspector instanceof Lifecycle) {
224 cb = new Lifecycle.BasicCallback();
225 ((Lifecycle) inspector).start(end - start + 1, cb, cb);
226 }
227
221 for (; i <= end; i++ ) { 228 for (; i <= end; i++ ) {
222 if (inline && needData) { 229 if (inline && needData) {
223 // inspector reading data (though FilterDataAccess) may have affected index position 230 // inspector reading data (though FilterDataAccess) may have affected index position
224 daIndex.seek(getIndexOffsetInt(i)); 231 daIndex.seek(getIndexOffsetInt(i));
225 } 232 }
280 } 287 }
281 } 288 }
282 if (!extraReadsToBaseRev || i >= start) { 289 if (!extraReadsToBaseRev || i >= start) {
283 inspector.next(i, actualLen, baseRevision, linkRevision, parent1Revision, parent2Revision, nodeidBuf, userDataAccess); 290 inspector.next(i, actualLen, baseRevision, linkRevision, parent1Revision, parent2Revision, nodeidBuf, userDataAccess);
284 } 291 }
292 if (cb != null) {
293 if (cb.isStopped()) {
294 break;
295 }
296 }
285 if (userDataAccess != null) { 297 if (userDataAccess != null) {
286 userDataAccess.reset(); 298 userDataAccess.reset();
287 if (lastUserData != null) { 299 if (lastUserData != null) {
288 lastUserData.done(); 300 lastUserData.done();
289 } 301 }
291 } 303 }
292 } 304 }
293 } catch (IOException ex) { 305 } catch (IOException ex) {
294 throw new HgBadStateException(ex); // FIXME need better handling 306 throw new HgBadStateException(ex); // FIXME need better handling
295 } finally { 307 } finally {
308 if (inspector instanceof Lifecycle) {
309 ((Lifecycle) inspector).finish(cb);
310 }
296 daIndex.done(); 311 daIndex.done();
297 if (daData != null) { 312 if (daData != null) {
298 daData.done(); 313 daData.done();
299 } 314 }
300 } 315 }