- Complete libnode.c LibLog support,

- Complete ndbench.c LibLog support,
- Add test-10M.ndb & test-10M-s.ndb test files.
This commit is contained in:
2024-04-21 12:54:13 +02:00
parent 67e20bbd87
commit 27f401dff6
6 changed files with 214 additions and 113 deletions

View File

@@ -43,6 +43,9 @@
# include <ver.h>
#endif
#include <log.h>
#include <node.h>
@@ -51,6 +54,10 @@
/* Defines */
/*----------------------------------------------------------------------------*/
#define LGD_MODULE_NAME "ndb"
#ifdef _LIBVER_SUPPORT
//VER_INFO_EXPORT( ndbench, "$Revision: 2.10 $", "$Name: $", __FILE__, "$Author: agibert $");
# define USAGE "Usage : %s [ --help | --version [-v] | --batch_run <batch_file_name>]\n"
@@ -58,8 +65,6 @@
# define USAGE "Usage : %s [ --help | --batch_run <batch_file_name>]\n"
#endif
#include <node.h>
#define QUIT 0
@@ -278,6 +283,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
ND_VA_ARG_GET( Cmd, *Args_Ptr, NDT_Command);
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *);
*/
ND_VA_ARG_GET( Reply_Index_Id_Ptr, *Args_Ptr, NDT_Index_Id *);
ND_VA_ARG_GET( Reply_Command_Ptr, *Args_Ptr, NDT_Command *);
ND_VA_ARG_GET( Cmd, *Args_Ptr, NDT_Command);
@@ -321,6 +327,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
ND_VA_LIST_CLOSE( user_args);
*/
ND_VA_ARG_GET( Module_Ptr_Ptr, *Args_Ptr, T_Module **);
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
@@ -359,6 +366,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
ND_VA_LIST_CLOSE( user_args);
*/
ND_VA_ARG_GET( Module_Ptr, *Args_Ptr, T_Module *);
@@ -384,6 +392,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
ND_VA_LIST_CLOSE( user_args);
*/
ND_VA_ARG_GET( Module1_Ptr, *Args_Ptr, T_Module *);
ND_VA_ARG_GET( Module2_Ptr, *Args_Ptr, T_Module *);
@@ -481,6 +490,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
void *Value_Ptr = Node_Ptr->Value;
*/
ND_VA_ARG_GET( Next_Node_Ptr, *Args_Ptr, NDT_Node *);
ND_VA_LIST_OPEN( lib_args, *Args_Ptr);
@@ -668,8 +678,9 @@ void Command_Get( int *choice, char **arg1, char **arg2, FILE *File_Output,
void Command_Exec_Begin_Print( FILE *File_Output, int Choice)
{
fprintf( File_Output, "%s: %s...\n", Command_Tab[Choice].Name, Command_Tab[Choice].FullName);
fflush( File_Output);
// fprintf( File_Output, "%s: %s...\n", Command_Tab[Choice].Name, Command_Tab[Choice].FullName);
LG_LOG_INFO_2( "%s: %s...", Command_Tab[Choice].Name, Command_Tab[Choice].FullName);
// fflush( File_Output);
}
@@ -677,18 +688,20 @@ void Command_Exec_Begin_Print( FILE *File_Output, int Choice)
/*----------------------------------------------------------------------------*/
/* Command_Exec_En_Print */
/* Command_Exec_End_Print */
/*----------------------------------------------------------------------------*/
void Command_Exec_End_Print( FILE *File_Output, int Choice, cpt T_Exec, int nb)
{
if( nb == 1)
{
fprintf( File_Output, "%s: Completed in (%.4f) second !\n", Command_Tab[Choice].Name, T_Exec.sec);
// fprintf( File_Output, "%s: Completed in (%.4f) second !\n", Command_Tab[Choice].Name, T_Exec.sec);
LG_LOG_INFO_2( "%s: Completed in (%.4f) second !", Command_Tab[Choice].Name, T_Exec.sec);
}
else
{
fprintf( File_Output, "%s: Completed in (%.4f) second, (%.2f) per second !\n", Command_Tab[Choice].Name, T_Exec.sec, nb / T_Exec.sec);
// fprintf( File_Output, "%s: Completed in (%.4f) second, (%.2f) per second !\n", Command_Tab[Choice].Name, T_Exec.sec, nb / T_Exec.sec);
LG_LOG_INFO_3( "%s: Completed in (%.4f) second, (%.2f) per second !", Command_Tab[Choice].Name, T_Exec.sec, nb / T_Exec.sec);
}
}
@@ -746,13 +759,13 @@ void Command_Index_Range_Get( FILE *File_Output, int *Low, int *High, char
void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, char *Arg1, char *Arg2, FILE *File_Input)
{
int low, high, i, j, nb_removed, Nb_Detected, Nb_Corrected;
int sub_choice, low, high, i, j, nb_removed, Nb_Detected, Nb_Corrected;
T_Module Ref_Module, *Module_Ptr;
char buf[BUF_SIZE];
NDT_Index_Type index_subtype;
fprintf( File_Output, "\n");
// fprintf( File_Output, "\n");
switch( Choice)
{
@@ -773,10 +786,10 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
Arg1 = buf;
}
Choice = atoi( Arg1);
sub_choice = atoi( Arg1);
t_start( t_exec);
ND_Library_Open( Choice);
ND_Library_Open( sub_choice);
t_stop( t_exec);
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
@@ -807,7 +820,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
Arg1 = buf;
}
Choice = atoi( Arg1);
sub_choice = atoi( Arg1);
for( i = 0; i < INDEX_NB; i++)
{
@@ -815,7 +828,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
}
t_start( t_exec);
if( Choice == 0)
if( sub_choice == 0)
{
ND_DataStruct_Open( DS_Ptr_Ptr, INDEX_NB, idx_type_tab, "Module_Manager", Module_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL);
}
@@ -909,9 +922,12 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
order = atoi( Arg2);
fprintf( File_Output, "DS_Value_Add: Adding from: (%d) to: (%d) order: (%d)...\n", low, high, order);
fflush( File_Output);
// fprintf( File_Output, "DS_Value_Add: Adding from: (%d) to: (%d) order: (%d)...\n", low, high, order);
// fflush( File_Output);
LG_LOG_INFO_3( "DS_Value_Add: Adding from: (%d) to: (%d) order: (%d)...", low, high, order);
t_start( t_exec);
if( order == 0)
@@ -927,7 +943,9 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
}
else
{
fprintf( File_Output, "DS_Value_Add: Allocation Failled !\n");
// fprintf( File_Output, "DS_Value_Add: Allocation Failled !\n");
LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !");
break;
}
@@ -947,7 +965,8 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
}
else
{
fprintf( File_Output, "DS_Value_Add: Allocation Failled !\n");
// fprintf( File_Output, "DS_Value_Add: Allocation Failled !\n");
LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !");
break;
}
@@ -1051,8 +1070,11 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
if( low != -1)
{
fprintf( File_Output, "DS_Value_Find: from: (%d) to: (%d)...\n", low, high);
fflush( File_Output);
// fprintf( File_Output, "DS_Value_Find: from: (%d) to: (%d)...\n", low, high);
// fflush( File_Output);
LG_LOG_INFO_2( "DS_Value_Find: from: (%d) to: (%d)...", low, high);
i = low;
j = high + 1;
@@ -1080,8 +1102,10 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
if( low != -1)
{
fprintf( File_Output, "Index_List_Open: Opening a FIFO List from: (%d) to: (%d)...\n", low, high);
fflush( File_Output);
// fprintf( File_Output, "Index_List_Open: Opening a FIFO List from: (%d) to: (%d)...\n", low, high);
// fflush( File_Output);
LG_LOG_INFO_2( "Index_List_Open: Opening a FIFO List from: (%d) to: (%d)...", low, high);
t_start( t_exec);
@@ -1104,9 +1128,10 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
if( low != -1)
{
// fprintf( File_Output, "Index_Tree_Open: Opening a balanced Tree from: (%d) to: (%d)...\n", low, high);
// fflush( File_Output);
fprintf( File_Output, "Index_Tree_Open: Opening a balanced Tree from: (%d) to: (%d)...\n", low, high);
fflush( File_Output);
LG_LOG_INFO_2( "Index_Tree_Open: Opening a balanced Tree from: (%d) to: (%d)...", low, high);
t_start( t_exec);
@@ -1129,9 +1154,10 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
if( low != -1)
{
// fprintf( File_Output, "Index_Close: Closing index from: (%d) to: (%d)...\n", low, high);
// fflush( File_Output);
fprintf( File_Output, "Index_Close: Closing index from: (%d) to: (%d)...\n", low, high);
fflush( File_Output);
LG_LOG_INFO_2( "Index_Close: Closing index from: (%d) to: (%d)...", low, high);
t_start( t_exec);
@@ -1197,7 +1223,8 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
if( index_subtype != NDD_INDEX_SUBTYPE_UNKNOWN)
{
fprintf( File_Output, "Index_List_SubType_Set: Setting List SubType to: (%d) (%s) !\n", index_subtype, ND_INDEX_SUBTYPE_VALUE_ASCII_GET( index_subtype));
// fprintf( File_Output, "Index_List_SubType_Set: Setting List SubType to: (%d) (%s) !\n", index_subtype, ND_INDEX_SUBTYPE_VALUE_ASCII_GET( index_subtype));
LG_LOG_INFO_2( "Index_List_SubType_Set: Setting List SubType to: (%d) (%s) !", index_subtype, ND_INDEX_SUBTYPE_VALUE_ASCII_GET( index_subtype));
t_start( t_exec);
@@ -1299,8 +1326,10 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
for( i = low; i <= high; i++)
{
fprintf( File_Output, "Index_Reorg: Reorganizing index (%d)...\n", i);
fflush( File_Output);
// fprintf( File_Output, "Index_Reorg: Reorganizing index (%d)...\n", i);
// fflush( File_Output);
LG_LOG_INFO_1( "Index_Reorg: Reorganizing index (%d)...", i);
ND_Index_Reorg( *DS_Ptr_Ptr, (NDT_Index_Id)i);
}
@@ -1323,8 +1352,10 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
for( i = low; i <= high; i++)
{
fprintf( File_Output, "Index_Tree_To_List: Converting Index (%d)...\n", i);
fflush( File_Output);
// fprintf( File_Output, "Index_Tree_To_List: Converting Index (%d)...\n", i);
// fflush( File_Output);
LG_LOG_INFO_1( "Index_Tree_To_List: Converting Index (%d)...", i);
ND_Index_Convert( *DS_Ptr_Ptr, (NDT_Index_Id)i, idx_type_sorted_list);
}
@@ -1347,8 +1378,10 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
for( i = low; i <= high; i++)
{
fprintf( File_Output, "Index_List_To_Tree: Converting Index (%d)...\n", i);
fflush( File_Output);
// fprintf( File_Output, "Index_List_To_Tree: Converting Index (%d)...\n", i);
// fflush( File_Output);
LG_LOG_INFO_1( "Index_List_To_Tree: Converting Index (%d)...", i);
ND_Index_Convert( *DS_Ptr_Ptr, (NDT_Index_Id)i, idx_type_balanced_tree);
}
@@ -1367,8 +1400,10 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
if( low != -1)
{
fprintf( File_Output, "Index_Info_Print: Printing index from: (%d) to: (%d)...\n", low, high);
fflush( File_Output);
// fprintf( File_Output, "Index_Info_Print: Printing index from: (%d) to: (%d)...\n", low, high);
// fflush( File_Output);
LG_LOG_INFO_2( "Index_Info_Print: Printing index from: (%d) to: (%d)...", low, high);
for( i = low; i <= high; i++)
{
@@ -1381,8 +1416,10 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
case INDEX_VALUE_PRINT:
{
fprintf( File_Output, "DS_Value_Print:\n");
fflush( File_Output);
// fprintf( File_Output, "DS_Value_Print:\n");
// fflush( File_Output);
LG_LOG_INFO_0( "DS_Value_Print:");
ND_DataStruct_Value_Print( File_Output, *DS_Ptr_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0);
break;
@@ -1408,15 +1445,19 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
position = atoi( Arg2);
fprintf( File_Output, "Index_Value_Break: Breaking %s values from index : (%d) to: (%d)...\n",
// fprintf( File_Output, "Index_Value_Break: Breaking %s values from index : (%d) to: (%d)...\n",
// ( position == 0 ) ? "Head" : ( ( position == 1) ? "Tail" : "Random"),
// low, high);
// fflush( File_Output);
LG_LOG_INFO_3( "Index_Value_Break: Breaking: (%s) values from index: (%d) to: (%d)...",
( position == 0 ) ? "Head" : ( ( position == 1) ? "Tail" : "Random"),
low, high);
fflush( File_Output);
t_start( t_exec);
fprintf( File_Output, "Index_Value_Break: Breaking value of nodes: ");
fflush( File_Output);
// fprintf( File_Output, "Index_Value_Break: Breaking value of nodes: ");
// fflush( File_Output);
for( i = low; i <= high; i++)
{
@@ -1447,8 +1488,10 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
}
}
fprintf( File_Output, "0x(%x)", node_ptr);
fflush( File_Output);
// fprintf( File_Output, "0x(%x)", node_ptr);
// fflush( File_Output);
LG_LOG_INFO_1( "Index_Value_Break: Breaking value of node: 0x(%x)", node_ptr);
node_ptr->Value = (void *)-1;
}
@@ -1480,9 +1523,12 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
for( i = low; i <= high; i++)
{
fprintf( File_Output, "Index_Check: Checking Index (%d)...\n", i);
fprintf( File_Output, "Index_Check: ");
fflush( File_Output);
// fprintf( File_Output, "Index_Check: Checking Index (%d)...\n", i);
// fprintf( File_Output, "Index_Check: ");
// fflush( File_Output);
LG_LOG_INFO_1( "Index_Check: Checking Index (%d)...", i);
LG_LOG_INFO_0( "Index_Check: ");
Nb_Corrected = Nb_Detected = 0;
ND_Index_Check( *DS_Ptr_Ptr, (NDT_Index_Id)i, &Nb_Detected, &Nb_Corrected, File_Output);
@@ -1514,15 +1560,21 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
if( file_input == NULL)
{
fprintf( File_Output, "Batch_Run: Can't open file (%s)!\n", Arg1);
// fprintf( File_Output, "Batch_Run: Can't open file (%s)!\n", Arg1);
LG_LOG_ERROR_1( "Batch_Run: Can't open file (%s)!", Arg1);
}
else
{
fprintf( File_Output, "\n\n--------------------------------------------------------------------------------\n");
fprintf( File_Output, "Batch_Run: Starting execution (%s)...\n", Arg1);
// fprintf( File_Output, "\n\n--------------------------------------------------------------------------------\n");
// fprintf( File_Output, "Batch_Run: Starting execution (%s)...\n", Arg1);
LG_LOG_INFO_0( "--------------------------------------------------------------------------------");
LG_LOG_INFO_1( "Batch_Run: Starting execution (%s)...", Arg1);
Batch_Run( DS_Ptr_Ptr, File_Output, file_input, 0);
fprintf( File_Output, "\n");
fprintf( File_Output, "Batch_Run: Ending execution (%s)...\n", Arg1);
// fprintf( File_Output, "\n");
// fprintf( File_Output, "Batch_Run: Ending execution (%s)...\n", Arg1);
LG_LOG_INFO_1( "Batch_Run: Ending execution (%s)...", Arg1);
fclose( file_input);
}
@@ -1581,11 +1633,21 @@ void Batch_Run( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, FILE *File_Input,
int main( int argc, char **argv)
{
NDT_Root *ds_ptr = NULL;
int rc = 0;
LGT_Status lg_status;
NDT_Root *ds_ptr = NULL;
if( ( lg_status = LG_Library_Open( LGD_LOG_WRITER_DEFAULT, true)) != LGS_OK)
{
fprintf( stderr, "Can't open LibLog library: (%d)\n", lg_status);
return( -1);
}
LG_LOG_INFO_0( "Start NDBench");
/* Init Random numbers... */
t_start( t_exec);
t_stop( t_exec);
srand( seed_get(t_exec));
@@ -1599,18 +1661,18 @@ int main( int argc, char **argv)
if( !strcmp( argv[1], "--help"))
{
fprintf( stderr, USAGE, argv[0]);
return( 1);
rc = 1;
}
#ifdef _LIBVER_SUPPORT
else if( !strcmp( argv[1], "--version"))
{
if( argc >= 3 && !strcmp( argv[2], "-v"))
{
return( VER_Object_Print( stdout, VERD_VERBOSE));
ec = VER_Object_Print( stdout, VERD_VERBOSE);
}
else
{
return( VER_Object_Print( stdout, VERD_MINIMAL));
rc = VER_Object_Print( stdout, VERD_MINIMAL);
}
}
#endif
@@ -1619,21 +1681,30 @@ int main( int argc, char **argv)
/* Batch Mode */
Command_Exec( &ds_ptr, stdout, BATCH_RUN, argv[2], NULL, stdin);
return( 0);
rc = 0;
}
else
{
fprintf( stderr, USAGE, argv[0]);
return( -1);
rc = -1;
}
}
else
{
/* Interactive Mode */
Batch_Run( &ds_ptr, stdout, stdin, 1);
rc = 0;
}
LG_LOG_INFO_0( "End NDBench");
if( ( lg_status = LG_Library_Close( true)) != LGS_OK)
{
fprintf( stderr, "Can't close LibLog library: (%d)\n", lg_status);
rc = -1;
}
/* Interactive Mode */
Batch_Run( &ds_ptr, stdout, stdin, 1);
return( 0);
return( rc);
}

10
util/test-10M-s.ndb Normal file
View File

@@ -0,0 +1,10 @@
Lib_Open 0
DS_Open 1
Index_List_Open 0-0
DS_Value_Add 1-10000000 0
DS_Value_Find 4999990-5000010
Index_List_To_Tree 0-0
DS_Value_Find 1-10000000
DS_Check
DS_Close
Lib_Close

10
util/test-10M.ndb Normal file
View File

@@ -0,0 +1,10 @@
Lib_Open 0
DS_Open 0
Index_List_Open 0-0
DS_Value_Add 1-10000000 0
DS_Value_Find 4999990-5000010
Index_List_To_Tree 0-0
DS_Value_Find 1-10000000
DS_Check
DS_Close
Lib_Close

View File

@@ -7,3 +7,5 @@ Batch_Run test-100K.ndb
Batch_Run test-100K-s.ndb
Batch_Run test-1M.ndb
Batch_Run test-1M-s.ndb
Batch_Run test-10M.ndb
Batch_Run test-10M-s.ndb