- Add DS_DataStruct_Value_Find(), DS_Index_Reorg(),
- DSBech: Implement DS_Value_Remove, DS_Value_Find, Index_Close, Index_Reorg, Index_List_To_Tree & Index_Tree_To_List commands.
This commit is contained in:
227
util/dsbench.c
227
util/dsbench.c
@@ -1081,8 +1081,6 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
|
||||
order = atoi( Arg3);
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -1104,16 +1102,21 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
|
||||
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
|
||||
char tmp_name[ DSD_NAME_SIZE];
|
||||
|
||||
snprintf( tmp_name, DSD_NAME_LEN, "Element #: (%ld)", i);
|
||||
tmp_name[ DSD_NAME_LEN] = '\0';
|
||||
|
||||
if( DS_Value_Alloc( (void **)&module_ptr, *DS_Ptr_Ptr, i, tmp_name) != DSS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !");
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
DS_DataStruct_Value_Add( *DS_Ptr_Ptr, module_ptr);
|
||||
}
|
||||
|
||||
i += inc;
|
||||
}
|
||||
@@ -1125,72 +1128,60 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
|
||||
break;
|
||||
}
|
||||
/*
|
||||
|
||||
case DS_VALUE_REMOVE:
|
||||
{
|
||||
int order;
|
||||
nb_removed = 0;
|
||||
|
||||
|
||||
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, "\nDS_Value_Remove: Remove order (croissant=0 | decroissant=1) ? ");
|
||||
fgets( buf, BUF_LEN, File_Input);
|
||||
|
||||
Arg2 = buf;
|
||||
DBD_ARG_READ( Arg3, local_arg3, "Remove ( 0:croissant | 1:decroissant): ");
|
||||
}
|
||||
|
||||
order = atoi( Arg2);
|
||||
|
||||
t_start( t_exec);
|
||||
order = atoi( Arg3);
|
||||
|
||||
if( order == 0)
|
||||
{
|
||||
i = low;
|
||||
j = high + 1;
|
||||
|
||||
while( i < j)
|
||||
{
|
||||
Ref_Module.Id = i;
|
||||
|
||||
if( ( ND_DataStruct_Value_Find( (void **)&Module_Ptr, *DS_Ptr_Ptr, &Ref_Module) == NDS_OK) && ( Module_Ptr != NULL))
|
||||
{
|
||||
if( ND_DataStruct_Value_Remove( *DS_Ptr_Ptr, (void *)Module_Ptr) == NDS_OK)
|
||||
{
|
||||
nb_removed++;
|
||||
ND_Value_Free( *DS_Ptr_Ptr, Module_Ptr);
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
i = low;
|
||||
j = high + 1;
|
||||
inc = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = high;
|
||||
j = low - 1;
|
||||
t_start( t_exec);
|
||||
i = high;
|
||||
j = low - 1;
|
||||
inc = -1;
|
||||
}
|
||||
|
||||
while( i > j)
|
||||
{
|
||||
Ref_Module.Id = i;
|
||||
t_start( t_exec);
|
||||
|
||||
if( ( ND_DataStruct_Value_Find( (void **)&Module_Ptr, *DS_Ptr_Ptr, &Ref_Module) == NDS_OK) && ( Module_Ptr != NULL))
|
||||
{
|
||||
if( ND_DataStruct_Value_Remove( *DS_Ptr_Ptr, (void *)Module_Ptr) == NDS_OK)
|
||||
{
|
||||
nb_removed++;
|
||||
ND_Value_Free( *DS_Ptr_Ptr, Module_Ptr);
|
||||
}
|
||||
}
|
||||
|
||||
i--;
|
||||
}
|
||||
}
|
||||
while( i != j)
|
||||
{
|
||||
ref_module.Id = i;
|
||||
|
||||
if( ( DS_DataStruct_Value_Find( (void **)&module_ptr, *DS_Ptr_Ptr, &ref_module) == DSS_OK) && ( module_ptr != NULL))
|
||||
{
|
||||
if( DS_DataStruct_Value_Remove( *DS_Ptr_Ptr, (void *)module_ptr) == NDS_OK)
|
||||
{
|
||||
nb_removed++;
|
||||
|
||||
if( DS_Value_Free( *DS_Ptr_Ptr, module_ptr) != DSS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_0( "DS_Value_Remove: Deallocation Failled !");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i += inc;
|
||||
}
|
||||
|
||||
t_stop( t_exec);
|
||||
|
||||
@@ -1199,7 +1190,7 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
case DS_VALUE_PRINT:
|
||||
{
|
||||
Command_Exec_Begin_Print( File_Output, Choice);
|
||||
@@ -1211,16 +1202,13 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
|
||||
break;
|
||||
}
|
||||
/*
|
||||
|
||||
case DS_VALUE_FIND:
|
||||
{
|
||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Search");
|
||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, Arg2, File_Input, Choice, "Search");
|
||||
|
||||
if( low != -1)
|
||||
{
|
||||
// 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);
|
||||
|
||||
|
||||
@@ -1231,9 +1219,18 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
|
||||
while( i < j)
|
||||
{
|
||||
Ref_Module.Id = low + (int)( (double)( high - low) * rand() / ( RAND_MAX + 1.0));
|
||||
ND_DataStruct_Value_Find( (void *)&Module_Ptr, *DS_Ptr_Ptr, &Ref_Module);
|
||||
i++;
|
||||
ref_module.Id = low + (int)( (double)( high - low) * rand() / ( RAND_MAX + 1.0));
|
||||
|
||||
if( DS_DataStruct_Value_Find( (void *)&module_ptr, *DS_Ptr_Ptr, &ref_module) != DSS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_0( "DS_Value_Find: Search Failled !");
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
t_stop (t_exec);
|
||||
@@ -1243,7 +1240,7 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
case INDEX_LIST_OPEN:
|
||||
{
|
||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, Arg2, File_Input, Choice, "Index");
|
||||
@@ -1278,16 +1275,18 @@ void Command_Exec( DST_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);
|
||||
|
||||
LG_LOG_INFO_2( "Index_Tree_Open: Opening a balanced Tree from: (%d) to: (%d)...", low, high);
|
||||
|
||||
t_start( t_exec);
|
||||
|
||||
for( i = low; i <= high; i++)
|
||||
{
|
||||
ND_Index_Open( &( ( *DS_Ptr_Ptr)->ND_Root), (NDT_Index_Id)i, DBD_IDX_TYPE_BALANCED_TREE);
|
||||
if( ( status = DS_Index_Open( *DS_Ptr_Ptr, (NDT_Index_Id)i, DBD_IDX_TYPE_BALANCED_TREE)) != DSS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_2( "Unable to open index: (%d), status: (%d)", i, status);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
t_stop( t_exec);
|
||||
@@ -1304,16 +1303,18 @@ void Command_Exec( DST_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);
|
||||
|
||||
LG_LOG_INFO_2( "Index_Close: Closing index from: (%d) to: (%d)...", low, high);
|
||||
|
||||
t_start( t_exec);
|
||||
|
||||
for( i = high; i >= low; i--)
|
||||
{
|
||||
ND_Index_Close( &( ( *DS_Ptr_Ptr)->ND_Root), (NDT_Index_Id)i);
|
||||
if( ( status = DS_Index_Close( *DS_Ptr_Ptr, (NDT_Index_Id)i)) != DSS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_2( "Unable to close index: (%d), status: (%d)", i, status);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
t_stop( t_exec);
|
||||
@@ -1465,10 +1466,10 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
*/
|
||||
case INDEX_REORG:
|
||||
{
|
||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, Arg2, File_Input, Choice, "Index");
|
||||
|
||||
if( low != -1)
|
||||
{
|
||||
@@ -1476,12 +1477,14 @@ void Command_Exec( DST_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);
|
||||
|
||||
LG_LOG_INFO_1( "Index_Reorg: Reorganizing index (%d)...", i);
|
||||
|
||||
ND_Index_Reorg( *DS_Ptr_Ptr, (NDT_Index_Id)i);
|
||||
if( ( status = DS_Index_Reorg( *DS_Ptr_Ptr, (NDT_Index_Id)i)) != DSS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_2( "Unable to reorganise index: (%d), status: (%d)", i, status);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
t_stop( t_exec);
|
||||
@@ -1492,35 +1495,9 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
break;
|
||||
}
|
||||
|
||||
case INDEX_TREE_TO_LIST:
|
||||
{
|
||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
||||
|
||||
if( low != -1)
|
||||
{
|
||||
t_start( t_exec);
|
||||
|
||||
for( i = low; i <= high; i++)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
t_stop (t_exec);
|
||||
|
||||
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case INDEX_LIST_TO_TREE:
|
||||
{
|
||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, Arg2, File_Input, Choice, "Index");
|
||||
|
||||
if( low != -1)
|
||||
{
|
||||
@@ -1528,12 +1505,14 @@ void Command_Exec( DST_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);
|
||||
|
||||
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);
|
||||
if( ( status = DS_Index_Convert( *DS_Ptr_Ptr, (NDT_Index_Id)i, DBD_IDX_TYPE_BALANCED_TREE)) != DSS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_2( "Unable to convert index: (%d), status: (%d)", i, status);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
t_stop (t_exec);
|
||||
@@ -1544,6 +1523,34 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
break;
|
||||
}
|
||||
|
||||
case INDEX_TREE_TO_LIST:
|
||||
{
|
||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, Arg2, File_Input, Choice, "Index");
|
||||
|
||||
if( low != -1)
|
||||
{
|
||||
t_start( t_exec);
|
||||
|
||||
for( i = low; i <= high; i++)
|
||||
{
|
||||
LG_LOG_INFO_1( "Index_Tree_To_List: Converting Index (%d)...", i);
|
||||
|
||||
if( ( status = DS_Index_Convert( *DS_Ptr_Ptr, (NDT_Index_Id)i, DBD_IDX_TYPE_SORTED_LIST)) != DSS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_2( "Unable to convert index: (%d), status: (%d)", i, status);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
t_stop (t_exec);
|
||||
|
||||
Command_Exec_End_Print( File_Output, Choice, t_exec, high - low);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
/*
|
||||
case INDEX_INFO_PRINT:
|
||||
{
|
||||
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");
|
||||
|
||||
Reference in New Issue
Block a user