kaivalnp commented on code in PR #14178:
URL: https://github.com/apache/lucene/pull/14178#discussion_r1982960581


##########
lucene/sandbox/src/java/org/apache/lucene/sandbox/codecs/faiss/LibFaissC.java:
##########
@@ -0,0 +1,488 @@
+/*
+ * 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.sandbox.codecs.faiss;
+
+import static java.lang.foreign.ValueLayout.ADDRESS;
+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 static org.apache.lucene.search.DocIdSetIterator.NO_MORE_DOCS;
+
+import java.io.IOException;
+import java.lang.foreign.Arena;
+import java.lang.foreign.FunctionDescriptor;
+import java.lang.foreign.Linker;
+import java.lang.foreign.MemoryLayout;
+import java.lang.foreign.MemorySegment;
+import java.lang.foreign.SymbolLookup;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+import java.nio.LongBuffer;
+import java.util.Locale;
+import org.apache.lucene.index.FloatVectorValues;
+import org.apache.lucene.index.KnnVectorValues;
+import org.apache.lucene.index.VectorSimilarityFunction;
+import org.apache.lucene.search.KnnCollector;
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.store.IndexOutput;
+import org.apache.lucene.util.Bits;
+import org.apache.lucene.util.FixedBitSet;
+import org.apache.lucene.util.hnsw.IntToIntFunction;
+
+/**
+ * Utility class to wrap necessary functions of the native C_API of Faiss 
using <a
+ * href="https://openjdk.org/projects/panama";>Project Panama</a> (library 
{@value
+ * LibFaissC#LIBRARY_NAME}, version {@value LibFaissC#LIBRARY_VERSION}, build 
using <a
+ * 
href="https://github.com/facebookresearch/faiss/blob/main/c_api/INSTALL.md";>this
 guide</a> and
+ * add to runtime along with all dependencies).
+ *
+ * @lucene.experimental
+ */
+public final class LibFaissC {
+  /*
+   * TODO: Requires some changes to Faiss
+   *  - https://github.com/facebookresearch/faiss/pull/4158 (merged in main, 
to be released in v1.11.0)
+   *  - https://github.com/facebookresearch/faiss/pull/4167 (merged in main, 
to be released in v1.11.0)
+   *  - https://github.com/facebookresearch/faiss/pull/4180 (in progress)
+   */
+
+  public static final String LIBRARY_NAME = "faiss_c";
+  public static final String LIBRARY_VERSION = "1.10.0";

Review Comment:
   Do you mean exposing it as an input variable? If so, I've kept it hard-coded 
because functions in the C_API may change over time, and fixing a version 
prevents the user from calling an incompatible library (i.e. functions that may 
not exist, or have different behavior than expected leading to silent issues)



-- 
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: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to