- 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:
Arnaud G. GIBERT 2024-05-04 18:43:08 +02:00
parent 9fc9a44356
commit 618e86de1b
4 changed files with 323 additions and 226 deletions

View File

@ -241,16 +241,18 @@ typedef struct DST_RootDescZ
# define DS_DataStruct_Reorg DS_DataStruct_Reorg_I # define DS_DataStruct_Reorg DS_DataStruct_Reorg_I
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_I # define DS_DataStruct_Traverse DS_DataStruct_Traverse_I
# define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_I # define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_I
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_I
# define DS_DataStruct_Print DS_DataStruct_Print_I # define DS_DataStruct_Print DS_DataStruct_Print_I
# define DS_DataStruct_Lock DS_DataStruct_Lock_I # define DS_DataStruct_Lock DS_DataStruct_Lock_I
# define DS_DataStruct_Unlock DS_DataStruct_Unlock_I # define DS_DataStruct_Unlock DS_DataStruct_Unlock_I
# define DS_DataStruct_Value_Add DS_DataStruct_Value_Add_I # define DS_DataStruct_Value_Add DS_DataStruct_Value_Add_I
# define DS_DataStruct_Value_Remove DS_DataStruct_Value_Remove_I # define DS_DataStruct_Value_Remove DS_DataStruct_Value_Remove_I
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_I
# define DS_DataStruct_Value_Find DS_DataStruct_Value_Find_I
# define DS_Index_Open DS_Index_Open_I # define DS_Index_Open DS_Index_Open_I
# define DS_Index_Close DS_Index_Close_I # define DS_Index_Close DS_Index_Close_I
# define DS_Index_Convert DS_Index_Convert_I # define DS_Index_Convert DS_Index_Convert_I
# define DS_Index_Reorg DS_Index_Reorg_I
# define DS_Node_Root_Get DS_Node_Root_Get_I # define DS_Node_Root_Get DS_Node_Root_Get_I
# define DS_Node_First_Get DS_Node_First_Get_I # define DS_Node_First_Get DS_Node_First_Get_I
@ -287,17 +289,19 @@ typedef struct DST_RootDescZ
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_L # define DS_DataStruct_Traverse DS_DataStruct_Traverse_L
# define DS_DataStruct_Convert DS_DataStruct_Convert_L # define DS_DataStruct_Convert DS_DataStruct_Convert_L
# define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_L # define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_L
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_L
# define DS_DataStruct_Print DS_DataStruct_Print_L # define DS_DataStruct_Print DS_DataStruct_Print_L
# define DS_DataStruct_Check DS_DataStruct_Check_L # define DS_DataStruct_Check DS_DataStruct_Check_L
# define DS_DataStruct_Lock DS_DataStruct_Lock_L # define DS_DataStruct_Lock DS_DataStruct_Lock_L
# define DS_DataStruct_Unlock DS_DataStruct_Unlock_L # define DS_DataStruct_Unlock DS_DataStruct_Unlock_L
# define DS_DataStruct_Value_Add DS_DataStruct_Value_Add_L # define DS_DataStruct_Value_Add DS_DataStruct_Value_Add_L
# define DS_DataStruct_Value_Remove DS_DataStruct_Value_Remove_L # define DS_DataStruct_Value_Remove DS_DataStruct_Value_Remove_L
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_L
# define DS_DataStruct_Value_Find DS_DataStruct_Value_Find_L
# define DS_Index_Open DS_Index_Open_L # define DS_Index_Open DS_Index_Open_L
# define DS_Index_Close DS_Index_Close_L # define DS_Index_Close DS_Index_Close_L
# define DS_Index_Convert DS_Index_Convert_L # define DS_Index_Convert DS_Index_Convert_L
# define DS_Index_Reorg DS_Index_Reorg_L
# define DS_Node_Root_Get DS_Node_Root_Get_L # define DS_Node_Root_Get DS_Node_Root_Get_L
# define DS_Node_First_Get DS_Node_First_Get_L # define DS_Node_First_Get DS_Node_First_Get_L
@ -333,16 +337,18 @@ typedef struct DST_RootDescZ
# define DS_DataStruct_Reorg DS_DataStruct_Reorg_CL # define DS_DataStruct_Reorg DS_DataStruct_Reorg_CL
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_CL # define DS_DataStruct_Traverse DS_DataStruct_Traverse_CL
# define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_CL # define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_CL
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_CL
# define DS_DataStruct_Print DS_DataStruct_Print_CL # define DS_DataStruct_Print DS_DataStruct_Print_CL
# define DS_DataStruct_Lock DS_DataStruct_Lock_CL # define DS_DataStruct_Lock DS_DataStruct_Lock_CL
# define DS_DataStruct_Unlock DS_DataStruct_Unlock_CL # define DS_DataStruct_Unlock DS_DataStruct_Unlock_CL
# define DS_DataStruct_Value_Add DS_DataStruct_Value_Add_CL # define DS_DataStruct_Value_Add DS_DataStruct_Value_Add_CL
# define DS_DataStruct_Value_Remove DS_DataStruct_Value_Remove_CL # define DS_DataStruct_Value_Remove DS_DataStruct_Value_Remove_CL
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_CL
# define DS_DataStruct_Value_Find DS_DataStruct_Value_Find_CL
# define DS_Index_Open DS_Index_Open_CL # define DS_Index_Open DS_Index_Open_CL
# define DS_Index_Close DS_Index_Close_CL # define DS_Index_Close DS_Index_Close_CL
# define DS_Index_Convert DS_Index_Convert_CL # define DS_Index_Convert DS_Index_Convert_CL
# define DS_Index_Reorg DS_Index_Reorg_CL
# define DS_Node_Root_Get DS_Node_Root_Get_CL # define DS_Node_Root_Get DS_Node_Root_Get_CL
# define DS_Node_First_Get DS_Node_First_Get_CL # define DS_Node_First_Get DS_Node_First_Get_CL
@ -560,6 +566,51 @@ DSD_API DST_Status DS_DataStruct_Value_Add_CL( DST_Root *Root_Ptr, void *Valu
/*----------------------------------------------------------------------------*/
/* Remove the first matching value from a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Ref_Value_Ptr: Reference value pointer to search */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Value_Remove_I( DST_Root *Root_Ptr, void *Ref_Value_Ptr);
DSD_API DST_Status DS_DataStruct_Value_Remove_L( DST_Root *Root_Ptr, void *Ref_Value_Ptr);
DSD_API DST_Status DS_DataStruct_Value_Remove_CL( DST_Root *Root_Ptr, void *Ref_Value_Ptr);
/*----------------------------------------------------------------------------*/
/* Print all the data structure values */
/*----------------------------------------------------------------------------*/
/* (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 */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...);
DSD_API DST_Status DS_DataStruct_Value_Print_L( FILE *Out_Ptr, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...);
DSD_API DST_Status DS_DataStruct_Value_Print_CL( FILE *Out_Ptr, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...);
/*----------------------------------------------------------------------------*/
/* Find a value in a data structure */
/*----------------------------------------------------------------------------*/
/* (O) Value_Ptr_Ptr: Value pointer address found */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Ref_Value_Ptr: Reference value pointer to search */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Value_Find_I( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, void *Ref_Value_Ptr, ...);
DSD_API DST_Status DS_DataStruct_Value_Find_C( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, void *Ref_Value_Ptr, ...);
DSD_API DST_Status SD_DataStruct_Value_Find_CL( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, void *Ref_Value_Ptr, ...);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Parcours de tous les noeuds d'une structure de données et exécution d'une */ /* Parcours de tous les noeuds d'une structure de données et exécution d'une */
/* commande sur chacun d'eux */ /* commande sur chacun d'eux */
@ -588,23 +639,6 @@ DSD_API DST_Status DS_DataStruct_Print_CL( NDT_Root * Root, FILE * Out);
/*----------------------------------------------------------------------------*/
/* Print all the data structure values */
/*----------------------------------------------------------------------------*/
/* (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 */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...);
DSD_API DST_Status DS_DataStruct_Value_Print_L( FILE *Out_Ptr, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...);
DSD_API DST_Status DS_DataStruct_Value_Print_CL( FILE *Out_Ptr, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Create a new index */ /* Create a new index */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -613,9 +647,9 @@ DSD_API DST_Status DS_DataStruct_Value_Print_CL( FILE *Out_Ptr, DST_Root *Roo
/* (I) Index_Type: Index type (List, tree, ...) */ /* (I) Index_Type: Index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
DSD_API NDT_Status DS_Index_Open_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type); DSD_API DST_Status DS_Index_Open_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type);
DSD_API NDT_Status DS_Index_Open_L( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type); DSD_API DST_Status DS_Index_Open_L( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type);
DSD_API NDT_Status DS_Index_Open_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type); DSD_API DST_Status DS_Index_Open_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type);
@ -626,9 +660,9 @@ DSD_API NDT_Status DS_Index_Open_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_I
/* (I) Index_Id: Id of the index */ /* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
DSD_API NDT_Status DS_Index_Close_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id); DSD_API DST_Status DS_Index_Close_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id);
DSD_API NDT_Status DS_Index_Close_L( DST_Root *Root_Ptr, NDT_Index_Id Index_Id); DSD_API DST_Status DS_Index_Close_L( DST_Root *Root_Ptr, NDT_Index_Id Index_Id);
DSD_API NDT_Status DS_Index_Close_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_Id); DSD_API DST_Status DS_Index_Close_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_Id);
@ -640,9 +674,24 @@ DSD_API NDT_Status DS_Index_Close_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_
/* (I) Index_Type: Index type (List, tree, ...) */ /* (I) Index_Type: Index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
DSD_API NDT_Status DS_Index_Convert_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type); DSD_API DST_Status DS_Index_Convert_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type);
DSD_API NDT_Status DS_Index_Convert_L( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type); DSD_API DST_Status DS_Index_Convert_L( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type);
DSD_API NDT_Status DS_Index_Convert_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type); DSD_API DST_Status DS_Index_Convert_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type);
/*----------------------------------------------------------------------------*/
/* Reorganise a data structure index: */
/* - Sort a non-sorted list */
/* - Rebalance a non auto-balanced tree */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Index_Reorg_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id);
DSD_API DST_Status DS_Index_Reorg_L( DST_Root *Root_Ptr, NDT_Index_Id Index_Id);
DSD_API DST_Status DS_Index_Reorg_CL( DST_Root *Root_Ptr, NDT_Index_Id Index_Id);
@ -752,30 +801,16 @@ DSD_API DST_Status DS_Value_Alloc_CL( void **Value_Ptr_Ptr, DST_Root *Root_Pt
/*----------------------------------------------------------------------------*/
/* Suppression du premier noeud correspondant à une valeur donnée */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de données */
/* (I) Reference_Value : pointeur sur la valeur de référence */
/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */
/*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_Value_Remove_I( NDT_Root * Root, void * Reference_Value, void ** Removed_Value);
DSD_API DST_Status DS_Value_Remove_L( NDT_Root * Root, void * Reference_Value, void ** Removed_Value);
DSD_API DST_Status DS_Value_Remove_CL( NDT_Root * Root, void * Reference_Value, void ** Removed_Value);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Désallocation d'une valeur d'une structure de données */ /* Désallocation d'une valeur d'une structure de données */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de données */ /* (I) Root : pointeur sur la racine de la structure de données */
/* (I) Value : pointeur sur la valeur à désallouer */ /* (I) Value : pointeur sur la valeur à désallouer */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_Value_Free_I( NDT_Root * Root, void * Value); DSD_API DST_Status DS_Value_Free_I( DST_Root *Root_Ptr, void *Value_Ptr);
DSD_API DST_Status DS_Value_Free_L( NDT_Root * Root, void * Value); DSD_API DST_Status DS_Value_Free_L( DST_Root *Root_Ptr, void *Value_Ptr);
DSD_API DST_Status DS_Value_Free_CL( NDT_Root * Root, void * Value); DSD_API DST_Status DS_Value_Free_CL( DST_Root *Root_Ptr, void *Value_Ptr);

View File

@ -197,11 +197,6 @@ DST_Status DS_Library_Stderr_Set_I( FILE *Out)
/* (I) Open_Mode : mode d'ouverture de la structure */ /* (I) Open_Mode : mode d'ouverture de la structure */
/* (I) Own_Value : indique si la structure possède ses valeurs */ /* (I) Own_Value : indique si la structure possède ses valeurs */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
//ND_DataStruct_Open( &OpenedDS_List, 1, &index_type, "DS_OpenedDS_List_Manager", NULL, NULL, NULL, NULL, NULL, TRUE, NULL)) != NDS_OK)
//DST_Status DS_DataStruct_Open_I( NDT_Root **Root, const char *DS_Name, NDT_DataStruct_Type Type, const char *Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, int Own_Values);
//DST_Status DS_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, char *DS_Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Index_Type_Tab, char *Manager_Name, size_t Segment_Size, DST_Flags Open_Mode, short Own_Value)
DST_Status DS_DataStruct_Open_I( DST_Root **Root_Ptr_Ptr, char *DS_Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Index_Type_Tab, char *Manager_Name, size_t Segment_Size, DST_Flags Open_Mode, short Own_Value) DST_Status DS_DataStruct_Open_I( DST_Root **Root_Ptr_Ptr, char *DS_Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Index_Type_Tab, char *Manager_Name, size_t Segment_Size, DST_Flags Open_Mode, short Own_Value)
{ {
@ -282,7 +277,7 @@ DST_Status DS_DataStruct_Open_I( DST_Root **Root_Ptr_Ptr, char *DS_Name, NDT
rootdesc_tmp.Heap_Name[ DSD_NAME_LEN] = '\0'; rootdesc_tmp.Heap_Name[ DSD_NAME_LEN] = '\0';
*/ */
// if( ( nd_status = ND_DataStruct_Open( Root_Ptr_Ptr, Index_Nb, Index_Type_Tab, Manager_Name, NULL, "DS_DataStruct_Alloc", NULL, "DS_DataStruct_Free", NULL, Own_Value, &rootdesc_tmp)) != NDS_OK) // if( ( nd_status = ND_DataStruct_Open( Root_Ptr_Ptr, Index_Nb, Index_Type_Tab, Manager_Name, NULL, "DS_DataStruct_Alloc", NULL, "DS_DataStruct_Free", NULL, Own_Value, &rootdesc_tmp)) != NDS_OK)
if( ( nd_status = ND_DataStruct_Open( &nd_root_ptr, Index_Nb, Index_Type_Tab, Manager_Name, NULL, "DS_DataStruct_Alloc", NULL, "DS_DataStruct_Free", NULL, Own_Value, &root_tmp)) != NDS_OK) if( ( nd_status = ND_DataStruct_Open( &nd_root_ptr, Index_Nb, Index_Type_Tab, Manager_Name, NULL, "DS_Allocator", NULL, "DS_Deallocator", NULL, Own_Value, &root_tmp)) != NDS_OK)
{ {
LG_LOG_ERROR_2( "Unable to create a new node structure in the existing heap: [%s], status: (%d)", heap_ptr->Name, nd_status); LG_LOG_ERROR_2( "Unable to create a new node structure in the existing heap: [%s], status: (%d)", heap_ptr->Name, nd_status);
@ -500,7 +495,7 @@ Strange: why end the heap here ?
rootdesc_tmp.Heap_Name[ DSD_NAME_LEN] = '\0'; rootdesc_tmp.Heap_Name[ DSD_NAME_LEN] = '\0';
*/ */
// if( ( nd_status = ND_DataStruct_Open( Root_Ptr_Ptr, Index_Nb, Index_Type_Tab, Manager_Name, NULL, "DS_DataStruct_Alloc", NULL, "DS_DataStruct_Free", NULL, Own_Value, &rootdesc_tmp)) != NDS_OK) // if( ( nd_status = ND_DataStruct_Open( Root_Ptr_Ptr, Index_Nb, Index_Type_Tab, Manager_Name, NULL, "DS_DataStruct_Alloc", NULL, "DS_DataStruct_Free", NULL, Own_Value, &rootdesc_tmp)) != NDS_OK)
if( ( nd_status = ND_DataStruct_Open( &nd_root_ptr, Index_Nb, Index_Type_Tab, Manager_Name, NULL, "DS_DataStruct_Alloc", NULL, "DS_DataStruct_Free", NULL, Own_Value, &root_tmp)) != NDS_OK) if( ( nd_status = ND_DataStruct_Open( &nd_root_ptr, Index_Nb, Index_Type_Tab, Manager_Name, NULL, "DS_Allocator", NULL, "DS_Deallocator", NULL, Own_Value, &root_tmp)) != NDS_OK)
{ {
LG_LOG_ERROR_2( "Unable to create a new node structure in new heap: [%s], status: (%d)", heap_ptr->Name, nd_status); LG_LOG_ERROR_2( "Unable to create a new node structure in new heap: [%s], status: (%d)", heap_ptr->Name, nd_status);
@ -913,7 +908,7 @@ DST_Status DS_DataStruct_Close_I( DST_Root *Root_Ptr, DST_Flags Close_Mode)
return( DSS_KO); return( DSS_KO);
} }
if( ( status = DS_DataStruct_Free( Root_Ptr, &( Root_Ptr->ND_Root), NULL)) != DSS_OK) if( ( status = DS_Deallocator( Root_Ptr, &( Root_Ptr->ND_Root), NULL)) != DSS_OK)
{ {
LG_LOG_ERROR_2( "Unable to free data structure: [%s], status: (%d)", ds_name, status); LG_LOG_ERROR_2( "Unable to free data structure: [%s], status: (%d)", ds_name, status);
} }
@ -1396,6 +1391,10 @@ DST_Status DS_DataStruct_Print_I ( NDT_Root * Root, FILE * Out )
return DS_DataStruct_Traverse_I (Root, NDD_CMD_PRINT_VALUE, Out); return DS_DataStruct_Traverse_I (Root, NDD_CMD_PRINT_VALUE, Out);
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Add a new value to a data structure */ /* Add a new value to a data structure */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -1407,7 +1406,6 @@ DST_Status DS_DataStruct_Value_Add_I( DST_Root *Root_Ptr, void *Value_Ptr)
{ {
// DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr); // DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
DST_Status status;
NDT_Status nd_status; NDT_Status nd_status;
@ -1425,9 +1423,7 @@ DST_Status DS_DataStruct_Value_Add_I( DST_Root *Root_Ptr, void *Value_Ptr)
if( ( nd_status = ND_DataStruct_Value_Add( &( Root_Ptr->ND_Root), Value_Ptr)) != NDS_OK) if( ( nd_status = ND_DataStruct_Value_Add( &( Root_Ptr->ND_Root), Value_Ptr)) != NDS_OK)
{ {
LG_LOG_ERROR_1( "Unable to add a value to the data structure: (%d)", nd_status); LG_LOG_ERROR_1( "Unable to add a value to the data structure, status: (%d)", nd_status);
// if (!DS_ERROR(rc)) RootDesc->Valid = TRUE;
return( DSS_KO); return( DSS_KO);
} }
@ -1445,59 +1441,42 @@ DST_Status DS_DataStruct_Value_Add_I( DST_Root *Root_Ptr, void *Value_Ptr)
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Suppression du premier noeud correspondant à une valeur donnée */ /* Remove the first matching value from a data structure */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de données */ /* (I) Root_Ptr: Data structure pointer */
/* (I) Reference_Value : pointeur sur la valeur de référence */ /* (I) Ref_Value_Ptr: Reference value pointer to search */
/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*
DST_Status DS_Value_Remove_I ( NDT_Root * Root, void * Reference_Value, void ** Removed_Value ) DST_Status DS_DataStruct_Value_Remove_I( DST_Root *Root_Ptr, void *Ref_Value_Ptr)
{ {
DST_Status rc; NDT_Status nd_status;
DST_RootDesc * RootDesc = (DST_RootDesc *)(Root->User);
/* On vérifie que la data structure est valide */ /* On vérifie que la data structure est valide */
/*
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On vérifie la structure */ DS_STRUCT_VALID_CHECK( Root_Ptr);
/*
Nb_Detected = Nb_Corrected = 0;
rc = DS_DataStruct_Check_L (Root, &Nb_Detected, &Nb_Corrected, DS_stderr);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_Value_Remove : unable to check the data structure");
DS_Error_Print ();
return rc;
}
}
/* On rend la structure invalide le temps de la suppression de valeur */ /* On rend la structure invalide le temps de l'ajout */
/*
RootDesc->Valid = FALSE;
Root_Ptr->Status = DSD_DATASTRUCT_STATUS_INVALID;
/* Suppression du noeud correspondant à la valeur de référence */ /* Suppression du noeud correspondant à la valeur de référence */
/*
rc = ND_Value_Remove (Root, Reference_Value, Removed_Value); if( ( nd_status = ND_DataStruct_Value_Remove( &( Root_Ptr->ND_Root), Ref_Value_Ptr)) != NDS_OK)
if (rc != NDS_OK)
{ {
sprintf (DS_Error_Msg, "Error DS_Value_Remove : unable to remove a value from the data structure"); LG_LOG_ERROR_1( "Unable to remove a value to the data structure, status: (%d)", nd_status);
DS_Error_Print ();
if (!DS_ERROR(rc)) RootDesc->Valid = TRUE; return( DSS_KO);
return rc;
} }
/* On rend la structure à nouveau valide */ /* On rend la structure à nouveau valide */
/*
RootDesc->Valid = TRUE;
return DSS_OK; Root_Ptr->Status = DSD_DATASTRUCT_STATUS_VALID;
return( DSS_OK);
} }
@ -1517,11 +1496,9 @@ DST_Status DS_Value_Remove_I ( NDT_Root * Root, void * Reference_Value, void **
DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, DST_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...) DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, DST_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); DST_Status status;
NDT_Status nd_status;
DST_Status status; va_list user_args;
NDT_Status nd_status;
va_list user_args;
va_start( user_args, Recursive_Offset); va_start( user_args, Recursive_Offset);
@ -1535,7 +1512,7 @@ DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, DST_Root *Root_Ptr, ND
if( ( nd_status = ND_DataStruct_Value_Print_VI( Out_Ptr, &( Root_Ptr->ND_Root), Recursive_Mode, Recursive_Depth, Recursive_Offset, &user_args)) != NDS_OK) if( ( nd_status = ND_DataStruct_Value_Print_VI( Out_Ptr, &( Root_Ptr->ND_Root), Recursive_Mode, Recursive_Depth, Recursive_Offset, &user_args)) != NDS_OK)
{ {
LG_LOG_ERROR_1( "Unable to dump the node structure: (%d)", nd_status); LG_LOG_ERROR_1( "Unable to print the data structure values, status: (%d)", nd_status);
status = DSS_KO; status = DSS_KO;
} }
@ -1553,6 +1530,54 @@ DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, DST_Root *Root_Ptr, ND
/*----------------------------------------------------------------------------*/
/* Find a value in a data structure */
/*----------------------------------------------------------------------------*/
/* (O) Value_Ptr_Ptr: Value pointer address found */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Ref_Value_Ptr: Reference value pointer to search */
/* (I) ...: User args */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Value_Find_I( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, void *Ref_Value_Ptr, ...)
{
DST_Status status;
NDT_Status nd_status;
va_list user_args;
va_start( user_args, Ref_Value_Ptr);
*Value_Ptr_Ptr = NULL;
/* On vérifie que la data structure est valide */
DS_STRUCT_VALID_CHECK( Root_Ptr);
/* Recherche dans la node structure */
if( ( nd_status = ND_DataStruct_Value_Find_VI( Value_Ptr_Ptr, &( Root_Ptr->ND_Root), Ref_Value_Ptr, &user_args)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to search a value in the data structure, status: (%d)", nd_status);
status = DSS_KO;
}
else
{
status = DSS_OK;
}
va_end( user_args);
return( status);
}
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Create a new index */ /* Create a new index */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -1561,7 +1586,7 @@ DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, DST_Root *Root_Ptr, ND
/* (I) Index_Type: Index type (List, tree, ...) */ /* (I) Index_Type: Index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
NDT_Status DS_Index_Open_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type) DST_Status DS_Index_Open_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type)
{ {
NDT_Status nd_status; NDT_Status nd_status;
@ -1589,7 +1614,7 @@ NDT_Status DS_Index_Open_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_In
/* (I) Index_Id: Id of the index */ /* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
NDT_Status DS_Index_Close_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id) DST_Status DS_Index_Close_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id)
{ {
NDT_Status nd_status; NDT_Status nd_status;
@ -1618,7 +1643,7 @@ NDT_Status DS_Index_Close_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id)
/* (I) Index_Type: Index type (List, tree, ...) */ /* (I) Index_Type: Index type (List, tree, ...) */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
NDT_Status DS_Index_Convert_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type) DST_Status DS_Index_Convert_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Index_Type Index_Type)
{ {
NDT_Status nd_status; NDT_Status nd_status;
@ -1639,6 +1664,36 @@ NDT_Status DS_Index_Convert_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT
/*----------------------------------------------------------------------------*/
/* Reorganise a data structure index: */
/* - Sort a non-sorted list */
/* - Rebalance a non auto-balanced tree */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Index_Id: Id of the index */
/*----------------------------------------------------------------------------*/
DST_Status DS_Index_Reorg_I( DST_Root *Root_Ptr, NDT_Index_Id Index_Id)
{
NDT_Status nd_status;
if( ( nd_status = ND_Index_Reorg_I( &( Root_Ptr->ND_Root), Index_Id)) != NDS_OK)
{
LG_LOG_ERROR_2( "Unable to reorg index: (%d), status: (%d)", Index_Id, nd_status);
return( DSS_KO);
}
else
{
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Récupération du premier noeud d'une structure */ /* Récupération du premier noeud d'une structure */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -1996,10 +2051,10 @@ DST_Status DS_Value_Alloc_I( void **Value_Ptr_Ptr, DST_Root *Root_Ptr, ... )
/* (I) Root : pointeur sur la racine de la structure de données */ /* (I) Root : pointeur sur la racine de la structure de données */
/* (I) Value : pointeur sur la valeur à désallouer */ /* (I) Value : pointeur sur la valeur à désallouer */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*
DST_Status DS_Value_Free_I ( NDT_Root * Root, void * Value ) DST_Status DS_Value_Free_I( DST_Root *Root_Ptr, void *Value_Ptr)
{ {
return ND_Value_Free (Root, Value); return ND_Value_Free( &( Root_Ptr->ND_Root), Value_Ptr);
} }
@ -2016,7 +2071,7 @@ DST_Status DS_Value_Free_I ( NDT_Root * Root, void * Value )
DST_Status DS_Alloc_I( void **Ptr_Ptr, NDT_Root *ND_Root_Ptr, size_t Size) DST_Status DS_Alloc_I( void **Ptr_Ptr, NDT_Root *ND_Root_Ptr, size_t Size)
{ {
return( DS_DataStruct_Alloc( Ptr_Ptr, ND_Root_Ptr, Size, NULL)); return( DS_Allocator( Ptr_Ptr, ND_Root_Ptr, Size, NULL)); // TBC: Use defined allocator!
} }
@ -2032,7 +2087,7 @@ DST_Status DS_Alloc_I( void **Ptr_Ptr, NDT_Root *ND_Root_Ptr, size_t Size)
DST_Status DS_Free_I( NDT_Root *ND_Root_Ptr, void *Ptr) DST_Status DS_Free_I( NDT_Root *ND_Root_Ptr, void *Ptr)
{ {
return( DS_DataStruct_Free( Ptr, ND_Root_Ptr, NULL)); return( DS_Deallocator( Ptr, ND_Root_Ptr, NULL)); // TBC: Use defined allocator!
} }
@ -2722,7 +2777,7 @@ DST_Status DS_Value_Free_L ( NDT_Root * Root, void * Value )
/* /*
DST_Status DS_Alloc_L ( NDT_Root * Root, size_t Size, void ** Ptr ) DST_Status DS_Alloc_L ( NDT_Root * Root, size_t Size, void ** Ptr )
{ {
return DS_DataStruct_Alloc (Size, Ptr, Root->User); return DS_Allocator (Size, Ptr, Root->User);
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -2734,7 +2789,7 @@ DST_Status DS_Alloc_L ( NDT_Root * Root, size_t Size, void ** Ptr )
/* /*
DST_Status DS_Free_L ( NDT_Root * Root, void * Ptr ) DST_Status DS_Free_L ( NDT_Root * Root, void * Ptr )
{ {
return DS_DataStruct_Free (Ptr, Root->User); return DS_Deallocator (Ptr, Root->User);
} }
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -3508,7 +3563,7 @@ DST_Status DS_DataStruct_IsOpen( DST_Root **Root_Ptr_Ptr, char *DS_Name)
/* Fonction d'allocation attachée à une structure de données : */ /* Fonction d'allocation attachée à une structure de données : */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Alloc( void **Ptr_Ptr, NDT_Root *ND_Root_Ptr, size_t Size, void *User_Ptr) DST_Status DS_Allocator( void **Ptr_Ptr, NDT_Root *ND_Root_Ptr, size_t Size, void *User_Ptr)
{ {
// DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)Data_Ptr; // DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)Data_Ptr;
// char *Heap_Name = RootDesc_Ptr->Heap_Name; // char *Heap_Name = RootDesc_Ptr->Heap_Name;
@ -3665,7 +3720,7 @@ DST_Status DS_DataStruct_Alloc( void **Ptr_Ptr, size_t Size, void *Data_Ptr)
/* Fonction de désallocation attachée à une structure de données : */ /* Fonction de désallocation attachée à une structure de données : */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Free( void *Ptr, NDT_Root *ND_Root_Ptr, void *User_Ptr) DST_Status DS_Deallocator( void *Ptr, NDT_Root *ND_Root_Ptr, void *User_Ptr)
{ {
// DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)Data_Ptr; // DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)Data_Ptr;
// char *Heap_Name = RootDesc_Ptr->Heap_Name; // char *Heap_Name = RootDesc_Ptr->Heap_Name;

View File

@ -126,7 +126,7 @@ DST_Status DS_Semaphore_Operate (int, struct sembuf *, unsigned int);
/* Fonction d'allocation attachée à une structure de données : */ /* Fonction d'allocation attachée à une structure de données : */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Alloc ( void **Ptr_Ptr, NDT_Root *ND_Root_Ptr, size_t Size, void *User_Ptr); DST_Status DS_Allocator( void **Ptr_Ptr, NDT_Root *ND_Root_Ptr, size_t Size, void *User_Ptr);
@ -134,7 +134,7 @@ DST_Status DS_DataStruct_Alloc ( void **Ptr_Ptr, NDT_Root *ND_Root_Ptr, size_
/* Fonction de désallocation attachée à une structure de données : */ /* Fonction de désallocation attachée à une structure de données : */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Free ( void *Ptr, NDT_Root *ND_Root_Ptr, void *User_Ptr ); DST_Status DS_Deallocator( void *Ptr, NDT_Root *ND_Root_Ptr, void *User_Ptr );

View File

@ -1081,8 +1081,6 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
order = atoi( Arg3); 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); 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) while( i != j)
{ {
if( DS_Value_Alloc( (void **)&module_ptr, *DS_Ptr_Ptr, i, "x") == NDS_OK) char tmp_name[ DSD_NAME_SIZE];
{
DS_DataStruct_Value_Add( *DS_Ptr_Ptr, module_ptr); snprintf( tmp_name, DSD_NAME_LEN, "Element #: (%ld)", i);
} tmp_name[ DSD_NAME_LEN] = '\0';
else
if( DS_Value_Alloc( (void **)&module_ptr, *DS_Ptr_Ptr, i, tmp_name) != DSS_OK)
{ {
LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !"); LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !");
break; break;
} }
else
{
DS_DataStruct_Value_Add( *DS_Ptr_Ptr, module_ptr);
}
i += inc; i += inc;
} }
@ -1125,72 +1128,60 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
break; break;
} }
/*
case DS_VALUE_REMOVE: case DS_VALUE_REMOVE:
{ {
int order; int order;
nb_removed = 0; 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( low != -1)
{ {
if( Arg2 == NULL) if( Arg3 == NULL)
{ {
fprintf( File_Output, "\nDS_Value_Remove: Remove order (croissant=0 | decroissant=1) ? "); DBD_ARG_READ( Arg3, local_arg3, "Remove ( 0:croissant | 1:decroissant): ");
fgets( buf, BUF_LEN, File_Input);
Arg2 = buf;
} }
order = atoi( Arg2); order = atoi( Arg3);
t_start( t_exec);
if( order == 0) if( order == 0)
{ {
i = low; i = low;
j = high + 1; j = high + 1;
inc = 1;
while( i < j) }
{ else
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 = high; i = high;
j = low - 1; j = low - 1;
t_start( t_exec); inc = -1;
}
while( i > j) t_start( t_exec);
{
Ref_Module.Id = i;
if( ( ND_DataStruct_Value_Find( (void **)&Module_Ptr, *DS_Ptr_Ptr, &Ref_Module) == NDS_OK) && ( Module_Ptr != NULL)) while( i != j)
{ {
if( ND_DataStruct_Value_Remove( *DS_Ptr_Ptr, (void *)Module_Ptr) == NDS_OK) ref_module.Id = i;
{
nb_removed++; if( ( DS_DataStruct_Value_Find( (void **)&module_ptr, *DS_Ptr_Ptr, &ref_module) == DSS_OK) && ( module_ptr != NULL))
ND_Value_Free( *DS_Ptr_Ptr, Module_Ptr); {
} if( DS_DataStruct_Value_Remove( *DS_Ptr_Ptr, (void *)module_ptr) == NDS_OK)
} {
nb_removed++;
i--;
} 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); t_stop( t_exec);
@ -1199,7 +1190,7 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
break; break;
} }
*/
case DS_VALUE_PRINT: case DS_VALUE_PRINT:
{ {
Command_Exec_Begin_Print( File_Output, Choice); 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; break;
} }
/*
case DS_VALUE_FIND: 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) 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); 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) while( i < j)
{ {
Ref_Module.Id = low + (int)( (double)( high - low) * rand() / ( RAND_MAX + 1.0)); 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++; 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); t_stop (t_exec);
@ -1243,7 +1240,7 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
break; break;
} }
*/
case INDEX_LIST_OPEN: case INDEX_LIST_OPEN:
{ {
Command_Index_Range_Get( File_Output, &low, &high, Arg1, Arg2, File_Input, Choice, "Index"); 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) 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); LG_LOG_INFO_2( "Index_Tree_Open: Opening a balanced Tree from: (%d) to: (%d)...", low, high);
t_start( t_exec); t_start( t_exec);
for( i = low; i <= high; i++) 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); 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) 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); LG_LOG_INFO_2( "Index_Close: Closing index from: (%d) to: (%d)...", low, high);
t_start( t_exec); t_start( t_exec);
for( i = high; i >= low; i--) 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); t_stop( t_exec);
@ -1465,10 +1466,10 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
break; break;
} }
*/
case INDEX_REORG: 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) 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++) 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); 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); t_stop( t_exec);
@ -1492,35 +1495,9 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
break; 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: 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) 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++) 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); 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); t_stop (t_exec);
@ -1544,6 +1523,34 @@ void Command_Exec( DST_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
break; 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: case INDEX_INFO_PRINT:
{ {
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index"); Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Index");