PredicateIndexBuilder { public void indexDocument(int docId, Predicate predicate) { if (documentIdCounter == Integer.MAX_VALUE) { throw new IllegalStateException("Index is full, max number of documents is: " + Integer.MAX_VALUE); } else if (seenIds.contains(docId)) { throw new IllegalArgumentException("Document id is already in use: " + docId); } else if (isNeverMatchingDocument(predicate)) { return; } seenIds.add(docId); predicate = optimizer.optimizePredicate(predicate); int internalId = documentIdCounter++; if (isAlwaysMatchingDocument(predicate)) { indexZeroConstraintDocument(internalId); } else { indexDocument(internalId, PredicateTreeAnnotator.createPredicateTreeAnnotations(predicate)); } } PredicateIndexBuilder(int arity);  PredicateIndexBuilder(int arity, long lowerBound, long upperBound);  PredicateIndexBuilder(Config config); void indexDocument(int docId, Predicate predicate); PredicateIndex build(); int getZeroConstraintDocCount(); PredicateIndexStats getStats();  }
@Test(expected = IllegalArgumentException.class) public void requireThatIndexingMultiDocumentsWithSameIdThrowsException() { PredicateIndexBuilder builder = new PredicateIndexBuilder(2); builder.indexDocument(1, Predicate.fromString("a in ['b']")); builder.indexDocument(1, Predicate.fromString("c in ['d']")); }