From 4db34699c36f331b3fea082d6867449b472e76c7 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Mon, 9 Sep 2024 11:03:05 -0700 Subject: [PATCH] Update Sort comparators for Chapel 2.2 (#3750) * update comparators for Chapel 2.2 Signed-off-by: Jade Abraham * fix makefile for docs Signed-off-by: Jade Abraham * remove gitignores Signed-off-by: Jade Abraham * fix missing * Signed-off-by: Jade Abraham * avoid compat module issues Signed-off-by: Jade Abraham --------- Signed-off-by: Jade Abraham --- Makefile | 8 ++++++-- src/ArgSortMsg.chpl | 16 ++++++++-------- src/RadixSortLSD.chpl | 5 +++-- src/SegStringSort.chpl | 4 ++-- src/SortMsg.chpl | 6 +++--- src/compat/eq-20/.gitignore | 1 - src/compat/eq-20/ArkoudaSortCompat.chpl | 13 +++++++++++++ src/compat/eq-21/.gitignore | 1 - src/compat/eq-21/ArkoudaSortCompat.chpl | 13 +++++++++++++ src/compat/ge-22/.gitignore | 1 - src/compat/ge-22/ArkoudaSortCompat.chpl | 3 +++ 11 files changed, 51 insertions(+), 20 deletions(-) delete mode 100644 src/compat/eq-20/.gitignore create mode 100644 src/compat/eq-20/ArkoudaSortCompat.chpl delete mode 100644 src/compat/eq-21/.gitignore create mode 100644 src/compat/eq-21/ArkoudaSortCompat.chpl delete mode 100644 src/compat/ge-22/.gitignore create mode 100644 src/compat/ge-22/ArkoudaSortCompat.chpl diff --git a/Makefile b/Makefile index aad393c8ee..3edebb74a8 100644 --- a/Makefile +++ b/Makefile @@ -382,6 +382,10 @@ ifeq ($(shell expr $(CHPL_MINOR) \>= 2),1) ARKOUDA_COMPAT_MODULES += -M $(ARKOUDA_SOURCE_DIR)/compat/ge-22 endif +ifeq ($(shell expr $(CHPL_MINOR) \>= 2),1) + ARKOUDA_KEYPART_FLAG := -suseKeyPartStatus=true +endif + ifeq ($(shell expr $(CHPL_MINOR) \<= 1),1) ARKOUDA_RW_DEFAULT_FLAG := -sOpenReaderLockingDefault=false -sOpenWriterLockingDefault=false endif @@ -391,7 +395,7 @@ SERVER_CONFIG_SCRIPT=$(ARKOUDA_SOURCE_DIR)/parseServerConfig.py $(ARKOUDA_MAIN_MODULE): check-deps register-commands $(ARROW_UTIL_O) $(ARROW_READ_O) $(ARROW_WRITE_O) $(ARKOUDA_SOURCES) $(ARKOUDA_MAKEFILES) $(eval MOD_GEN_OUT=$(shell python3 $(SERVER_CONFIG_SCRIPT) $(ARKOUDA_CONFIG_FILE) $(ARKOUDA_REGISTRATION_CONFIG) $(ARKOUDA_SOURCE_DIR))) - $(CHPL) $(CHPL_DEBUG_FLAGS) $(PRINT_PASSES_FLAGS) $(REGEX_MAX_CAPTURES_FLAG) $(OPTIONAL_SERVER_FLAGS) $(CHPL_FLAGS_WITH_VERSION) $(CHPL_COMPAT_FLAGS) $(ARKOUDA_MAIN_SOURCE) $(ARKOUDA_COMPAT_MODULES) $(ARKOUDA_SERVER_USER_MODULES) $(MOD_GEN_OUT) $(ARKOUDA_RW_DEFAULT_FLAG) $(ARKOUDA_REGISTRY_DIR)/Commands.chpl -I$(ARKOUDA_SOURCE_DIR)/parquet -o $@ + $(CHPL) $(CHPL_DEBUG_FLAGS) $(PRINT_PASSES_FLAGS) $(REGEX_MAX_CAPTURES_FLAG) $(OPTIONAL_SERVER_FLAGS) $(CHPL_FLAGS_WITH_VERSION) $(CHPL_COMPAT_FLAGS) $(ARKOUDA_MAIN_SOURCE) $(ARKOUDA_COMPAT_MODULES) $(ARKOUDA_SERVER_USER_MODULES) $(MOD_GEN_OUT) $(ARKOUDA_RW_DEFAULT_FLAG) $(ARKOUDA_KEYPART_FLAG) $(ARKOUDA_REGISTRY_DIR)/Commands.chpl -I$(ARKOUDA_SOURCE_DIR)/parquet -o $@ CLEAN_TARGETS += arkouda-clean .PHONY: arkouda-clean @@ -474,7 +478,7 @@ doc-server: ${DOC_DIR} $(DOC_SERVER_OUTPUT_DIR)/index.html $(DOC_SERVER_OUTPUT_DIR)/index.html: $(ARKOUDA_SOURCES) $(ARKOUDA_MAKEFILES) | $(DOC_SERVER_OUTPUT_DIR) @echo "Building documentation for: Server" @# Build the documentation to the Chapel output directory - $(CHPLDOC) $(CHPLDOC_FLAGS) $(ARKOUDA_MAIN_SOURCE) -o $(DOC_SERVER_OUTPUT_DIR) + $(CHPLDOC) $(CHPLDOC_FLAGS) $(ARKOUDA_MAIN_SOURCE) $(ARKOUDA_SOURCE_DIR)/compat/ge-22/* -o $(DOC_SERVER_OUTPUT_DIR) @# Create the .nojekyll file needed for github pages in the Chapel output directory touch $(DOC_SERVER_OUTPUT_DIR)/.nojekyll @echo "Completed building documentation for: Server" diff --git a/src/ArgSortMsg.chpl b/src/ArgSortMsg.chpl index 12cd06ab61..312b16516e 100644 --- a/src/ArgSortMsg.chpl +++ b/src/ArgSortMsg.chpl @@ -11,7 +11,7 @@ module ArgSortMsg use Time; use Math only; - private use Sort; + private use ArkoudaSortCompat; use Reflection only; @@ -39,9 +39,9 @@ module ArgSortMsg proc dynamicTwoArrayRadixSort(ref Data:[], comparator:?rec=new DefaultComparator()) { if Data._instance.isDefaultRectangular() { - Sort.TwoArrayRadixSort.twoArrayRadixSort(Data, comparator); + ArkoudaSortCompat.TwoArrayRadixSort.twoArrayRadixSort(Data, comparator); } else { - Sort.TwoArrayDistributedRadixSort.twoArrayDistributedRadixSort(Data, comparator); + ArkoudaSortCompat.TwoArrayDistributedRadixSort.twoArrayDistributedRadixSort(Data, comparator); } } @@ -86,7 +86,7 @@ module ArgSortMsg // (isInt(x(0)) || isUint(x(0)) || isReal(x(0))) { import Reflection.canResolveMethod; - record ContrivedComparator { + record ContrivedComparator: keyPartComparator { const dc = new DefaultComparator(); proc keyPart(a, i: int) { if canResolveMethod(dc, "keyPart", a, 0) { @@ -123,9 +123,9 @@ module ArgSortMsg part = makePart(x[1]); } if i > x[0].size { - return (-1, 0:uint(64)); + return (keyPartStatus.pre, 0:uint(64)); } else { - return (0, part); + return (keyPartStatus.returned, part); } } else { for param j in 0..= x.size { - return (-1, 0:uint(64)); + return (keyPartStatus.pre, 0:uint(64)); } else { - return (0, part); + return (keyPartStatus.returned, part); } } } diff --git a/src/RadixSortLSD.chpl b/src/RadixSortLSD.chpl index 45108052de..a789e30e06 100644 --- a/src/RadixSortLSD.chpl +++ b/src/RadixSortLSD.chpl @@ -22,16 +22,17 @@ module RadixSortLSD use RangeChunk; use Logging; use ServerConfig; + use ArkoudaSortCompat except isSorted; private config const logLevel = ServerConfig.logLevel; private config const logChannel = ServerConfig.logChannel; const rsLogger = new Logger(logLevel, logChannel); - record KeysComparator { + record KeysComparator: keyComparator { inline proc key(k) { return k; } } - record KeysRanksComparator { + record KeysRanksComparator: keyComparator { inline proc key(kr) { const (k, _) = kr; return k; } } diff --git a/src/SegStringSort.chpl b/src/SegStringSort.chpl index 9a7a4c5198..d98d76393e 100644 --- a/src/SegStringSort.chpl +++ b/src/SegStringSort.chpl @@ -1,6 +1,6 @@ module SegStringSort { use SegmentedString; - use Sort; + use ArkoudaSortCompat; use Time; use IO; use CTypes; @@ -26,7 +26,7 @@ module SegStringSort { private config const logChannel = ServerConfig.logChannel; const ssLogger = new Logger(logLevel, logChannel); - record StringIntComparator { + record StringIntComparator: keyPartComparator { proc keyPart((a0,_): (string, int), in i: int) { // Just run the default comparator on the string return (new DefaultComparator()).keyPart(a0, i); diff --git a/src/SortMsg.chpl b/src/SortMsg.chpl index 52bd6e96d9..22ba8b372b 100644 --- a/src/SortMsg.chpl +++ b/src/SortMsg.chpl @@ -4,7 +4,7 @@ module SortMsg use Time; use Math only; - use Sort only; + use ArkoudaSortCompat only relativeComparator; use Search only; use Reflection; use ServerErrors; @@ -201,14 +201,14 @@ module SortMsg return new MsgTuple(repMsg, MsgType.NORMAL); } - record leftCmp { + record leftCmp: relativeComparator { proc compare(a: real, b: real): int { if a < b then return -1; else return 1; } } - record rightCmp { + record rightCmp: relativeComparator { proc compare(a: real, b: real): int { if a <= b then return -1; else return 1; diff --git a/src/compat/eq-20/.gitignore b/src/compat/eq-20/.gitignore deleted file mode 100644 index f935021a8f..0000000000 --- a/src/compat/eq-20/.gitignore +++ /dev/null @@ -1 +0,0 @@ -!.gitignore diff --git a/src/compat/eq-20/ArkoudaSortCompat.chpl b/src/compat/eq-20/ArkoudaSortCompat.chpl new file mode 100644 index 0000000000..e04391d2d0 --- /dev/null +++ b/src/compat/eq-20/ArkoudaSortCompat.chpl @@ -0,0 +1,13 @@ +module ArkoudaSortCompat { + public use Sort; + + interface keyComparator {} + interface keyPartComparator {} + interface relativeComparator {} + + module keyPartStatus { + proc pre param do return -1; + proc returned param do return 0; + proc post param do return 1; + } +} diff --git a/src/compat/eq-21/.gitignore b/src/compat/eq-21/.gitignore deleted file mode 100644 index f935021a8f..0000000000 --- a/src/compat/eq-21/.gitignore +++ /dev/null @@ -1 +0,0 @@ -!.gitignore diff --git a/src/compat/eq-21/ArkoudaSortCompat.chpl b/src/compat/eq-21/ArkoudaSortCompat.chpl new file mode 100644 index 0000000000..e04391d2d0 --- /dev/null +++ b/src/compat/eq-21/ArkoudaSortCompat.chpl @@ -0,0 +1,13 @@ +module ArkoudaSortCompat { + public use Sort; + + interface keyComparator {} + interface keyPartComparator {} + interface relativeComparator {} + + module keyPartStatus { + proc pre param do return -1; + proc returned param do return 0; + proc post param do return 1; + } +} diff --git a/src/compat/ge-22/.gitignore b/src/compat/ge-22/.gitignore deleted file mode 100644 index f935021a8f..0000000000 --- a/src/compat/ge-22/.gitignore +++ /dev/null @@ -1 +0,0 @@ -!.gitignore diff --git a/src/compat/ge-22/ArkoudaSortCompat.chpl b/src/compat/ge-22/ArkoudaSortCompat.chpl new file mode 100644 index 0000000000..7d9c338766 --- /dev/null +++ b/src/compat/ge-22/ArkoudaSortCompat.chpl @@ -0,0 +1,3 @@ +module ArkoudaSortCompat { + public use Sort; +}