@Override public Collection<Work> createPerEntityWorks(Object entity, Serializable id, WorkType workType) { if (workType.equals(WorkType.DELETE)) { return Collections.emptySet(); } return super.createPerEntityWorks(entity, id, workType); } }
public void workApplied(Work work) { workLog.add( work ); if ( work.getType().equals( ADD ) ) { lastAddedDocumentId = (Integer) work.getId(); } }
/** * Calculates the expect number of documents in the index by replaying * the work log, taking into account deletes, add and updates * * @return index size */ public int calculateIndexSize() { Set<Serializable> added = new HashSet<>(); for ( Work work : workLog ) { if ( work.getType().equals( DELETE ) ) { added.remove( work.getId() ); } else { added.add( work.getId() ); } } return added.size(); } }
while ( work == null ) { WorkType workType = randomGenerator.oneOf( ADD, DELETE, UPDATE ); if ( workType.equals( ADD ) ) { if ( addCounter.get() > 0 ) { work = createAddWork(); if ( workType.equals( DELETE ) ) { if ( deleteCounter.get() > 0 && previouslyAddedId != null ) { work = createDeleteWork( previouslyAddedId ); if ( workType.equals( UPDATE ) ) { if ( updateCounter.get() > 0 && previouslyAddedId != null ) { work = createUpdateWork( previouslyAddedId );