From: Bryan T. <tho...@us...> - 2007-03-06 20:38:11
|
Update of /cvsroot/cweb/bigdata/src/test/com/bigdata/objndx In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv23960/src/test/com/bigdata/objndx Modified Files: TestIndexSegmentMerger.java Log Message: Refactoring to introduce asynchronous handling of overflow events in support of a scale-up/scale-out design. Index: TestIndexSegmentMerger.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/objndx/TestIndexSegmentMerger.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestIndexSegmentMerger.java 7 Feb 2007 13:44:52 -0000 1.3 --- TestIndexSegmentMerger.java 6 Mar 2007 20:38:06 -0000 1.4 *************** *** 54,58 **** /** ! * Test suite for compacting merge of index segments (really, of two B+-Trees). * * @todo write tests where the keys do not overlap (done). --- 54,58 ---- /** ! * Test suite for compacting merge of B+-Trees. * * @todo write tests where the keys do not overlap (done). *************** *** 60,63 **** --- 60,67 ---- * @todo write tests where the keys overlap but there are no conflicts. * + * @todo write tests: merging a tree with itself, merging trees w/o deletion + * markers, merging trees w/ deletion markers, merging trees w/ age-based + * version expiration, merging trees with count-based version expiration. + * * @todo write tests where there are keys that conflict. conflicts need to be * resolved according to some policy, and there are a variety of policies *************** *** 101,104 **** --- 105,121 ---- /** + * Return the temporary directory. + */ + static synchronized protected File getTempDir() { + + File tmpDir = new File(System.getProperty("java.io.tmpdir")); + + assertTrue(!tmpDir.exists() || tmpDir.mkdirs()); + + return tmpDir; + + } + + /** * Test builds two btrees, populates them with disjoint key ranges (1-10 * and 11-20), and then merges their entries. *************** *** 124,153 **** } - File outFile = new File( getName()+".merge"); - - if(outFile.exists() && ! outFile.delete() ) { - - throw new AssertionError("Could not delete test file: " - + outFile.getAbsoluteFile()); - - } - // branching factor used by leaves emitted by the merge process. final int m = 3; ! IndexSegmentMerger merger = new IndexSegmentMerger(outFile, m, btree1, ! btree2); - /* - * FIXME nothing is really defined until this operation so maybe it - * makes sense to have the "merger" be an iterator backed by a file - * whose contents are eagerly generated when the source btrees are large (> - * X MB) and buffered in a simple in-memory leaf data structure when - * they are small. The only real reason to go to an external file to - * buffer the contents is that we may have to merge index segments that - * are larger than we would like. Actually, another reason is that we - * could produce multiple merged file segments if there was a need to - * split the index during the merge operation. - */ MergedLeafIterator itr = merger.merge(); --- 141,149 ---- } // branching factor used by leaves emitted by the merge process. final int m = 3; ! IndexSegmentMerger merger = new IndexSegmentMerger(m, btree1, btree2); MergedLeafIterator itr = merger.merge(); *************** *** 180,193 **** assertEquals(20,entryIndex); - // close the iterator and delete the backing file (if any). - itr.close(); - - // @todo consider adding a rewind() method to the iterator. - /* ! * @todo build an index segment from the merged entries and validate its ! * contents. */ ! } --- 176,185 ---- assertEquals(20,entryIndex); /* ! * Verify that the tmpStore was closed. The backing file (if any) is ! * deleted when the tmpStore is closed. */ ! assertFalse(itr.tmpStore.isOpen()); ! } *************** *** 224,241 **** assertEquals("btree2.nentries", 10, btree2.getEntryCount()); - File outFile = new File( getName()+".merge"); - - if(outFile.exists() && ! outFile.delete() ) { - - throw new AssertionError("Could not delete test file: " - + outFile.getAbsoluteFile()); - - } - // branching factor used by leaves emitted by the merge process. final int m = 3; ! IndexSegmentMerger merger = new IndexSegmentMerger(outFile, m, btree1, ! btree2); MergedLeafIterator itr = merger.merge(); --- 216,223 ---- assertEquals("btree2.nentries", 10, btree2.getEntryCount()); // branching factor used by leaves emitted by the merge process. final int m = 3; ! IndexSegmentMerger merger = new IndexSegmentMerger(m, btree1, btree2); MergedLeafIterator itr = merger.merge(); *************** *** 269,281 **** assertEquals(20,entryIndex); - // close the iterator and delete the backing file (if any). - itr.close(); - - // @todo consider adding a rewind() method to the iterator. - /* ! * @todo build an index segment from the merged entries and validate its ! * contents. */ } --- 251,259 ---- assertEquals(20,entryIndex); /* ! * Verify that the tmpStore was closed. The backing file (if any) is ! * deleted when the tmpStore is closed. */ + assertFalse(itr.tmpStore.isOpen()); } |