From 2af3abb40aa44b41759aea5dfed89980b259dbe7 Mon Sep 17 00:00:00 2001 From: Hirotaka Wakabayashi Date: Wed, 30 Oct 2024 04:36:58 +0000 Subject: [PATCH 1/3] Fix the link --- README.md | 2 +- .../java/ax/antpick/k2hash/example/Attr.java | 164 ------------------ 2 files changed, 1 insertion(+), 165 deletions(-) delete mode 100644 example/src/main/java/ax/antpick/k2hash/example/Attr.java diff --git a/README.md b/README.md index acb30da..86eb9fd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ k2hash_java ------ -[![Actions Status](https://github.com/yahoojapan/k2hash_java/workflows/CI/badge.svg)](https://github.com/yahoojapan/k2hash_java/actions) +[![Actions Status](https://github.com/yahoojapan/k2hash_java/actions/workflows/main.yml/badge.svg)](https://github.com/yahoojapan/k2hash_java/actions) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/yahoojapan/k2hash_nodejs/master/LICENSE) ### Overview diff --git a/example/src/main/java/ax/antpick/k2hash/example/Attr.java b/example/src/main/java/ax/antpick/k2hash/example/Attr.java deleted file mode 100644 index bd1cd5c..0000000 --- a/example/src/main/java/ax/antpick/k2hash/example/Attr.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * K2hash Java Driver - * - * Copyright 2023 Yahoo Japan Corporation. - * - * K2hash is a key-value store base library. - * K2hash Java Driver is the one for Java. - * - * See the LICENSE file with this source code for - * the details of the MIT License. - * - * AUTHOR: Hirotaka Wakabayashi - * CREATE: Fri, 30 Sep 2023 - * REVISION: - * - */ -package ax.antpick.k2hash.example; - -import com.sun.jna.*; -import com.sun.jna.ptr.*; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -// -// javac -cp \ -// "logback-classic-1.3.11.jar:logback-core-1.3.11.jar:slf4j-api-2.0.7.jar:jna-5.13.0.jar:jna-platform-5.13.0.jar" \ -// ax/antpick/k2hash/example/Attr.java -// - -public class Attr { - static final Logger logger = LoggerFactory.getLogger(Attr.class); - public static final int DEFAULT_MASK_BITS = 8; - public static final int DEFAULT_CMASK_BITS = 4; - public static final int DEFAULT_MAX_ELEMENT = 32; - public static final int DEFAULT_PAGE_SIZE = 4096; - - public static class K2hashAttrPack extends Structure { - /** Fields of K2hashAttrPack. */ - public static final List FIELDS = - createFieldsOrder("pkey", "keylength", "pval", "vallength"); - - /** An attribute key. */ - public String pkey; - // public byte[] pkey; - /** The length of an attribute key. */ - public int keylength; - /** An attribute value. */ - public String pval; - // public byte[] pval; - /** The length of an attribute value. */ - public int vallength; - - /** Constructor of a K2hash attribute. */ - public K2hashAttrPack() {} - - /** - * Returns fields in the same order with the K2hash C API K2hashAttrPack structure. - * - * @return fields - */ - @Override - protected List getFieldOrder() { - return FIELDS; - } - } - - public interface CLibrary extends Library { - // prototypes - void free(Pointer ptr); - } - - public interface K2hashLibrary extends Library { - // prototypes - long k2h_open_mem(int maskbitcnt, int cmaskbitcnt, int maxelementcnt, long pagesize); - - boolean k2h_close(long handle); - - boolean k2h_set_str_value_wa( - long handle, String pkey, String pval, String pass, LongByReference expirationDuration); - - Pointer k2h_get_str_direct_value_wp(long handle, String pkey, String pass); - - boolean k2h_add_str_attr(long handle, String pkey, String attrName, String attrVal); - - // extern PK2HATTRPCK k2h_get_str_direct_attrs(k2h_h handle, const char* pkey, int* - // pattrspckcnt); - K2hashAttrPack k2h_get_str_direct_attrs(long handle, String pkey, IntByReference pattrspckcnt); - - // extern bool k2h_free_attrpack(PK2HATTRPCK pattrs, int attrcnt); - boolean k2h_free_attrpack(K2hashAttrPack pattrs, int attrcnt); - } - - public static class time_t extends IntegerType { - public time_t(long value) { - super(Native.LONG_SIZE, value); - } - } - - public static void main(String[] args) { - System.setProperty("jna.dump_memory", "true"); - CLibrary C_INSTANCE = (CLibrary) Native.synchronizedLibrary(Native.load("c", CLibrary.class)); - K2hashLibrary INSTANCE = - (K2hashLibrary) Native.synchronizedLibrary(Native.load("k2hash", K2hashLibrary.class)); - long handle = - INSTANCE.k2h_open_mem( - DEFAULT_MASK_BITS, DEFAULT_CMASK_BITS, DEFAULT_MAX_ELEMENT, DEFAULT_PAGE_SIZE); - INSTANCE.k2h_set_str_value_wa(handle, "testkey", "testval", "", null); - Pointer val = INSTANCE.k2h_get_str_direct_value_wp(handle, "testkey", ""); - logger.debug("val {}", val.getString(0)); - C_INSTANCE.free(val); - - String attrName = "testkey_attr"; - String attrVal = "testkey_attr_val"; - boolean isSuccess = INSTANCE.k2h_add_str_attr(handle, "testkey", attrName, attrVal); - if (!isSuccess) { - logger.error("INSTANCE.k2h_add_attr returns false"); - } - - isSuccess = INSTANCE.k2h_add_str_attr(handle, "testkey", "testkey_attr2", "testkey_attr2_val"); - if (!isSuccess) { - logger.error("INSTANCE.k2h_add_attr returns false"); - } - - IntByReference iref = new IntByReference(); - K2hashAttrPack pp = INSTANCE.k2h_get_str_direct_attrs(handle, "testkey", iref); - pp.setAutoRead(false); - logger.debug("pp {}", pp); - - if (pp == null || iref.getValue() == 0) { - logger.warn("no attribute exists"); - return; - } - K2hashAttrPack[] attrs = (K2hashAttrPack[]) pp.toArray(iref.getValue()); - logger.debug("iref.getValue() {}", iref.getValue()); - - Map map = new HashMap<>(); - Stream stream = Stream.of(attrs); - stream.forEach( - attr -> { - logger.debug("{} {} {} {}", attr.pkey, attr.keylength, attr.pval, attr.vallength); - logger.debug("attr.toString() {} ", attr.toString()); - logger.debug("attr.getPointer() {} ", attr.getPointer()); - logger.debug("attr.pkey.toString() {} ", attr.pkey); - logger.debug("attr.pval.toString() {} ", attr.pval); - map.put(attr.pkey, attr.pval); - }); - logger.debug("K2hashAttrPack address={} size={}", pp.toString(), pp.size()); - - // INSTANCE.k2h_free_attrpack(pp, iref.getValue()); - INSTANCE.k2h_close(handle); - } -} -// -// Local variables: -// tab-width: 2 -// c-basic-offset: 2 -// End: -// vim600: noexpandtab sw=2 ts=2 fdm=marker -// vim<600: noexpandtab sw=2 ts=2 -// From 5e6028e45320703de1fd14869acb324d70cb51c1 Mon Sep 17 00:00:00 2001 From: Hirotaka Wakabayashi Date: Wed, 30 Oct 2024 05:55:28 +0000 Subject: [PATCH 2/3] Move files --- k2hash/src/main/java/{ => ax/antpick/k2hash}/CLibrary.java | 0 k2hash/src/main/java/{ => ax/antpick/k2hash}/K2hash.java | 0 k2hash/src/main/java/{ => ax/antpick/k2hash}/K2hashAttrPack.java | 0 k2hash/src/main/java/{ => ax/antpick/k2hash}/K2hashKeyQueue.java | 0 k2hash/src/main/java/{ => ax/antpick/k2hash}/K2hashLibrary.java | 0 k2hash/src/main/java/{ => ax/antpick/k2hash}/K2hashQueue.java | 0 k2hash/src/main/java/{ => ax/antpick/k2hash}/package-info.java | 0 k2hash/src/test/java/{ => ax/antpick/k2hash}/K2hashFileTest.java | 0 .../src/test/java/{ => ax/antpick/k2hash}/K2hashKeyQueueTest.java | 0 k2hash/src/test/java/{ => ax/antpick/k2hash}/K2hashQueueTest.java | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename k2hash/src/main/java/{ => ax/antpick/k2hash}/CLibrary.java (100%) rename k2hash/src/main/java/{ => ax/antpick/k2hash}/K2hash.java (100%) rename k2hash/src/main/java/{ => ax/antpick/k2hash}/K2hashAttrPack.java (100%) rename k2hash/src/main/java/{ => ax/antpick/k2hash}/K2hashKeyQueue.java (100%) rename k2hash/src/main/java/{ => ax/antpick/k2hash}/K2hashLibrary.java (100%) rename k2hash/src/main/java/{ => ax/antpick/k2hash}/K2hashQueue.java (100%) rename k2hash/src/main/java/{ => ax/antpick/k2hash}/package-info.java (100%) rename k2hash/src/test/java/{ => ax/antpick/k2hash}/K2hashFileTest.java (100%) rename k2hash/src/test/java/{ => ax/antpick/k2hash}/K2hashKeyQueueTest.java (100%) rename k2hash/src/test/java/{ => ax/antpick/k2hash}/K2hashQueueTest.java (100%) diff --git a/k2hash/src/main/java/CLibrary.java b/k2hash/src/main/java/ax/antpick/k2hash/CLibrary.java similarity index 100% rename from k2hash/src/main/java/CLibrary.java rename to k2hash/src/main/java/ax/antpick/k2hash/CLibrary.java diff --git a/k2hash/src/main/java/K2hash.java b/k2hash/src/main/java/ax/antpick/k2hash/K2hash.java similarity index 100% rename from k2hash/src/main/java/K2hash.java rename to k2hash/src/main/java/ax/antpick/k2hash/K2hash.java diff --git a/k2hash/src/main/java/K2hashAttrPack.java b/k2hash/src/main/java/ax/antpick/k2hash/K2hashAttrPack.java similarity index 100% rename from k2hash/src/main/java/K2hashAttrPack.java rename to k2hash/src/main/java/ax/antpick/k2hash/K2hashAttrPack.java diff --git a/k2hash/src/main/java/K2hashKeyQueue.java b/k2hash/src/main/java/ax/antpick/k2hash/K2hashKeyQueue.java similarity index 100% rename from k2hash/src/main/java/K2hashKeyQueue.java rename to k2hash/src/main/java/ax/antpick/k2hash/K2hashKeyQueue.java diff --git a/k2hash/src/main/java/K2hashLibrary.java b/k2hash/src/main/java/ax/antpick/k2hash/K2hashLibrary.java similarity index 100% rename from k2hash/src/main/java/K2hashLibrary.java rename to k2hash/src/main/java/ax/antpick/k2hash/K2hashLibrary.java diff --git a/k2hash/src/main/java/K2hashQueue.java b/k2hash/src/main/java/ax/antpick/k2hash/K2hashQueue.java similarity index 100% rename from k2hash/src/main/java/K2hashQueue.java rename to k2hash/src/main/java/ax/antpick/k2hash/K2hashQueue.java diff --git a/k2hash/src/main/java/package-info.java b/k2hash/src/main/java/ax/antpick/k2hash/package-info.java similarity index 100% rename from k2hash/src/main/java/package-info.java rename to k2hash/src/main/java/ax/antpick/k2hash/package-info.java diff --git a/k2hash/src/test/java/K2hashFileTest.java b/k2hash/src/test/java/ax/antpick/k2hash/K2hashFileTest.java similarity index 100% rename from k2hash/src/test/java/K2hashFileTest.java rename to k2hash/src/test/java/ax/antpick/k2hash/K2hashFileTest.java diff --git a/k2hash/src/test/java/K2hashKeyQueueTest.java b/k2hash/src/test/java/ax/antpick/k2hash/K2hashKeyQueueTest.java similarity index 100% rename from k2hash/src/test/java/K2hashKeyQueueTest.java rename to k2hash/src/test/java/ax/antpick/k2hash/K2hashKeyQueueTest.java diff --git a/k2hash/src/test/java/K2hashQueueTest.java b/k2hash/src/test/java/ax/antpick/k2hash/K2hashQueueTest.java similarity index 100% rename from k2hash/src/test/java/K2hashQueueTest.java rename to k2hash/src/test/java/ax/antpick/k2hash/K2hashQueueTest.java From ca7f1724c2ebbedb092af240269a170e2ab3f3e2 Mon Sep 17 00:00:00 2001 From: Hirotaka Wakabayashi Date: Wed, 30 Oct 2024 07:11:08 +0000 Subject: [PATCH 3/3] Updates the ChangeLog --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8dbd15d..b4aa8c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ k2hash-java (1.0.6) stable; urgency=low - * Bump up + * Updated the SonaType configurations -- Hirotaka Wakabayashi Thu, 30 Nov 2023 13:57:40 +0900