@Override public void writeField(FieldInfo fieldInfo, PointsReader reader) throws IOException { PointValues values = reader.getValues(fieldInfo.name); boolean singleValuePerDoc = values.size() == values.getDocCount(); try (BKDWriter writer = new BKDWriter( writeState.segmentInfo.maxDoc(), writeState.directory, writeState.segmentInfo.name, fieldInfo.getPointDimensionCount(), fieldInfo.getPointNumBytes(), maxPointsInLeafNode, maxMBSortInHeap, values.size(), singleValuePerDoc)) { if (values instanceof MutablePointValues) { final long fp = writer.writeField(dataOut, fieldInfo.name, (MutablePointValues) values); if (fp != -1) { indexFPs.put(fieldInfo.name, fp); } return; } values.intersect( new IntersectVisitor() { @Override public void visit(int docID) { throw new IllegalStateException(); } public void visit(int docID, byte[] packedValue) throws IOException { writer.add(packedValue, docID); } @Override public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) { return Relation.CELL_CROSSES_QUERY; } }); // We could have 0 points on merge since all docs with dimensional fields may be deleted: if (writer.getPointCount() > 0) { indexFPs.put(fieldInfo.name, writer.finish(dataOut)); } } }