uschindler commented on code in PR #15508:
URL: https://github.com/apache/lucene/pull/15508#discussion_r2983184169


##########
lucene/core/src/java25/org/apache/lucene/internal/vectorization/NativeVectorUtilSupport.java:
##########
@@ -0,0 +1,590 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.internal.vectorization;
+
+import static java.lang.foreign.ValueLayout.JAVA_BYTE;
+import static java.lang.foreign.ValueLayout.JAVA_DOUBLE;
+import static java.lang.foreign.ValueLayout.JAVA_FLOAT;
+import static java.lang.foreign.ValueLayout.JAVA_INT;
+import static java.lang.foreign.ValueLayout.JAVA_LONG;
+
+import java.lang.foreign.AddressLayout;
+import java.lang.foreign.FunctionDescriptor;
+import java.lang.foreign.Linker;
+import java.lang.foreign.MemorySegment;
+import java.lang.foreign.SymbolLookup;
+import java.lang.foreign.ValueLayout;
+import java.lang.invoke.MethodHandle;
+import java.util.function.Supplier;
+import java.util.logging.Logger;
+import org.apache.lucene.util.Constants;
+
+/**
+ * VectorUtilSupport implementation that uses native bindings for optimized 
vector operations(using
+ * Foreign Function and Memory API (FFM)) if available(optional) or else 
fallback to
+ * PanamaVectorUtil implementations.
+ *
+ * <p>This class provides access to native C implementations of dot product 
operations from the
+ * loaded shared/dynamic library(.so|.dylib|.dll) which is generated from C 
code and linked at
+ * runtime. The native library contains multiple optimized implementations:
+ *
+ * <p>PanamaVectorUtilSupport#dotProduct use this Native C implementation for 
dot product
+ * calculation if system property <b>lucene.useNativeDotProduct=true</b> is 
passed it always tries
+ * to ensure binary is provided and required methods are implemented
+ *
+ * <p>It Uses <code>Linker.Option.critical(true)</code> for optimal 
performance by eliminating the
+ * overhead of ensuring MemorySegments are allocated off-heap before native 
calls.
+ */
+@SuppressWarnings("restricted")
+public final class NativeVectorUtilSupport implements VectorUtilSupport {

Review Comment:
   this class should be package private



##########
lucene/core/src/java25/org/apache/lucene/internal/vectorization/NativeVectorizationProvider.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.lucene.internal.vectorization;
+
+import java.io.IOException;
+import java.util.Locale;
+import java.util.logging.Logger;
+import org.apache.lucene.codecs.hnsw.FlatVectorsScorer;
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.Constants;
+import org.apache.lucene.util.SuppressForbidden;
+
+/** Native provider returning native implementations which delegates to Panama 
implementation. */
+public final class NativeVectorizationProvider extends VectorizationProvider {

Review Comment:
   this class should be package private



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to