예제 #1
0
/* -------------------------------------------------------------------- */
rc_t temp_registry_merge( temp_registry * self,
                          KDirectory * dir,
                          const char * output_filename,
                          size_t buf_size,
                          bool show_progress,
                          bool force,
                          compress_t compress )
{
    rc_t rc = 0;
    if ( self == NULL )
        rc = RC( rcVDB, rcNoTarg, rcConstructing, rcSelf, rcNull );
    else if ( output_filename == NULL )
        rc = RC( rcVDB, rcNoTarg, rcConstructing, rcParam, rcNull );
    else
    {
        struct bg_progress * progress = NULL;
        
        if ( show_progress )
        {
            rc = KOutMsg( "concat :" );
            if ( rc == 0 )
            {
                uint64_t total = total_size( dir, &self -> lists );
                rc = bg_progress_make( &progress, total, 0, 0 ); /* progress_thread.c */
            }
        }
        
        if ( rc == 0 )
        {
            uint32_t first;
            uint32_t count = count_valid_entries( &self -> lists, &first ); /* above */
            if ( count == 1 )
            {
                /* we have only ONE set of files... */
                VNamelist * l = VectorGet ( &self -> lists, first );
                VNamelistReorder ( l, false );
                rc = execute_concat( dir,
                    output_filename,
                    l,
                    buf_size,
                    progress,
                    force,
                    compress ); /* concatenator.c */
            }
            else if ( count > 1 )
            {
                /* we have MULTIPLE sets of files... */
                cmn_merge cmn = { dir, output_filename, buf_size, progress, force, compress };
                on_merge_ctx omc = { &cmn, 0 };
                VectorInit( &omc . threads, 0, count );
                VectorForEach ( &self -> lists, false, on_merge, &omc );
                join_and_release_threads( &omc . threads ); /* helper.c */
            }
            
            bg_progress_release( progress ); /* progress_thread.c ( ignores NULL )*/
        }
    }
    return rc;
}
예제 #2
0
static rc_t CC merge_thread_func( const KThread *self, void *data )
{
    merge_data * md = data;
    SBuffer s_filename;
    rc_t rc = split_filename_insert_idx( &s_filename, 4096,
                            md -> cmn -> output_filename, md -> idx ); /* helper.c */
    if ( rc == 0 )
    {
        VNamelistReorder ( md -> files, false );        
        rc = execute_concat( md -> cmn -> dir,
            s_filename . S . addr,
            md -> files,
            md -> cmn -> buf_size,
            md -> cmn -> progress,
            md -> cmn -> force,
            md -> cmn -> compress );
        release_SBuffer( &s_filename ); /* helper.c */
    }
    free( ( void * ) md );
    return rc;
}
예제 #3
0
/* ListPhysColumns
 *  avail: 2.4
 */
LIB_EXPORT rc_t CC VTableListPhysColumns ( const VTable *self, KNamelist **names )
{
    rc_t rc;

    if ( names == NULL )
        rc = RC ( rcVDB, rcTable, rcListing, rcParam, rcNull );
    else
    {
        * names = NULL;

        if ( self == NULL )
            rc = RC ( rcVDB, rcTable, rcListing, rcSelf, rcNull );
        else
        {
            KNamelist *kcol_names;
            rc = KTableListCol ( self -> ktbl, & kcol_names );
            if ( rc == 0 )
            {
                uint32_t kcol_count;
                rc = KNamelistCount ( kcol_names, & kcol_count );
                if ( rc == 0 )
                {
                    uint32_t scol_count = 0;
                    KNamelist *scol_names = NULL;
                    const KMDataNode *col_node = self -> col_node;

#if LAZY_OPEN_COL_NODE
                    if ( col_node == NULL )
                    {
                        rc = KMetadataOpenNodeRead ( self -> meta, & ( ( VTable* ) self ) -> col_node, "col" );
                        if ( rc == 0 || GetRCState ( rc ) != rcNotFound )
                            col_node = self -> col_node;
                    }
#endif
                    if ( col_node != NULL )
                    {
                        rc = KMDataNodeListChildren ( col_node, & scol_names );
                        if ( rc == 0 )
                            rc = KNamelistCount ( scol_names, & scol_count );
                    }

                    if ( rc == 0 )
                    {
                        VNamelist *vnames;
                        rc = VNamelistMake ( & vnames, kcol_count + scol_count );
                        if ( rc == 0 )
                        {
                            uint32_t i;
                            const char *name;

                            for ( i = 0; i < kcol_count && rc == 0; ++ i )
                            {
                                rc = KNamelistGet ( kcol_names, i, & name );
                                if ( rc == 0 )
                                    rc = VNamelistAppend ( vnames, name );
                            }

                            for ( i = 0; i < scol_count && rc == 0; ++ i )
                            {
                                rc = KNamelistGet ( scol_names, i, & name );
                                if ( rc == 0 )
                                    rc = VNamelistAppend ( vnames, name );
                            }

                            if ( rc == 0 )
                            {
                                rc = VNamelistToNamelist ( vnames, names );
                                if ( rc == 0 )
                                    VNamelistReorder ( vnames, false );
                            }
                        }

                        VNamelistRelease ( vnames );
                    }

                    KNamelistRelease ( scol_names );
                }

                KNamelistRelease ( kcol_names );
            }
        }
    }

    return rc;
}