- Start a new ndbench implementation, based on ndbench,

- Implement DS_Index_Open_I(), DS_Index_Close_I(), DS_Index_Convert_I(),
- Convert DST_DataStruct.Name from pointer to array.
This commit is contained in:
2024-04-30 19:03:08 +02:00
parent 813967de98
commit 42ab4c9029
4 changed files with 1481 additions and 467 deletions

View File

@@ -563,7 +563,7 @@ Strange: why end the heap here ?
/* On ajoute la data structure à la liste des structures ouvertes par le processus courant */
if( ( nd_status = ND_Value_Alloc( (void **)&opened_datastruct_ptr, OpenedDS_List, DS_Name, Root_Ptr_Ptr)) != NDS_OK)
if( ( nd_status = ND_Value_Alloc( (void **)&opened_datastruct_ptr, OpenedDS_List, DS_Name, *Root_Ptr_Ptr)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to alloc a new opened data structure element: [%s], status: (%d)", DS_Name, nd_status);
@@ -882,16 +882,16 @@ DST_Status DS_DataStruct_Close_I( NDT_Root *Root_Ptr, DST_Flags Close_Mode)
/* Suppression de la data structure de la liste des structures ouvertes */
to_remove.Name = ds_name;
strncpy( to_remove.Name, ds_name, DSD_NAME_LEN);
if( ( nd_status = ND_DataStruct_Value_Find( ( void **)&opened_datastruct_ptr, OpenedDS_List, &to_remove)) != NDS_OK)
if( ( ( nd_status = ND_DataStruct_Value_Find( ( void **)&opened_datastruct_ptr, OpenedDS_List, &to_remove)) != NDS_OK) || ( opened_datastruct_ptr == NULL))
{
LG_LOG_ERROR_2( "Unable to find data struct element: [%s] from opened structure list, status: (%d)", ds_name, nd_status);
return( DSS_KO);
}
else
{
{
if( ( nd_status = ND_DataStruct_Value_Remove( OpenedDS_List, opened_datastruct_ptr)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to remove data struct element: [%s] from opened structure list, status: (%d)", ds_name, nd_status);
@@ -919,9 +919,12 @@ DST_Status DS_DataStruct_Close_I( NDT_Root *Root_Ptr, DST_Flags Close_Mode)
/*----------------------------------------------------------------------------*/
/* (I) Stream: Output stream */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Recursive_Mode: Child or Parent */
/* (I) Recursive_Depth: Curent recursion depth */
/* (I) Recursive_Offset: Curent print out offset */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr)
DST_Status DS_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset)
{
DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
@@ -957,7 +960,7 @@ DST_Status DS_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr)
/* Affichage des informations sur la structure */
if( ( nd_status = ND_DataStruct_Info_Print( Out, Root_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0)) != NDS_OK)
if( ( nd_status = ND_DataStruct_Info_Print( Out, Root_Ptr, Recursive_Mode, Recursive_Depth, Recursive_Offset)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to print info about the data structure: (%d)", nd_status);
@@ -965,6 +968,24 @@ DST_Status DS_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr)
}
/* Opened DS Print */
if( ( nd_status = ND_DataStruct_Info_Print( Out, OpenedDS_List, Recursive_Mode, Recursive_Depth, Recursive_Offset)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to print info about the data structure: (%d)", nd_status);
return( DSS_KO);
}
if( ( nd_status = ND_DataStruct_Value_Print( Out, OpenedDS_List, Recursive_Mode, Recursive_Depth, Recursive_Offset)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to print values about the data structure: (%d)", nd_status);
return( DSS_KO);
}
/* Dump SM */
SM_Library_Dump( stderr);
@@ -1319,6 +1340,92 @@ DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, NDT_Root *Root_Ptr, ND
/*----------------------------------------------------------------------------*/
/* Create a new index */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Index_Type: Index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
NDT_Status DS_Index_Open_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type)
{
NDT_Status nd_status;
if( ( nd_status = ND_Index_Open_I( Root_Ptr, Index_Id, Index_Type)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to open index: (%d), status: (%d)", Index_Id, nd_status);
return( DSS_KO);
}
else
{
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* Remove an Index */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/
NDT_Status DS_Index_Close_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
{
NDT_Status nd_status;
if( ( nd_status = ND_Index_Close_I( Root_Ptr, Index_Id)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to close index: (%d), status: (%d)", Index_Id, nd_status);
return( DSS_KO);
}
else
{
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* Convert a data structure index to another type */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/* (I) Index_Type: Index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/
NDT_Status DS_Index_Convert_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type)
{
NDT_Status nd_status;
if( ( nd_status = ND_Index_Convert_I( Root_Ptr, Index_Id, Index_Type)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to convert index: (%d), status: (%d)", Index_Id, nd_status);
return( DSS_KO);
}
else
{
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* Récupération du premier noeud d'une structure */
/*----------------------------------------------------------------------------*/
@@ -3207,7 +3314,7 @@ DST_Status DS_DataStruct_IsOpen( NDT_Root **Root_Ptr_Ptr, char *DS_Name)
DST_DataStruct to_find, *found_ptr;
to_find.Name = DS_Name;
strncpy( to_find.Name, DS_Name, DSD_NAME_LEN);
if( ( nd_status = ND_DataStruct_Value_Find( (void **)&found_ptr, OpenedDS_List, &to_find)) != NDS_OK)
{
@@ -3629,7 +3736,7 @@ NDT_Status DS_OpenedDS_List_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
if( ( *Opened_DataStruct_Ptr_Ptr = (DST_DataStruct *)malloc( sizeof( DST_DataStruct))) == NULL)
if( ( *Opened_DataStruct_Ptr_Ptr = ( DST_DataStruct *)malloc( sizeof( DST_DataStruct))) == NULL)
{
LG_LOG_ERROR_1( "Can't allocate value zise: (%d)", sizeof( DST_DataStruct));
@@ -3637,8 +3744,10 @@ NDT_Status DS_OpenedDS_List_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id
}
else
{
( *Opened_DataStruct_Ptr_Ptr)->Name = DS_Name;
strncpy( ( *Opened_DataStruct_Ptr_Ptr)->Name, DS_Name, DSD_NAME_LEN);
( *Opened_DataStruct_Ptr_Ptr)->Root_Ptr = Root_Ptr;
LG_LOG_TRACE_2( LGD_LOG_LEVEL_DEFAULT, "Allocate new DS: Name: [%s] Root_Ptr: (%p)", DS_Name, Root_Ptr);
return( DSS_OK);
}

View File

@@ -94,7 +94,7 @@ NDT_Root *OpenedDS_List;
typedef struct DST_DataStruct
{
char *Name;
char Name[ DSD_NAME_SIZE];
NDT_Root *Root_Ptr;
} DST_DataStruct;