use of org.apache.lucene.document.BinaryPoint in project lucene-solr by apache.
the class TestPointValues method testIllegalDimChangeTwoWriters.
public void testIllegalDimChangeTwoWriters() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.close();
iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w2 = new IndexWriter(dir, iwc);
Document doc2 = new Document();
doc2.add(new BinaryPoint("dim", new byte[4], new byte[4]));
IllegalArgumentException expected = expectThrows(IllegalArgumentException.class, () -> {
w2.addDocument(doc2);
});
assertEquals("cannot change point dimension count from 1 to 2 for field=\"dim\"", expected.getMessage());
w2.close();
dir.close();
}
use of org.apache.lucene.document.BinaryPoint in project lucene-solr by apache.
the class TestPointValues method testIllegalTooManyDimensions.
public void testIllegalTooManyDimensions() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
byte[][] values = new byte[PointValues.MAX_DIMENSIONS + 1][];
for (int i = 0; i < values.length; i++) {
values[i] = new byte[4];
}
expectThrows(IllegalArgumentException.class, () -> {
doc.add(new BinaryPoint("dim", values));
});
Document doc2 = new Document();
doc2.add(new IntPoint("dim", 17));
w.addDocument(doc2);
w.close();
dir.close();
}
use of org.apache.lucene.document.BinaryPoint in project lucene-solr by apache.
the class TestPointValues method testIllegalNumBytesChangeTwoSegments.
public void testIllegalNumBytesChangeTwoSegments() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.commit();
Document doc2 = new Document();
doc2.add(new BinaryPoint("dim", new byte[6]));
IllegalArgumentException expected = expectThrows(IllegalArgumentException.class, () -> {
w.addDocument(doc2);
});
assertEquals("cannot change point numBytes from 4 to 6 for field=\"dim\"", expected.getMessage());
w.close();
dir.close();
}
use of org.apache.lucene.document.BinaryPoint in project lucene-solr by apache.
the class TestPointValues method testIllegalNumBytesChangeTwoWriters.
public void testIllegalNumBytesChangeTwoWriters() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
doc.add(new BinaryPoint("dim", new byte[4]));
w.addDocument(doc);
w.close();
iwc = new IndexWriterConfig(new MockAnalyzer(random()));
IndexWriter w2 = new IndexWriter(dir, iwc);
Document doc2 = new Document();
doc2.add(new BinaryPoint("dim", new byte[6]));
IllegalArgumentException expected = expectThrows(IllegalArgumentException.class, () -> {
w2.addDocument(doc2);
});
assertEquals("cannot change point numBytes from 4 to 6 for field=\"dim\"", expected.getMessage());
w2.close();
dir.close();
}
use of org.apache.lucene.document.BinaryPoint in project lucene-solr by apache.
the class TestPointValues method testUpgradeFieldToPoints.
// Suddenly add points to an existing field:
public void testUpgradeFieldToPoints() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig iwc = newIndexWriterConfig();
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
doc.add(newStringField("dim", "foo", Field.Store.NO));
w.addDocument(doc);
w.close();
iwc = newIndexWriterConfig();
w = new IndexWriter(dir, iwc);
doc.add(new BinaryPoint("dim", new byte[4]));
w.close();
dir.close();
}
Aggregations