ivandasch commented on a change in pull request #9569:
URL: https://github.com/apache/ignite/pull/9569#discussion_r758179512



##########
File path: modules/numa-allocator/src/main/cpp/include/numa/numa_alloc.h
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.
+ */
+
+#ifndef _NUMA_ALLOC_H
+#define _NUMA_ALLOC_H
+
+#include <ostream>
+
+namespace numa {
+    class BitSet {
+    public:
+        BitSet();
+
+        BitSet(const BitSet &other);
+
+        BitSet &operator=(const BitSet &other);
+
+        ~BitSet();
+
+        class Reference {

Review comment:
       Now it is not used. This is quite common technique  (see i.e. bitset 
implementation in 
[libstdc++|https://github.com/gcc-mirror/gcc/blob/85e91ad55a69282c1b0e34569836a026a1a954d1/libstdc%2B%2B-v3/include/std/bitset#L802])
 to implement non-const `operator[]`. With it you can do somethin like this
   ```c++
   BitSet a, b;
   a[0] = true;
   for (size_t i = 0; i < a.Size() && i < b.Size(); ++i) {
        a[i] = !b[i];
   }
   ```
   But this functionality is no used so far, it is for probably future uses

##########
File path: 
modules/numa-allocator/src/main/java/org/apache/ignite/internal/mem/NumaAllocUtil.java
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.ignite.internal.mem;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Paths;
+
+/** */
+public class NumaAllocUtil {
+    /** */
+    private static final String extension = ".so";
+
+    /** */
+    private static final String libraryName = "libnuma_alloc";
+
+    /** */
+    private NumaAllocUtil() {
+        // No-op.
+    }
+
+    /** */
+    private static String getLibName() {
+        return Paths.get("/org/apache/ignite/internal/mem", getOSName(), 
getOSArch(), libraryName + extension)
+            .toString();
+    }
+
+    /** */
+    private static String getOSArch() {
+        return System.getProperty("os.arch", "");
+    }
+
+    /** */
+    private static String getOSName() {
+        if (System.getProperty("os.name", "").contains("Linux"))
+            return "linux";
+        else
+            throw new UnsupportedOperationException("Operating System is not 
supported");
+    }
+
+    static {
+        String libName = getLibName();
+        File nativeLib = null;
+
+        try (InputStream in = 
NumaAllocUtil.class.getResourceAsStream(libName)) {
+            if (in == null) {
+                throw new ExceptionInInitializerError("Failed to load native 
numa_alloc library, "
+                    + libName + " not found");
+            }
+
+            nativeLib = File.createTempFile(libraryName, extension);
+
+            try (FileOutputStream out = new FileOutputStream(nativeLib)) {

Review comment:
       +1, good catch




-- 
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]


Reply via email to