V1StoredIndex extends Freezable implements IndexSegment { @NotNull @Override public IndexSegment addDocument( final int documentId, @NotNull final Collection<UnsignedByteArray> values) { if (documentId < 0) throw new IllegalArgumentException("Negative document ID"); if (values.size() != 1) throw new IllegalArgumentException("A single value expected"); checkNotFrozen(); final UnsignedByteArray value = values.iterator().next(); List<Integer> indexes = this.valueDocId.computeIfAbsent(value, v -> new LinkedList<>()); if (!indexes.isEmpty()) { uniqueValues = false; } indexes.add(documentId); return this; } V1StoredIndex(
            @NotNull final String fieldName); @NotNull @Override IndexSegment addDocument(
            final int documentId,
            @NotNull final Collection<UnsignedByteArray> values); @Override void setDatabaseDocumentsCount(final int documentsCount); @NotNull @Override OutputStreamWritable buildWritable();  }
@Test public void addDocument() { new V1StoredIndex("field") .addDocument( 0, Collections.singletonList(from(0))); }
@Test(expected = IllegalArgumentException.class) public void wrongDocument() { new V1StoredIndex("field") .addDocument( -1, Collections.singletonList(from(0))); }
@Test(expected = IllegalArgumentException.class) public void emptyValues() { new V1StoredIndex("field") .addDocument( 0, Collections.<UnsignedByteArray>emptyList()); }
@Test(expected = IllegalArgumentException.class) public void multipleValues() { new V1StoredIndex("field") .addDocument( 0, Arrays.asList(from(0), from(1))); }