示例#1
0
void ensGvsynonymDel(EnsPGvsynonym *Pgvs)
{
    EnsPGvsynonym pthis = NULL;

    if (!Pgvs)
        return;

#if defined(AJ_DEBUG) && AJ_DEBUG >= 1
    if (ajDebugTest("ensGvsynonymDel"))
    {
        ajDebug("ensGvsynonymDel\n"
                "  *Pgvs %p\n",
                *Pgvs);

        ensGvsynonymTrace(*Pgvs, 1);
    }
#endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */

    if (!(pthis = *Pgvs) || --pthis->Use)
    {
        *Pgvs = NULL;

        return;
    }

    ensGvsourceDel(&pthis->Gvsource);

    ajStrDel(&pthis->Name);
    ajStrDel(&pthis->Moleculetype);

    ajMemFree((void **) Pgvs);

    return;
}
示例#2
0
void ensStorableDel(EnsPStorable *Pstorable)
{
    EnsPStorable pthis = NULL;

    if (!Pstorable)
        return;

#if defined(AJ_DEBUG) && AJ_DEBUG >= 1
    if (ajDebugTest("ensStorableDel"))
        ajDebug("ensStorableDel\n"
                "  *Pstorable %p\n",
                *Pstorable);
#endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */

    if (!(pthis = *Pstorable) || --pthis->Use)
    {
        *Pstorable = NULL;

        return;
    }

    ajMemFree((void **) Pstorable);

    return;
}
示例#3
0
void ensGvdatabaseadaptorDel(EnsPGvdatabaseadaptor *Pgvdba)
{
    EnsPGvdatabaseadaptor pthis = NULL;

    if (!Pgvdba)
        return;

#if defined(AJ_DEBUG) && AJ_DEBUG >= 1
    if (ajDebugTest("ensGvdatabaseadaptorDel"))
    {
        ajDebug("ensGvdatabaseadaptorDel\n"
                "  *Pgvdba %p\n",
                *Pgvdba);

        ensGvdatabaseadaptorTrace(*Pgvdba, 1);
    }
#endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 1 */

    if (!(pthis = *Pgvdba))
        return;

    ajMemFree((void **) Pgvdba);

    return;
}
static int cacheensembl_stringcompare(const void* P1, const void* P2)
{
    const AjPStr string1 = NULL;
    const AjPStr string2 = NULL;

    string1 = *(AjPStr const*) P1;
    string2 = *(AjPStr const*) P2;

#if AJFALSE
    if(ajDebugTest("cacheensembl_stringcompare"))
        ajDebug("cacheensembl_stringcompare\n"
                "  string1 %u\n"
                "  string2 %u\n",
                string1,
                string2);
#endif

    return ajStrCmpCaseS(string1, string2);
}
示例#5
0
AjBool ensAssemblyexceptionadaptorFetchAllBySeqregionIdentifier(
    const EnsPAssemblyexceptionadaptor aea,
    ajuint srid,
    AjPList aes)
{
    AjIList iter = NULL;
    AjPList list = NULL;

    EnsPAssemblyexception ae = NULL;

    if(ajDebugTest("ensAssemblyexceptionadaptorFetchAllBySeqregionIdentifier"))
        ajDebug("ensAssemblyexceptionadaptorFetchAllBySeqregionIdentifier\n"
                "  aea %p\n"
                "  srid %u\n"
                "  aes %p\n",
                aea,
                srid,
                aes);

    if(!aea)
        return ajFalse;

    if(!aes)
        return ajFalse;

    list = (AjPList) ajTableFetch(aea->CacheBySeqregionIdentifier,
                                  (const void *) &srid);

    iter = ajListIterNew(list);

    while(!ajListIterDone(iter))
    {
        ae = (EnsPAssemblyexception) ajListIterGet(iter);

        ajListPushAppend(aes, (void *) ensAssemblyexceptionNewRef(ae));
    }

    ajListIterDel(&iter);

    return ajTrue;
}
示例#6
0
static int listUintCompareDescending(
    const void *item1,
    const void *item2)
{
    int result = 0;

    ajuint *Pidentifier1 = *(ajuint *const *) item1;
    ajuint *Pidentifier2 = *(ajuint *const *) item2;

#if defined(AJ_DEBUG) && AJ_DEBUG >= 2
    if (ajDebugTest("listUintCompareDescending"))
        ajDebug("listUintCompareDescending\n"
                "  identifier1 %u\n"
                "  identifier2 %u\n",
                *Pidentifier1,
                *Pidentifier2);
#endif /* defined(AJ_DEBUG) && AJ_DEBUG >= 2 */

    /* Sort empty values towards the end of the AJAX List. */

    if (Pidentifier1 && (!Pidentifier2))
        return -1;

    if ((!Pidentifier1) && (!Pidentifier2))
        return 0;

    if ((!Pidentifier1) && Pidentifier2)
        return +1;

    /* Evaluate identifier objects */

    if (*Pidentifier1 > *Pidentifier2)
        result = -1;

    if (*Pidentifier1 < *Pidentifier2)
        result = +1;

    return result;
}
示例#7
0
void ensCacheDel(EnsPCache* Pcache)
{
    AjBool debug = AJFALSE;

    EnsPCache pthis = NULL;

    CachePNode node = NULL;

    if(!Pcache)
        return;

    if(!*Pcache)
        return;

    debug = ajDebugTest("ensCacheDel");

    if(debug)
        ajDebug("ensCacheDel\n"
                "  *Pcache %p\n",
                *Pcache);

    pthis = *Pcache;

    /* Remove nodes from the AJAX List. */

    while(ajListPop(pthis->List, (void **) &node))
    {
        /* Remove the node from the AJAX Table. */

        ajTableRemove(pthis->Table, node->Key);

        /* Update the cache statistics. */

        pthis->Count--;

        pthis->Bytes -= node->Bytes;

        /* Write changes of value data to disk if any. */

        if(pthis->Write && node->Value && node->Dirty)
            (*pthis->Write)(node->Value);

        /* Both, key and value data are deleted via cacheNodeDel. */

        cacheNodeDel(pthis, &node);
    }

    if(debug)
        ensCacheTrace(pthis, 1);

    ajStrDel(&pthis->Label);

    ajListFree(&pthis->List);

    ajTableFree(&pthis->Table);

    AJFREE(pthis);

    *Pcache = NULL;

    return;
}
示例#8
0
EnsPCache ensCacheNew(AjEnum type,
                      ajuint maxbytes,
                      ajuint maxcount,
                      ajuint maxsize,
                      void* Freference(void* value),
                      void Fdelete(void** value),
                      ajuint Fsize(const void* value),
                      void* Fread(const void* key),
                      AjBool Fwrite(const void* value),
                      AjBool synchron,
                      const char *label)
{
    AjBool debug = AJFALSE;

    EnsPCache cache = NULL;

    debug = ajDebugTest("ensCacheNew");

    if(debug)
        ajDebug("ensCacheNew\n"
                "  type %d\n"
                "  maxbytes %u\n"
                "  maxcount %u\n"
                "  maxsize %u\n"
                "  Freference %p\n"
                "  Fdelete %p\n"
                "  Fsize %p\n"
                "  Fread %p\n"
                "  Fwrite %p\n"
                "  synchron '%B'\n"
                "  label '%s'\n",
                type,
                maxbytes,
                maxcount,
                maxsize,
                Freference,
                Fdelete,
                Fsize,
                Fread,
                Fwrite,
                synchron,
                label);

    if((type < ensECacheTypeNumeric) || (type > ensECacheTypeAlphaNumeric))
        ajFatal("ensCacheNew requires a valid type.\n");

    if((!maxbytes) && (!maxcount))
        ajFatal("ensCacheNew requires either a "
                "maximum bytes or maximum count limit.\n");

    if(!maxsize)
        maxsize = maxbytes ? maxbytes / 10 + 1 : 0;

    if(maxbytes && (!maxsize))
        ajFatal("ensCacheNew requires a maximum size limit, "
                "when a maximum bytes limit is set.");

    /* TODO: Find and set a sensible value here! */

    if(debug)
        ajDebug("ensCacheNew maxbytes %u, maxcount %u, maxsize %u.\n",
                maxbytes, maxcount, maxsize);

    if(maxbytes && (maxbytes < 1000))
        ajFatal("ensCacheNew cannot set a maximum bytes limit (%u) under "
                "1000, as each Cache Node requires %u bytes alone.",
                maxbytes, sizeof(CachePNode));

    /* TODO: Find and set a sensible value here! */

    if(maxsize && (maxsize < 3))
        ajFatal("ensCacheNew cannot set a maximum size limit (%u) under "
                "3 bytes. maximum bytes %u maximum count %u.",
                maxsize, maxbytes, maxcount);

    /*
    ** Pointers to functions for automatic reading of data not yet in the
    ** cache and writing of data modified in cache are not mandatory.
    ** If not specified the cache will simply lack this functionality.
    ** However, the specification of a function deleting stale cache entries
    ** and a function calculating the size of value data are required.
    */

    if(!(void*)Freference)
        ajFatal("ensCacheNew requires a referencing function.");

    if(!(void*)Fdelete)
        ajFatal("ensCacheNew requires a deletion function.");

    if(maxsize && (!(void*)Fsize))
        ajFatal("ensCacheNew requires a memory sizing function "
                "when a maximum size limit has been defined.");

    if(!label)
        ajFatal("ensCacheNew requires a label.");

    AJNEW0(cache);

    cache->Label = ajStrNewC(label);
    cache->List  = ajListNew();

    switch(type)
    {
        case ensECacheTypeNumeric:

            cache->Table = ajTableNewFunctionLen(0,
                                                 ensTableCmpUint,
                                                 ensTableHashUint);

            break;

        case ensECacheTypeAlphaNumeric:

            cache->Table = ajTablestrNewLen(0);

            break;

        default:
            ajWarn("ensCacheNew got unexpected Cache type %d.\n",
                   cache->Type);
    }

    cache->Reference = Freference;
    cache->Delete    = Fdelete;
    cache->Size      = Fsize;
    cache->Read      = Fread;
    cache->Write     = Fwrite;
    cache->Type      = type;
    cache->Synchron  = synchron;
    cache->MaxBytes  = maxbytes;
    cache->MaxCount  = maxcount;
    cache->MaxSize   = maxsize;
    cache->Bytes     = 0;
    cache->Count     = 0;
    cache->Dropped   = 0;
    cache->Removed   = 0;
    cache->Stored    = 0;
    cache->Hit       = 0;
    cache->Miss      = 0;

    return cache;
}