@Override public void doDestroy() throws HyracksDataException { btreeCursor.destroy(); }
@Override public void destroy() throws HyracksDataException { if (destroyed) { return; } destroyed = true; try { btreeAccessor.destroy(); } finally { btreeCursor.destroy(); } }
@Override public void doDestroy() throws HyracksDataException { try { super.doDestroy(); } finally { if (deletedKeysBTreeCursors != null) { for (int i = 0; i < deletedKeysBTreeCursors.length; i++) { deletedKeysBTreeCursors[i].destroy(); } deletedKeysBTreeCursors = null; } } }
@Override public void doDestroy() throws HyracksDataException { try { invListRangeSearchCursor.destroy(); isInvListCursorOpen = false; } finally { btreeCursor.destroy(); } }
@Test public void testDoubleDestroySucceeds() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); List<ISearchPredicate> predicates = createSearchPredicates(); open(accessor, cursor, predicates.get(0)); cursor.close(); cursor.destroy(); cursor.destroy(); destroy(accessor); }
@Test public void testCreateDestroySucceed() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); cursor.destroy(); destroy(accessor); }
@Test public void testDestroyWhileOpenFails() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); List<ISearchPredicate> predicates = createSearchPredicates(); open(accessor, cursor, predicates.get(0)); boolean expectedExceptionThrown = false; try { cursor.destroy(); } catch (Exception e) { expectedExceptionThrown = true; } cursor.close(); cursor.destroy(); destroy(accessor); Assert.assertTrue(expectedExceptionThrown); }
@Test public void testCloseWithoutOpenSucceeds() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); cursor.close(); cursor.destroy(); destroy(accessor); }
@Test public void testDoubleCloseSucceeds() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); List<ISearchPredicate> predicates = createSearchPredicates(); open(accessor, cursor, predicates.get(0)); cursor.close(); cursor.close(); cursor.destroy(); destroy(accessor); }
@Test public void testGetTupleReturnsNullAfterDestroy() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); List<ISearchPredicate> predicates = createSearchPredicates(); open(accessor, cursor, predicates.get(0)); cursor.close(); cursor.destroy(); destroy(accessor); Assert.assertNull(cursor.getTuple()); }
@Test public void testDoubleOpenFails() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); List<ISearchPredicate> predicates = createSearchPredicates(); open(accessor, cursor, predicates.get(0)); boolean expectedExceptionThrown = false; try { open(accessor, cursor, predicates.get(0)); } catch (Exception e) { expectedExceptionThrown = true; } cursor.close(); cursor.destroy(); destroy(accessor); Assert.assertTrue(expectedExceptionThrown); }
@Test public void testOpenAfterDestroyFails() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); List<ISearchPredicate> predicates = createSearchPredicates(); open(accessor, cursor, predicates.get(0)); cursor.close(); cursor.destroy(); boolean expectedExceptionThrown = false; try { open(accessor, cursor, predicates.get(0)); } catch (Exception e) { expectedExceptionThrown = true; } destroy(accessor); Assert.assertTrue(expectedExceptionThrown); }
@Test public void testHasNextBeforeOpenFails() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); boolean expectedExceptionThrown = false; try { cursor.hasNext(); } catch (Exception e) { expectedExceptionThrown = true; } cursor.destroy(); destroy(accessor); Assert.assertTrue(expectedExceptionThrown); }
@Test public void testNextBeforeOpenFails() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); boolean expectedExceptionThrown = false; try { cursor.next(); } catch (Exception e) { expectedExceptionThrown = true; } cursor.destroy(); destroy(accessor); Assert.assertTrue(expectedExceptionThrown); }
@Test public void testHasNextAfterCloseFails() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); List<ISearchPredicate> predicates = createSearchPredicates(); open(accessor, cursor, predicates.get(0)); cursor.close(); boolean expectedExceptionThrown = false; try { cursor.hasNext(); } catch (Exception e) { expectedExceptionThrown = true; } cursor.destroy(); destroy(accessor); Assert.assertTrue(expectedExceptionThrown); }
@Test public void testNextAfterCloseFails() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); List<ISearchPredicate> predicates = createSearchPredicates(); open(accessor, cursor, predicates.get(0)); cursor.close(); boolean expectedExceptionThrown = false; try { cursor.next(); } catch (Exception e) { expectedExceptionThrown = true; } cursor.destroy(); destroy(accessor); Assert.assertTrue(expectedExceptionThrown); }
@Test public void testHasNextAfterDestroyFails() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); List<ISearchPredicate> predicates = createSearchPredicates(); open(accessor, cursor, predicates.get(0)); cursor.close(); cursor.destroy(); boolean expectedExceptionThrown = false; try { cursor.hasNext(); } catch (Exception e) { expectedExceptionThrown = true; } destroy(accessor); Assert.assertTrue(expectedExceptionThrown); }
@Test public void testCloseAfterDestroyFails() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); List<ISearchPredicate> predicates = createSearchPredicates(); open(accessor, cursor, predicates.get(0)); cursor.close(); cursor.destroy(); boolean expectedExceptionThrown = false; try { cursor.close(); } catch (Exception e) { expectedExceptionThrown = true; } destroy(accessor); Assert.assertTrue(expectedExceptionThrown); }
@Test public void testNextAfterDestroyFails() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); List<ISearchPredicate> predicates = createSearchPredicates(); open(accessor, cursor, predicates.get(0)); cursor.close(); cursor.destroy(); boolean expectedExceptionThrown = false; try { cursor.next(); } catch (Exception e) { expectedExceptionThrown = true; } destroy(accessor); Assert.assertTrue(expectedExceptionThrown); }
@Test public void testNormalLifeCycle() throws Exception { IIndexAccessor accessor = createAccessor(); IIndexCursor cursor = createCursor(accessor); List<ISearchPredicate> predicates = createSearchPredicates(); for (ISearchPredicate predicate : predicates) { open(accessor, cursor, predicate); while (cursor.hasNext()) { cursor.next(); } cursor.close(); } cursor.destroy(); destroy(accessor); }