- Implement DS_DataStruct_Value_Add_I, DS_DataStruct_Flush_I() & DS_Free,

- dsbench testings...
This commit is contained in:
2024-05-01 13:28:27 +02:00
parent 42ab4c9029
commit 6c74ecb997
3 changed files with 268 additions and 215 deletions

View File

@@ -365,7 +365,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_VALUE_ALLOC";
LG_LOG_TRACE_0( LGD_LOG_LEVEL_DEFAULT, "CMD_VALUE_ALLOC called...");
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
if( DS_Alloc( (void **)Module_Ptr_Ptr, Root_Ptr, sizeof( T_Module)) != DSS_OK)
@@ -397,15 +397,14 @@ 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( Value_Ptr, *Args_Ptr, void *);
ND_VA_ARG_GET( Module_Ptr_Ptr, *Args_Ptr, T_Module **);
Command_Name = "NDD_CMD_VALUE_FREE";
/*
DS_Free( Root_Ptr, Value_Ptr);
*/
return( NDS_OK);
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
return( DS_Free( Root_Ptr, Module_Ptr_Ptr));
}
case NDD_CMD_VALUE_COMP:
@@ -878,9 +877,9 @@ 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, char *Arg3, FILE *File_Input)
{
DST_Status status;
int sub_choice_int1, sub_choice_int2, low, high, i, j, nb_removed, Nb_Detected, Nb_Corrected;
int sub_choice_int1, sub_choice_int2, low, high, i, j, inc, nb_removed, nb_detected, nb_corrected;
char *sub_choice_str;
T_Module Ref_Module, *Module_Ptr;
T_Module ref_module, *module_ptr;
char buf[ BUF_SIZE], local_arg1[ BUF_SIZE], local_arg2[ BUF_SIZE], local_arg3[ BUF_SIZE];
NDT_Index_Type index_subtype;
@@ -958,7 +957,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
}
else
{
LG_LOG_INFO_1( "Data structure: [%s] created", sub_choice_str);
LG_LOG_INFO_1( "Data structure: [%s] opened", sub_choice_str);
}
t_stop( t_exec);
@@ -972,33 +971,44 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
Command_Exec_Begin_Print( File_Output, Choice);
t_start( t_exec);
if( ( status = DS_DataStruct_Close( *DS_Ptr_Ptr, DSD_CLOSE) != DSS_OK))
if( ( status = DS_DataStruct_Close( *DS_Ptr_Ptr, DSD_CLOSE)) != DSS_OK)
{
LG_LOG_ERROR_1( "Can't close data structure: (%d)", status);
LG_LOG_ERROR_1( "Can't close data structure, status: (%d)", status);
}
else
{
LG_LOG_INFO_0( "Data structure closed");
*DS_Ptr_Ptr = NULL;
}
t_stop( t_exec);
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
break;
}
case DS_FLUSH:
{
Command_Exec_Begin_Print( File_Output, Choice);
t_start( t_exec);
if( ( status = DS_DataStruct_Flush( *DS_Ptr_Ptr)) != DSS_OK)
{
LG_LOG_ERROR_1( "Can't flush data structure, status: (%d)", status);
}
else
{
LG_LOG_INFO_0( "Data structure flushed");
}
t_stop( t_exec);
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
break;
}
/*
case DS_FLUSH:
{
Command_Exec_Begin_Print( File_Output, Choice);
t_start( t_exec);
ND_DataStruct_Flush( *DS_Ptr_Ptr);
t_stop( t_exec);
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
break;
}
case DS_CHECK:
{
Command_Exec_Begin_Print( File_Output, Choice);
@@ -1038,25 +1048,22 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
break;
}
/*
case DS_VALUE_ADD:
{
int order;
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Value");
Command_Index_Range_Get( File_Output, &low, &high, Arg1, Arg2, File_Input, Choice, "Value");
if( low != -1)
{
if( Arg2 == NULL)
if( Arg3 == NULL)
{
fprintf( File_Output, "DS_Value_Add: Add order ( 0:croissant | 1:decroissant) ? ");
fgets( buf, BUF_LEN ,stdin);
Arg2 = buf;
DBD_ARG_READ( Arg3, local_arg3, "DS_Value_Add: Add order ( 0:croissant | 1:decroissant): ");
}
order = atoi( Arg2);
order = atoi( Arg3);
// fprintf( File_Output, "DS_Value_Add: Adding from: (%d) to: (%d) order: (%d)...\n", low, high, order);
// fflush( File_Output);
@@ -1064,51 +1071,36 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
LG_LOG_INFO_3( "DS_Value_Add: Adding from: (%d) to: (%d) order: (%d)...", low, high, order);
t_start( t_exec);
if( order == 0)
{
i = low;
j = high + 1;
while( i < j)
{
if( ND_Value_Alloc( (void **)&Module_Ptr, *DS_Ptr_Ptr, "x", i) == NDS_OK)
{
ND_DataStruct_Value_Add( *DS_Ptr_Ptr, Module_Ptr);
}
else
{
// fprintf( File_Output, "DS_Value_Add: Allocation Failled !\n");
LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !");
break;
}
i++;
}
}
else
i = low;
j = high + 1;
inc = 1;
}
else
{
i = high;
j = low - 1;
i = high;
j = low - 1;
inc = -1;
}
t_start( t_exec);
while( i > j)
{
if( ND_Value_Alloc( (void **)&Module_Ptr, *DS_Ptr_Ptr, "x", i) == NDS_OK)
{
ND_DataStruct_Value_Add( *DS_Ptr_Ptr, Module_Ptr);
}
else
{
// fprintf( File_Output, "DS_Value_Add: Allocation Failled !\n");
LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !");
break;
}
i--;
}
}
while( i != j)
{
if( DS_Value_Alloc( (void **)&module_ptr, *DS_Ptr_Ptr, i, "x") == NDS_OK)
{
DS_DataStruct_Value_Add( *DS_Ptr_Ptr, module_ptr);
}
else
{
LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !");
break;
}
i += inc;
}
t_stop( t_exec);
@@ -1117,7 +1109,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
break;
}
/*
case DS_VALUE_REMOVE:
{
int order;
@@ -1191,15 +1183,19 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
break;
}
*/
case DS_VALUE_PRINT:
{
Command_Exec_Begin_Print( File_Output, Choice);
ND_DataStruct_Value_Print( File_Output, *DS_Ptr_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0);
if( ( status = DS_DataStruct_Value_Print( File_Output, *DS_Ptr_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0)) != DSS_OK)
{
LG_LOG_ERROR_1( "Unable to print data structure values, status: (%d)", status);
}
break;
}
/*
case DS_VALUE_FIND:
{
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Search");
@@ -1244,7 +1240,12 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
for( i = low; i <= high; i++)
{
DS_Index_Open( *DS_Ptr_Ptr, (NDT_Index_Id)i, DBD_IDX_TYPE_FIFO);
if( ( status = DS_Index_Open( *DS_Ptr_Ptr, (NDT_Index_Id)i, DBD_IDX_TYPE_FIFO)) != DSS_OK)
{
LG_LOG_ERROR_2( "Unable to open index: (%d), status: (%d)", i, status);
break;
}
}
t_stop( t_exec);