@@ -388,7 +388,8 @@ private DenseVectorIndexOptions defaultIndexOptions(boolean defaultInt8Hnsw, boo
388
388
return new BBQHnswIndexOptions (
389
389
Lucene99HnswVectorsFormat .DEFAULT_MAX_CONN ,
390
390
Lucene99HnswVectorsFormat .DEFAULT_BEAM_WIDTH ,
391
- new RescoreVector (DEFAULT_OVERSAMPLE )
391
+ new RescoreVector (DEFAULT_OVERSAMPLE ),
392
+ false
392
393
);
393
394
} else if (defaultInt8Hnsw ) {
394
395
return new Int8HnswIndexOptions (
@@ -1455,15 +1456,20 @@ public DenseVectorIndexOptions parseIndexOptions(String fieldName, Map<String, ?
1455
1456
}
1456
1457
int m = XContentMapValues .nodeIntegerValue (mNode );
1457
1458
int efConstruction = XContentMapValues .nodeIntegerValue (efConstructionNode );
1459
+
1458
1460
RescoreVector rescoreVector = null ;
1459
1461
if (hasRescoreIndexVersion (indexVersion )) {
1460
1462
rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
1461
1463
if (rescoreVector == null && defaultOversampleForBBQ (indexVersion )) {
1462
1464
rescoreVector = new RescoreVector (DEFAULT_OVERSAMPLE );
1463
1465
}
1464
1466
}
1467
+
1468
+ Object directRawVectorReadsNode = indexOptionsMap .remove ("direct_raw_vector_reads" );
1469
+ boolean directRawVectorReads = XContentMapValues .nodeBooleanValue (directRawVectorReadsNode , false );
1470
+
1465
1471
MappingParser .checkNoRemainingFields (fieldName , indexOptionsMap );
1466
- return new BBQHnswIndexOptions (m , efConstruction , rescoreVector );
1472
+ return new BBQHnswIndexOptions (m , efConstruction , rescoreVector , directRawVectorReads );
1467
1473
}
1468
1474
1469
1475
@ Override
@@ -1518,10 +1524,12 @@ public DenseVectorIndexOptions parseIndexOptions(String fieldName, Map<String, ?
1518
1524
);
1519
1525
}
1520
1526
}
1527
+
1521
1528
RescoreVector rescoreVector = RescoreVector .fromIndexOptions (indexOptionsMap , indexVersion );
1522
1529
if (rescoreVector == null ) {
1523
1530
rescoreVector = new RescoreVector (DEFAULT_OVERSAMPLE );
1524
1531
}
1532
+
1525
1533
Object visitPercentageNode = indexOptionsMap .remove ("default_visit_percentage" );
1526
1534
double visitPercentage = 0d ;
1527
1535
if (visitPercentageNode != null ) {
@@ -1536,8 +1544,12 @@ public DenseVectorIndexOptions parseIndexOptions(String fieldName, Map<String, ?
1536
1544
);
1537
1545
}
1538
1546
}
1547
+
1548
+ Object directRawVectorReadsNode = indexOptionsMap .remove ("direct_raw_vector_reads" );
1549
+ boolean directRawVectorReads = XContentMapValues .nodeBooleanValue (directRawVectorReadsNode , false );
1550
+
1539
1551
MappingParser .checkNoRemainingFields (fieldName , indexOptionsMap );
1540
- return new BBQIVFIndexOptions (clusterSize , visitPercentage , rescoreVector );
1552
+ return new BBQIVFIndexOptions (clusterSize , visitPercentage , rescoreVector , directRawVectorReads );
1541
1553
}
1542
1554
1543
1555
@ Override
@@ -2009,17 +2021,23 @@ public String toString() {
2009
2021
public static class BBQHnswIndexOptions extends QuantizedIndexOptions {
2010
2022
private final int m ;
2011
2023
private final int efConstruction ;
2024
+ private final boolean directRawVectorReads ;
2012
2025
2013
- public BBQHnswIndexOptions (int m , int efConstruction , RescoreVector rescoreVector ) {
2026
+ public BBQHnswIndexOptions (int m , int efConstruction , RescoreVector rescoreVector , boolean directRawVectorReads ) {
2014
2027
super (VectorIndexType .BBQ_HNSW , rescoreVector );
2015
2028
this .m = m ;
2016
2029
this .efConstruction = efConstruction ;
2030
+ this .directRawVectorReads = directRawVectorReads ;
2017
2031
}
2018
2032
2019
2033
@ Override
2020
2034
KnnVectorsFormat getVectorsFormat (ElementType elementType ) {
2021
2035
assert elementType == ElementType .FLOAT ;
2022
- return new ES93HnswBinaryQuantizedVectorsFormat (m , efConstruction );
2036
+ var format = new ES93HnswBinaryQuantizedVectorsFormat (m , efConstruction );
2037
+ if (directRawVectorReads ) {
2038
+ format .useDirectIO ();
2039
+ }
2040
+ return format ;
2023
2041
}
2024
2042
2025
2043
@ Override
@@ -2031,12 +2049,13 @@ public boolean updatableTo(DenseVectorIndexOptions update) {
2031
2049
@ Override
2032
2050
boolean doEquals (DenseVectorIndexOptions other ) {
2033
2051
BBQHnswIndexOptions that = (BBQHnswIndexOptions ) other ;
2034
- return m == that .m && efConstruction == that .efConstruction && Objects .equals (rescoreVector , that .rescoreVector );
2052
+ return m == that .m && efConstruction == that .efConstruction && Objects .equals (rescoreVector , that .rescoreVector )
2053
+ && directRawVectorReads == that .directRawVectorReads ;
2035
2054
}
2036
2055
2037
2056
@ Override
2038
2057
int doHashCode () {
2039
- return Objects .hash (m , efConstruction , rescoreVector );
2058
+ return Objects .hash (m , efConstruction , rescoreVector , directRawVectorReads );
2040
2059
}
2041
2060
2042
2061
@ Override
@@ -2053,6 +2072,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
2053
2072
if (rescoreVector != null ) {
2054
2073
rescoreVector .toXContent (builder , params );
2055
2074
}
2075
+ if (directRawVectorReads ) {
2076
+ builder .field ("direct_raw_vector_reads" , true );
2077
+ }
2056
2078
builder .endObject ();
2057
2079
return builder ;
2058
2080
}
@@ -2131,17 +2153,23 @@ public boolean validateDimension(int dim, boolean throwOnError) {
2131
2153
static class BBQIVFIndexOptions extends QuantizedIndexOptions {
2132
2154
final int clusterSize ;
2133
2155
final double defaultVisitPercentage ;
2156
+ final boolean directRawVectorReads ;
2134
2157
2135
- BBQIVFIndexOptions (int clusterSize , double defaultVisitPercentage , RescoreVector rescoreVector ) {
2158
+ BBQIVFIndexOptions (int clusterSize , double defaultVisitPercentage , RescoreVector rescoreVector , boolean directRawVectorReads ) {
2136
2159
super (VectorIndexType .BBQ_DISK , rescoreVector );
2137
2160
this .clusterSize = clusterSize ;
2138
2161
this .defaultVisitPercentage = defaultVisitPercentage ;
2162
+ this .directRawVectorReads = directRawVectorReads ;
2139
2163
}
2140
2164
2141
2165
@ Override
2142
2166
KnnVectorsFormat getVectorsFormat (ElementType elementType ) {
2143
2167
assert elementType == ElementType .FLOAT ;
2144
- return new ES920DiskBBQVectorsFormat (clusterSize , ES920DiskBBQVectorsFormat .DEFAULT_CENTROIDS_PER_PARENT_CLUSTER );
2168
+ var format = new ES920DiskBBQVectorsFormat (clusterSize , ES920DiskBBQVectorsFormat .DEFAULT_CENTROIDS_PER_PARENT_CLUSTER );
2169
+ if (directRawVectorReads ) {
2170
+ format .useDirectIO ();
2171
+ }
2172
+ return format ;
2145
2173
}
2146
2174
2147
2175
@ Override
@@ -2154,12 +2182,13 @@ boolean doEquals(DenseVectorIndexOptions other) {
2154
2182
BBQIVFIndexOptions that = (BBQIVFIndexOptions ) other ;
2155
2183
return clusterSize == that .clusterSize
2156
2184
&& defaultVisitPercentage == that .defaultVisitPercentage
2157
- && Objects .equals (rescoreVector , that .rescoreVector );
2185
+ && Objects .equals (rescoreVector , that .rescoreVector )
2186
+ && directRawVectorReads == that .directRawVectorReads ;
2158
2187
}
2159
2188
2160
2189
@ Override
2161
2190
int doHashCode () {
2162
- return Objects .hash (clusterSize , defaultVisitPercentage , rescoreVector );
2191
+ return Objects .hash (clusterSize , defaultVisitPercentage , rescoreVector , directRawVectorReads );
2163
2192
}
2164
2193
2165
2194
@ Override
@@ -2176,6 +2205,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
2176
2205
if (rescoreVector != null ) {
2177
2206
rescoreVector .toXContent (builder , params );
2178
2207
}
2208
+ if (directRawVectorReads ) {
2209
+ builder .field ("direct_raw_vector_reads" , true );
2210
+ }
2179
2211
builder .endObject ();
2180
2212
return builder ;
2181
2213
}
0 commit comments