Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
5f2e901
Checkpoint: Switching to DM UI project.
Oct 13, 2025
994e99f
Checkpoint: Switching to DM project.
Oct 14, 2025
ea6430f
Checkpoing: Switching to DM project.
Oct 16, 2025
cf0dbb5
Finish implementing major features for the cluster driver.
Oct 27, 2025
a861fb4
Upgrade memory handling in the cluster driver.
Oct 28, 2025
b4634f3
Begin adding query files to search for duplicates.
Oct 30, 2025
63a4dc2
Add warning for providing an invalid parameter.
Nov 7, 2025
22e55a3
Merge branch 'master' into dups
Nov 7, 2025
4b656a4
Improve exp_functions() to use central schema verification.
Nov 13, 2025
fa28afa
Add ClusterDriverRequirements (forgot to commit them before).
Nov 14, 2025
81a1d2f
Clean up unintended usage of glyph.h
Nov 14, 2025
e624d40
Attempt to reduce issues from ambiguously signed chars.
Nov 14, 2025
b0e000b
All tests now pass.
Nov 17, 2025
0874365
Re-apply reduced weight for duplicate pairs (temporarily turned off l…
Nov 17, 2025
01d918a
Clean up.
Nov 17, 2025
42a65f1
Update licences.
Nov 17, 2025
b281037
Clean up.
Nov 17, 2025
ee0bca7
Add "show_less" option to the cache method (skips printing uncomputed…
Nov 19, 2025
0c9eb2c
Update cluster library to use dynamic memory for any data over a coup…
Nov 19, 2025
394764e
Remove necessary requests for the driver name in objQueryFetch().
Nov 19, 2025
9b8cc19
Fix bugs that caused regressions after the updates to the cluster lib…
Nov 20, 2025
17156b7
Fix an invalid free (nmFree used instead of nmSysFree()).
Nov 20, 2025
648e30a
Merge branch 'master' into dups
Nov 20, 2025
29640a1
Minor improvements and clean up.
Nov 20, 2025
0fa62d3
Correct minor mistakes.
Nov 20, 2025
d3b571c
Merge branch 'master' into dups
Nov 22, 2025
06bae81
Implement a more extendable schema verification system.
Nov 21, 2025
13fd4b7
Replace old schema verification with the new system.
Nov 21, 2025
e83c15f
Expand the new schema verification system with extra data validation …
Nov 21, 2025
070cfe3
Clean up, bug fixes, and naming convention updates.
Nov 21, 2025
8795aaf
Add tests for log and power functions.
Nov 22, 2025
2e948d8
Add exp_fn_i_get_number().
Nov 22, 2025
4c347be
Add exp_fn_i_do_math() to bring the power of schema verification to l…
Nov 22, 2025
d177522
Minor clean up.
Lightning11wins Nov 25, 2025
7b49a5b
Address Greg's comments
Lightning11wins Dec 11, 2025
e9c10a5
Merge branch 'exp-schema' into dups
Lightning11wins Dec 11, 2025
b6abca7
Finish exp_functions.c work.
Lightning11wins Dec 11, 2025
8c86b5f
Organize docs.
Lightning11wins Dec 12, 2025
63fa5ba
Fix wrong stAddValue() info caused by reading old code.
Lightning11wins Dec 12, 2025
d0d4f54
Clean up stale TOODs.
Lightning11wins Dec 12, 2025
3b86627
Fix more styling mistakes.
Lightning11wins Dec 12, 2025
6b83c67
Fix indentation mistakes (thanks Centrallix Indent extension).
Lightning11wins Dec 15, 2025
66029f5
Rename functions to use the proper prefix everywhere.
Lightning11wins Jan 8, 2026
fce7a2c
Update magic.h to prepare for implementing magic on all cluster drive…
Lightning11wins Jan 8, 2026
b9defb8
Refactor some cluster driver code to make it cleaner.
Lightning11wins Jan 8, 2026
636814e
Add magic.h to all major cluster driver structs.
Lightning11wins Jan 8, 2026
495597e
Fix a broken test by increasing the tolerance for reasonable deviations.
Lightning11wins Jan 8, 2026
ab71333
Compile tests with -lm to prevent sporadic linker errors.
Lightning11wins Jan 28, 2026
65e4458
Fix a critical driver bug causing levenshtein to be executed on the c…
Lightning11wins Jan 28, 2026
68d1c68
Merge branch 'refs/heads/master' into dups
Lightning11wins Jan 28, 2026
8ba449e
Fix a major bug where punctuation and whitespace was not properly ign…
Lightning11wins Jan 28, 2026
2be1d22
Remove a broken link in clusters.h.
Lightning11wins Jan 30, 2026
814fcfa
Fix code that assumed DateTime->Value was seconds since the epoch (it…
Lightning11wins Mar 16, 2026
8917ae2
Clean up code and comments.
Lightning11wins Mar 16, 2026
6eeeb2d
Add seed attribute to cluster driver.
Lightning11wins Mar 17, 2026
c561728
Improve support for IntVec and StringVec attribute types.
Lightning11wins Mar 18, 2026
ee9c410
Rename NameAttr to DataAttr in SourceData struct to match KeyAttr.
Lightning11wins Mar 18, 2026
f8aa100
Fix clusterGetAttrValue() asserting MGK_CL_CLUSTER_DATA on SearchData…
Lightning11wins Mar 18, 2026
7dfc69b
Switch stats struct to use compile-time initialization (for consisten…
Lightning11wins Mar 18, 2026
d1c2185
Improve error messages in ci_ComputeSourceData().
Lightning11wins Mar 18, 2026
fd289ff
Refactor clusters to store an array of indexes into the SourceData st…
Lightning11wins Mar 18, 2026
dbc01f2
Fix spelling errors and improve comments.
Lightning11wins Mar 18, 2026
4e96440
Add a test case for the cluster driver.
Lightning11wins Mar 18, 2026
c7c6fcb
Fix the keys field in the SourceData struct not being properly freed …
Lightning11wins Mar 18, 2026
b411968
Update sizeof functions to return size_t instead of unsigned int.
Lightning11wins Mar 18, 2026
0fcf5e5
Update generated HTML by running make in centrallix-doc/Widgets.
Lightning11wins Mar 18, 2026
f47c678
Update copyright notices to use correct dates.
Lightning11wins Mar 18, 2026
e799efa
Fix typo that stated the signed int max was 2147483629.
Lightning11wins Mar 18, 2026
b9a9d36
Update macros.
Lightning11wins Mar 18, 2026
c9241cf
Fix error handling.
Lightning11wins Mar 18, 2026
5fd3d96
Reimplement some code in ca_build_vector() so we don't need to use a …
Lightning11wins Mar 18, 2026
3e57fa6
Fix spelling mistakes and clean up comments.
Lightning11wins Mar 18, 2026
32ef9e0
Use ca_parse_vector_token() to abstract sparse vector parsing logic.
Lightning11wins Mar 18, 2026
00bdc0e
Rename params for ca_parse_vector_token() to improve readability.
Lightning11wins Mar 18, 2026
118e22b
Fix an incorrect doc comment.
Lightning11wins Mar 18, 2026
19cd50b
Fix vector function bugs.
Lightning11wins Mar 18, 2026
ebb9585
Implement improved workaround for mssError() not supporting %c.
Lightning11wins Mar 18, 2026
6544e4e
Update doc comments.
Lightning11wins Mar 19, 2026
9de3d40
Update attribute lists.
Lightning11wins Mar 19, 2026
9cac9b8
Add `README.md` to explain the new datasets directory.
Lightning11wins Mar 19, 2026
98d8a11
Update `README.md` with knowledge learned from testing updates to fil…
Lightning11wins Mar 19, 2026
a0936d6
Improve OSDriver_Authoring.md with Noah's comments.
Lightning11wins Mar 19, 2026
f8572ad
Rewrite mssError() with lessons learned from mssErrorf().
Lightning11wins Mar 19, 2026
ddd99f6
Replace ci_xaToTrimmedArray() with xaToArray().
Lightning11wins Mar 19, 2026
d17c043
Fix a bug in exp_fn_compare() any correct use of the function to fals…
Lightning11wins Mar 19, 2026
8d5364e
Add detail to the description in the copyright notice for the cluster…
Lightning11wins Mar 19, 2026
7e2979b
Improve how enums are implemented in objdrv_cluster.c.
Lightning11wins Mar 19, 2026
59eda46
Re-add typecasts that I removed because I thought they were optional.
Lightning11wins Mar 19, 2026
cf26c09
Fix a memory error.
Lightning11wins Mar 19, 2026
f447c19
Move file name and file path macros to obj.h to promote future reuse.
Lightning11wins Mar 19, 2026
9449178
Refactor attribute name lists to improve reusability and extendability.
Lightning11wins Mar 19, 2026
fd84d79
Revisit attributes offered by the cluster driver.
Lightning11wins Mar 19, 2026
00c07f1
Improve the cluster driver testcase to test the default attribute lists.
Lightning11wins Mar 19, 2026
b540a38
Improve driver with testing.
Lightning11wins Mar 20, 2026
e27308e
Update an example on OSDriver_Authoring.md because the sybase driver …
Lightning11wins Mar 20, 2026
bda9eac
Improve structs.
Lightning11wins Mar 20, 2026
62eebee
Modify min_improvement field in the driver schema to only accept doub…
Lightning11wins Mar 20, 2026
d6e9d98
Fix a bug in the new mssError() implementation.
Lightning11wins Mar 20, 2026
71b3c60
Clean up.
Lightning11wins Mar 20, 2026
fa048eb
Rename Key fields to CacheKey to reduce confusion with the Keys fetch…
Lightning11wins Mar 20, 2026
99f0a29
Clean up and updates.
Lightning11wins Mar 20, 2026
33d6150
Fix bugs and clean up.
Lightning11wins Mar 20, 2026
b2e0f35
Address Greptile comments.
Lightning11wins Mar 23, 2026
326a475
Update error handling in exp_fn_metaphone().
Lightning11wins Mar 23, 2026
06f07b9
Modify check function syntax.
Lightning11wins Mar 23, 2026
0c8f5cc
Overhaul error checking in double_metaphone.c.
Lightning11wins Mar 23, 2026
011d952
Fix cluster driver not setting freed computed data to NULL.
Lightning11wins Mar 23, 2026
8506a39
Clean up some typos and bugs.
Lightning11wins Mar 23, 2026
f1e6bfe
Fix bug from Greptile.
Lightning11wins Mar 24, 2026
e705a68
Improve string buffer handling in exp_functions.c.
Lightning11wins Mar 24, 2026
9a88787
Expand cluster driver test case.
Lightning11wins Mar 24, 2026
dfbd6c4
Merge branch 'refs/heads/master' into dups
Lightning11wins Mar 24, 2026
07129f8
Fix expect.
Lightning11wins Mar 26, 2026
cc85e7b
Merge branch 'refs/heads/fix-expect' into dups
Lightning11wins Mar 26, 2026
b369ee4
Add code to use expect.h features.
Lightning11wins Mar 26, 2026
5ea6848
Fix Greptile comments.
Lightning11wins Mar 26, 2026
0a96f95
Fix Greptile comments.
Lightning11wins Mar 26, 2026
44df6fc
Fix the fix because the previous fix was badly designed.
Lightning11wins Mar 26, 2026
a041dca
Merge branch 'refs/heads/fix-expect' into dups
Lightning11wins Mar 26, 2026
ef1107b
Update and reduce returns in the cluster driver.
Lightning11wins Mar 26, 2026
de74a99
Add recursion checks and update recursion error messages.
Lightning11wins Mar 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ perf.data.old
.idea/
.vscode/
centrallix-os/tmp/*
centrallix-os/datasets/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The centrallix-os/datasets folder does not exist in the repo, and its not used anywhere by anything in centrallix that I can tell. I would recommend either removing it from the git ignore if it's only used by you, or if it's needed by something (perhaps a Kardia branch?) adding a simple readme so the folder exists in the repo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added README.md.

2 changes: 1 addition & 1 deletion centrallix-doc/Widgets/onepage.html
Original file line number Diff line number Diff line change
Expand Up @@ -5976,7 +5976,7 @@ <h3 class="childproperties">Child Properties:</h3>
<tr>
<td class="name">type</td>
<td class="type">string</td>
<td class="description">The type of the column: "text", "check", or "image". "text" is a normal column, and displays the textual value of the data element. "check" displays a checkmark if the data is non-zero (integers) or for strings if the value is non-empty and not "N" or "No". "image" displays the image referred to by the pathname contained in the data value.</td>
<td class="description">The type of the column: "text", "check", "image", or "progress". "text" is a normal column, and displays the textual value of the data element. "check" displays a checkmark if the data is non-zero (integers) or for strings if the value is non-empty and not "N" or "No". "image" displays the image referred to by the pathname contained in the data value. "progress" displays a progress bar, with additional fields such as bar_color, bar_textcollor, and bar_padding.</td>
</tr>
<tr>
<td class="name">width</td>
Expand Down
2 changes: 1 addition & 1 deletion centrallix-doc/Widgets/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ <h3 class="childproperties">Child Properties:</h3>
<tr>
<td class="name">type</td>
<td class="type">string</td>
<td class="description">The type of the column: "text", "check", or "image". "text" is a normal column, and displays the textual value of the data element. "check" displays a checkmark if the data is non-zero (integers) or for strings if the value is non-empty and not "N" or "No". "image" displays the image referred to by the pathname contained in the data value.</td>
<td class="description">The type of the column: "text", "check", "image", or "progress". "text" is a normal column, and displays the textual value of the data element. "check" displays a checkmark if the data is non-zero (integers) or for strings if the value is non-empty and not "N" or "No". "image" displays the image referred to by the pathname contained in the data value. "progress" displays a progress bar, with additional fields such as bar_color, bar_textcollor, and bar_padding.</td>
</tr>
<tr>
<td class="name">width</td>
Expand Down
2 changes: 1 addition & 1 deletion centrallix-doc/Widgets/widgets.xml
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you need to run make in the centrallix-doc/Widgets directory to propagate the XML change to the relevant HTML files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for showing me how to build the HTML, done.

Original file line number Diff line number Diff line change
Expand Up @@ -3731,7 +3731,7 @@ myTabControl "widget/tab"

<childproperty name="title" type="string">The title of the column to be displayed in the header row.</childproperty>

<childproperty name="type" type="string">The type of the column: "text", "check", or "image". "text" is a normal column, and displays the textual value of the data element. "check" displays a checkmark if the data is non-zero (integers) or for strings if the value is non-empty and not "N" or "No". "image" displays the image referred to by the pathname contained in the data value.</childproperty>
<childproperty name="type" type="string">The type of the column: "text", "check", "image", or "progress". "text" is a normal column, and displays the textual value of the data element. "check" displays a checkmark if the data is non-zero (integers) or for strings if the value is non-empty and not "N" or "No". "image" displays the image referred to by the pathname contained in the data value. "progress" displays a progress bar, with additional fields such as bar_color, bar_textcollor, and bar_padding.</childproperty>

<childproperty name="width" type="integer">width of the column.</childproperty>

Expand Down
6 changes: 3 additions & 3 deletions centrallix-lib/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ LIBS = @LIBS@
##
PROFILE=@PROFILE@
COVERAGE=@COVERAGE@
CFLAGS=@CFLAGS@ @DEFS@ -Iinclude -DCXLIB_INTERNAL -DNM_USE_SYSMALLOC -Wall $(PROFILE) $(COVERAGE) -g
CFLAGS=@CFLAGS@ @DEFS@ -Iinclude -DCXLIB_INTERNAL -DNM_USE_SYSMALLOC -Wall $(PROFILE) $(COVERAGE) -g -lm
MTCFLAGS=@CFLAGS@ @DEFS@ -Iinclude -DCXLIB_INTERNAL -DNM_USE_SYSMALLOC -Wall $(PROFILE) $(COVERAGE) -g -O0
TCFLAGS=$(patsubst -DNDEBUG,,$(CFLAGS))

XSTATICFILES=mtask.o mtlexer.o memstr.o xarray.o xhash.o xstring.o mtsession.o newmalloc.o xhashqueue.o bdqs_transport.o xhandle.o xringqueue.o cxsec.o smmalloc.o qprintf.o strtcpy.o util.o
XSTATICFILES=mtask.o mtlexer.o memstr.o xarray.o xhash.o xstring.o mtsession.o newmalloc.o xhashqueue.o bdqs_transport.o xhandle.o xringqueue.o cxsec.o smmalloc.o clusters.o qprintf.o strtcpy.o util.o
STATICFILES=$(patsubst %,src/%,$(XSTATICFILES))

XDYNAMICFILES=mtask.lo mtlexer.lo memstr.lo xarray.lo xhash.lo xstring.lo mtsession.lo newmalloc.lo xhashqueue.lo bdqs_transport.lo xhandle.lo xringqueue.lo cxsec.lo smmalloc.lo qprintf.lo strtcpy.lo util.lo
XDYNAMICFILES=mtask.lo mtlexer.lo memstr.lo xarray.lo xhash.lo xstring.lo mtsession.lo newmalloc.lo xhashqueue.lo bdqs_transport.lo xhandle.lo xringqueue.lo cxsec.lo smmalloc.lo clusters.lo qprintf.lo strtcpy.lo util.lo
DYNAMICFILES=$(patsubst %,src/%,$(XDYNAMICFILES))

INCLUDEFILES:=$(wildcard include/*.h)
Expand Down
2 changes: 1 addition & 1 deletion centrallix-lib/aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ AC_DEFUN(CHECK_BUILTIN_EXPECT,
AC_DEFINE([HAVE_BUILTIN_EXPECT], [1], [Define if __builtin_expect is available])
AC_MSG_RESULT([yes])
],
[AC_MSG_RESULT([no])],
[AC_MSG_RESULT([no])]
)
]
)
Expand Down
1 change: 1 addition & 0 deletions centrallix-lib/configure
Original file line number Diff line number Diff line change
Expand Up @@ -4104,6 +4104,7 @@ $as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }

fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

Expand Down
161 changes: 161 additions & 0 deletions centrallix-lib/include/clusters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
#ifndef CLUSTERS_H
#define CLUSTERS_H

/************************************************************************/
/* Centrallix Application Server System */
/* Centrallix Core */
/* */
/* Copyright (C) 1998-2026 LightSys Technology Services, Inc. */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA */
/* 02111-1307 USA */
/* */
/* A copy of the GNU General Public License has been included in this */
/* distribution in the file "COPYING". */
/* */
/* Module: lib_cluster.c, lib_cluster.h */
/* Author: Israel Fuller */
/* Creation: September 29, 2025 */
/* Description Clustering library used to cluster and search data with */
/* cosine or Levenshtein (aka. edit distance) similarity */
/* measures. Used by the "clustering driver". */
/* For more information on how to use this library, see */
/* string-similarity.md in the centrallix-sysdoc folder. */
/************************************************************************/

#include <stdlib.h>
#include <stdbool.h>

#ifdef CXLIB_INTERNAL
#include "xarray.h"
#else
#include "cxlib/xarray.h"
#endif

/** This file has additional documentation in string_similarity.md. **/


/*** This value defines the number of dimensions used for a sparse
*** vector. The higher the number, the fewer collisions will be
*** encountered when using these vectors for cosine comparisons.
*** This is also called the vector table size, if viewing the
*** vector as a hash table of character pairs.
***
*** 2147483647 is the signed int max, and is also a prime number.
*** Using this value ensures that the longest run of 0s will not
*** cause an int underflow with the current encoding scheme.
***
*** Unfortunately, we can't use a number this large yet because
*** kmeans algorithm creates densely allocated centroids with
*** `CA_NUM_DIMS` dimensions, so a large number causes it to fail.
*** This, we use 251 as the largest prime number less than 256,
*** giving us a decent balance between collision reduction and
*** kmeans centroid performance/memory overhead.
***/
#define CA_NUM_DIMS 251

/*** The character used to create a pair with the first and last characters
*** of a string. Currently set to 96, the character just before 'a' (97)
*** in the ASCII table.
***/
#define CA_BOUNDARY_CHAR ((unsigned char)('a' - 1))

/** Types. **/
typedef int* pVector; /* Sparse vector. */
typedef double* pCentroid; /* Dense centroid. */
#define CENTROID_SIZE (CA_NUM_DIMS * sizeof(double))

/*** Information about detected matching pairs.
***
*** @param i The index into the provided data for the first element of the pair.
*** @param j The index into the provided data for the second element of the pair.
*** @param similarity A number from 0 to 1, from a similarity function, showing
*** how similar the pairs are.
***/
typedef struct
{
unsigned int i, j;
double similarity;
}
Pair, *pPair;


/** Edit distance function. **/
int ca_edit_dist(const char* str1, const char* str2, const size_t str1_length, const size_t str2_length);

/** Vector functions. **/
pVector ca_build_vector(const char* str);
unsigned int ca_sparse_len(const pVector vector);
void ca_print_vector(const pVector vector);
void ca_free_vector(pVector sparse_vector);

/** k-means function. **/
int ca_kmeans(
pVector* vectors,
const unsigned int num_vectors,
const unsigned int num_clusters,
const unsigned int max_iter,
const double min_improvement,
unsigned int* labels,
double* vector_sims,
bool auto_seed);

/** Vector helper macros. **/
#define ca_is_empty(vector) (vector[0] == -CA_NUM_DIMS)
/*** Note: Given that CA_NUM_DIMS == 251, ca_build_vector("") will give the
*** vector we check for in the ca_has_no_pairs() macro, [-172, 11, -78],
*** which has a single pair of boundary characters.
*** If CA_NUM_DIMS is modified, this macro will need to be updated, hence the
*** compiler directive causing it to be undefined in this case, likely leading
*** to a lot of compiler or linker issues to remind the developer about this.
***/
#if CA_NUM_DIMS == 251
#define ca_has_no_pairs(vector) \
({ \
__typeof__ (vector) _v = (vector); \
_v[0] == -172 && _v[1] == 11 && _v[2] == -78; \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the value of CA_NUM_DIMS changes, this function will not work properly. It could also use a comment to explain what the 3 numbers are meant to represent (I assume a number of empty slots, the value produced by the pair made by start/end, and then the remaining empty slots)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, added comments and used compiler directives to make sure that the macro won't be defined anymore if this assumption is not met. I think that would cause a bunch of compiler errors, which should remind anyone who changes CA_NUM_DIMS to come and update this macro, too.

})
#endif

/** Comparison functions (see ca_search()). **/
double ca_cos_compare(void* v1, void* v2);
double ca_lev_compare(void* str1, void* str2);
bool ca_eql(pVector v1, pVector v2);

/** Similarity search functions. **/
void* ca_most_similar(
void* target,
void** data,
const unsigned int num_data,
const double (*similarity)(void*, void*),
const double threshold);
pXArray ca_sliding_search(
void** data,
const unsigned int num_data,
const unsigned int window_size,
const double (*similarity)(void*, void*),
const double threshold,
pXArray maybe_pairs);
pXArray ca_complete_search(
void** data,
const unsigned int num_data,
const double (*similarity)(void*, void*),
const double threshold,
pXArray maybe_pairs);

/** Module management functions. **/
void ca_init(void);

#endif /* End of .h file. */
6 changes: 5 additions & 1 deletion centrallix-lib/include/cxlibconfig-internal.h.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/* include/cxlibconfig-internal.h.in. Generated from configure.ac by autoheader. */

/*** cxlibconfig-internal.h.in lists defines that are used by centrallix-lib
*** internally and will not be needed in other modules. For external
*** usecases, see cxlibconfig.h.in.
***/

/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT

Expand Down Expand Up @@ -34,4 +39,3 @@

/* defined to 1 if SIOCOUTQ is available */
#undef HAVE_SIOCOUTQ

9 changes: 9 additions & 0 deletions centrallix-lib/include/cxlibconfig.h.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/* include/cxlibconfig.h.in. Generated from configure.ac by autoheader. */

/*** cxlibconfig-h.in lists defines that should be availabe to anyone
*** using centrallix-lib. For example, a define used in an external .h
*** file should be written here so that the .h file can include it even
*** if it is used in another project.
***/

/* Define to 1 if you have the `endservent' function. */
#undef HAVE_ENDSERVENT

Expand Down Expand Up @@ -33,6 +39,9 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H

/* Define to 1 if you have the `__builtin_expect' function. */
#undef HAVE_BUILTIN_EXPECT

/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP

Expand Down
27 changes: 17 additions & 10 deletions centrallix-lib/include/expect.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/* GNU Lesser General Public License, Version 2.1, contained in the */
/* included file "COPYING". */
/* */
/* Module: Expect Branch Optimization Module (mtask.c, mtask.h) */
/* Module: Expect Branch Optimization Module (expect.h) */
/* Author: Israel Fuller */
/* Date: February 27th, 2026 */
/* */
Expand All @@ -23,19 +23,26 @@
/* true, UNLIKELY() indicates it is likely to be false. */
/************************************************************************/

#ifdef HAVE_CONFIG_H
#ifdef CXLIB_INTERNAL
#include "cxlibconfig.h"
#else
#include "cxlib/cxlibconfig.h"
#endif
#endif

/** Define macros for signalling the more likely branch to the compiler. **/
#ifdef HAVE_BUILTIN_EXPECT
/** Use the GCC __builtin_expect() function for optimization. **/
/** Note: We use !!(x) which normalizes to 0 or 1 to help the compiler. **/
#define LIKELY(x) (__builtin_expect(!!(x), 1))
#define UNLIKELY(x) (__builtin_expect(!!(x), 0))
/** Use the GCC __builtin_expect() function for optimization. **/
/** Note: We use !!(x) which normalizes to 0 or 1 to help the compiler. **/
#define LIKELY(x) (__builtin_expect(!!(x), 1))
#define UNLIKELY(x) (__builtin_expect(!!(x), 0))
#else
/*** Fallback: Define pass through functions to support compilers that don't
*** have this feature.
***/
#define LIKELY(x) (x)
#define UNLIKELY(x) (x)
/*** Fallback: Define pass through functions to support compilers that don't
*** have this feature.
***/
#define LIKELY(x) (x)
#define UNLIKELY(x) (x)
#endif

#endif
79 changes: 79 additions & 0 deletions centrallix-lib/include/glyph.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#ifndef GLYPH_H
#define GLYPH_H

/************************************************************************/
/* Centrallix Application Server System */
/* Centrallix Core */
/* */
/* Copyright (C) 1998-2026 LightSys Technology Services, Inc. */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License, or */
/* (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA */
/* 02111-1307 USA */
/* */
/* A copy of the GNU General Public License has been included in this */
/* distribution in the file "COPYING". */
/* */
/* Module: glyph.h */
/* Author: Israel Fuller */
/* Creation: October 27, 2025 */
/* Description: A simple debug visualizer to make pretty patterns in */
/* developer's terminal which can be surprisingly useful */
/* for debugging algorithms. */
/************************************************************************/

#include <stdlib.h>

/** Uncomment to activate glyphs. **/
/** Should not be enabled in production code on the master branch. */
// #define ENABLE_GLYPHS

#ifdef ENABLE_GLYPHS
#define glyph_print(s) printf("%s", s);

/*** Initialize a simple debug visualizer to make pretty patterns in the
*** developer's terminal. Great for when you need to run a long task and
*** want a super simple way to make sure it's still working.
***
*** @attention - Relies on storing data in variables in scope, so calling
*** glyph() requires a call to glyph_init() previously in the same scope.
***
*** @param name The symbol name of the visualizer.
*** @param str The string printed for the visualization.
*** @param interval The number of invocations of glyph() required to print.
*** @param flush Whether to flush on output.
***/
#define glyph_init(name, str, interval, flush) \
const char* vis_##name##_str = str; \
const unsigned int vis_##name##_interval = interval; \
const bool vis_##name##_flush = flush; \
unsigned int vis_##name##_i = 0u;

/*** Invoke a visualizer.
***
*** @param name The name of the visualizer to invoke.
***/
#define glyph(name) \
if (++vis_##name##_i % vis_##name##_interval == 0) \
{ \
glyph_print(vis_##name##_str); \
if (vis_##name##_flush) fflush(stdout); \
}
#else
#define glyph_print(str)
#define glyph_init(name, str, interval, flush)
#define glyph(name)
#endif

#endif /* End of .h file. */
Loading