package org.archive.wayback.resourceindex.filters;

import org.archive.wayback.core.CaptureSearchResult;
import org.archive.wayback.util.ObjectFilter;

public class DuplicateHashFilter implements ObjectFilter<CaptureSearchResult> {

	private String lastHash = null;
	private int maxDupeHashes = 10;
	private int count = 0;
	
	@Override
	public int filterObject(CaptureSearchResult o) {
		String thisHash = o.getDigest();
		int result = FILTER_INCLUDE;
		if (lastHash != null) {
			if (lastHash.equals(thisHash) && !o.isDuplicateDigest()) {
				count++;
				if (count >= maxDupeHashes) {
					result = FILTER_EXCLUDE;
				}
			}
		}
		lastHash = thisHash;
		return result;
	}


}

@@ -616,16 +616,43 @@
 ;%0A%09%09%09%09%7D%0A
+%09%09%09%7D else %7B%0A%09%09%09%09count = 0;%0A
 %09%09%09%7D%0A%09%09%7D

Reset DuplicateHashFilter counter to 0 after non-match