File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed
server/src/main/java/org/elasticsearch/index/codec/vectors Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 2525
2626import java .io .IOException ;
2727
28+ import static org .elasticsearch .index .codec .vectors .BQVectorUtils .constSqrt ;
29+
2830/**
2931 * Copied from Lucene, replace with Lucene's implementation sometime after Lucene 10
3032 */
@@ -70,6 +72,18 @@ public abstract class BinarizedByteVectorValues extends ByteVectorValues {
7072 */
7173 public abstract int size ();
7274
75+ int discretizedDimensions () {
76+ return BQVectorUtils .discretize (dimension (), 64 );
77+ }
78+
79+ float sqrtDimensions () {
80+ return (float ) constSqrt (dimension ());
81+ }
82+
83+ float maxX1 () {
84+ return (float ) (1.9 / constSqrt (discretizedDimensions () - 1.0 ));
85+ }
86+
7387 /**
7488 * Return a {@link VectorScorer} for the given query vector.
7589 *
@@ -87,12 +101,4 @@ float getCentroidDP() throws IOException {
87101 return VectorUtil .dotProduct (centroid , centroid );
88102 }
89103
90- // TODO the following two most likely need fixing
91- public float sqrtDimensions () {
92- return 0 ;
93- }
94-
95- public float maxX1 () {
96- return 0 ;
97- }
98104}
Original file line number Diff line number Diff line change @@ -110,10 +110,17 @@ public byte[] vectorValue(int targetOrd) throws IOException {
110110 return binaryValue ;
111111 }
112112
113+ @ Override
114+ public int discretizedDimensions () {
115+ return discretizedDimensions ;
116+ }
117+
118+ @ Override
113119 public float sqrtDimensions () {
114120 return sqrtDimensions ;
115121 }
116122
123+ @ Override
117124 public float maxX1 () {
118125 return maxX1 ;
119126 }
You can’t perform that action at this time.
0 commit comments