@Override protected void jumpToItem(int itemIndex) throws Exception { super.jumpToItem(rowsToSkip + itemIndex); }
@Override public void write(List<? extends T> items) throws Exception { for (T item : items) { if (item instanceof ItemIndexAware && useItemIndex) { Long index = ((ItemIndexAware) item).getIndex(); if (index != null) { jumpToItem(index.intValue()); } } if (currentItemCount < maxItemCount) { if (doWrite(item)) { currentItemCount++; } currentItemIndex++; } LOGGER.trace("[currentItemCount={}, currentItemIndex={}]", currentItemCount, currentItemIndex); } LOGGER.debug("Written {} items", items); }
@Override public void open(ExecutionContext executionContext) throws ItemStreamException { super.open(executionContext); try { doOpen(); } catch (Exception e) { throw new ItemStreamException("Failed to initialize the writer", e); } if (!isSaveState()) { return; } if (executionContext.containsKey(getExecutionContextKey(WRITE_COUNT_MAX))) { maxItemCount = executionContext.getInt(getExecutionContextKey(WRITE_COUNT_MAX)); } if (executionContext.containsKey(getExecutionContextKey(WRITE_COUNT))) { int itemCount = executionContext.getInt(getExecutionContextKey(WRITE_COUNT)); currentItemCount = itemCount; if (itemCount < maxItemCount) { try { jumpToItem(itemCount); } catch (Exception e) { throw new ItemStreamException("Could not move to stored position on restart", e); } } } }