@Override public final void close() throws HyracksDataException { if (ENFORCE_OPEN_CLOSE_DESTROY) { if (state == State.CLOSED) { return; } else if (state == State.DESTROYED) { throw new IllegalStateException("Cannot close a cursor in the state " + state); } } state = State.CLOSED; doClose(); }
@Override public final ITupleReference getTuple() { if (state == State.OPENED) { return doGetTuple(); } else { return null; } }
@Override public final boolean hasNext() throws HyracksDataException { if (ENFORCE_NEXT_HAS_NEXT && state != State.OPENED) { throw new IllegalStateException("Cannot call hasNext() on a cursor in the state " + state); } return doHasNext(); }
@Override public final void next() throws HyracksDataException { if (ENFORCE_NEXT_HAS_NEXT && state != State.OPENED) { throw new IllegalStateException("Cannot call next() on a cursor in the state " + state); } doNext(); }
@Override public final void open(ICursorInitialState initialState, ISearchPredicate searchPred) throws HyracksDataException { if (ENFORCE_OPEN_CLOSE_DESTROY && state != State.CLOSED) { if (STORE_TRACES && destroyCallStack != null) { LOGGER.log(Level.WARN, "The cursor was destroyed in " + Arrays.toString(destroyCallStack)); } throw new IllegalStateException("Cannot open a cursor in the state " + state); } doOpen(initialState, searchPred); state = State.OPENED; if (STORE_TRACES) { openCallStack = new Throwable().getStackTrace(); } }
@Override public final void destroy() throws HyracksDataException { if (ENFORCE_OPEN_CLOSE_DESTROY) { if (state == State.DESTROYED) { return; } else if (state != State.CLOSED) { if (STORE_TRACES && openCallStack != null) { LOGGER.log(Level.WARN, "The cursor was opened in " + Arrays.toString(openCallStack)); } throw new IllegalStateException("Cannot destroy a cursor in the state " + state); } } state = State.DESTROYED; try { doDestroy(); } finally { if (ENFORCE_OPEN_CLOSE_DESTROY && STORE_TRACES) { destroyCallStack = new Throwable().getStackTrace(); } } }