From 74034d131e1e1049eb2013c0a9cc35c0d516f39c Mon Sep 17 00:00:00 2001 From: Vamshi Vijay Nakkirtha <46505183+vamshin@users.noreply.github.com> Date: Wed, 1 Jul 2020 13:03:06 -0700 Subject: [PATCH] recall bug fix for odfe>=1.8 (#155) * recall bug fix for odfe>=1.8 --- .../knn/index/codec/KNNCodecUtil.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/amazon/opendistroforelasticsearch/knn/index/codec/KNNCodecUtil.java b/src/main/java/com/amazon/opendistroforelasticsearch/knn/index/codec/KNNCodecUtil.java index 2d0e4bdb..6050b753 100644 --- a/src/main/java/com/amazon/opendistroforelasticsearch/knn/index/codec/KNNCodecUtil.java +++ b/src/main/java/com/amazon/opendistroforelasticsearch/knn/index/codec/KNNCodecUtil.java @@ -18,6 +18,7 @@ import org.apache.lucene.index.BinaryDocValues; import org.apache.lucene.search.DocIdSetIterator; +import org.apache.lucene.util.BytesRef; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -43,10 +44,9 @@ public static KNNCodecUtil.Pair getFloats(BinaryDocValues values) throws IOExcep ArrayList vectorList = new ArrayList<>(); ArrayList docIdList = new ArrayList<>(); for (int doc = values.nextDoc(); doc != DocIdSetIterator.NO_MORE_DOCS; doc = values.nextDoc()) { - byte[] value = values.binaryValue().bytes; - - try (ByteArrayInputStream byteStream = new ByteArrayInputStream(value); - ObjectInputStream objectStream = new ObjectInputStream(byteStream)) { + BytesRef bytesref = values.binaryValue(); + try (ByteArrayInputStream byteStream = new ByteArrayInputStream(bytesref.bytes, bytesref.offset, bytesref.length); + ObjectInputStream objectStream = new ObjectInputStream(byteStream)) { float[] vector = (float[]) objectStream.readObject(); vectorList.add(vector); } catch (ClassNotFoundException e) {