source/adios2/engine/julea-kv-old/JuleaInteractionWriter.cpp
/**
 *  Writes name of variable/attribute to Julea KV. Also checks if name is
 * already in kv. paramName = name of variable/attribute nameSpace = file kvName
 * = variable_names/ attribute_names
 */
Writes name of variable/attribute to Julea KV. Also checks if name is
already in kv. paramName = name of variable/attribute nameSpace = file kvName
= variable_names/ attribute_names
Writes name of variable / attribute to Julea KV . Also checks if name is already in kv . paramName = name of variable / attribute nameSpace = file kvName = variable_names / attribute_names
void PutNameToJulea(std::string paramName, std::string nameSpace,
                    std::string kvName)
{
    bool err = false;
    guint32 valueLen = 0;
    bson_t *bsonNames;
    bson_iter_t bIter;
    void *namesBuf = NULL;
    auto semantics = j_semantics_new(J_SEMANTICS_TEMPLATE_DEFAULT);
    auto batch = j_batch_new(semantics);
    auto batch2 = j_batch_new(semantics);
    auto name = strdup(paramName.c_str());
    auto kvObjectNames = j_kv_new(kvName.c_str(), nameSpace.c_str());
    j_kv_get(kvObjectNames, &namesBuf, &valueLen, batch);
    err = j_batch_execute(batch);
    if (valueLen == 0)
    {
        bsonNames = bson_new();
    }
    else
    {
        bsonNames = bson_new_from_data((const uint8_t *)namesBuf, valueLen);
    }
    free(namesBuf);
    if (!bson_iter_init_find(&bIter, bsonNames, name))
    {
        bson_append_int32(bsonNames, name, -1, 42);
    }
    else
    {
    }
    namesBuf = g_memdup2(bson_get_data(bsonNames), bsonNames->len);
    j_kv_put(kvObjectNames, namesBuf, bsonNames->len, g_free, batch2);
    g_assert_true(j_batch_execute(batch2) == true);
    free(name);
    bson_destroy(bsonNames);
    j_kv_unref(kvObjectNames);
    j_batch_unref(batch);
    j_batch_unref(batch2);
    j_semantics_unref(semantics);
}
void PutNameToJulea ( std :: string paramName , std :: string nameSpace , std :: string kvName ) { bool err = false ; guint32 valueLen = 0 ; bson_t * bsonNames ; bson_iter_t bIter ; void * namesBuf = NULL ; auto semantics = j_semantics_new ( J_SEMANTICS_TEMPLATE_DEFAULT ) ; auto batch = j_batch_new ( semantics ) ; auto batch2 = j_batch_new ( semantics ) ; auto name = strdup ( paramName . c_str ( ) ) ; auto kvObjectNames = j_kv_new ( kvName . c_str ( ) , nameSpace . c_str ( ) ) ; j_kv_get ( kvObjectNames , & namesBuf , & valueLen , batch ) ; err = j_batch_execute ( batch ) ; if ( valueLen == 0 ) { bsonNames = bson_new ( ) ; } else { bsonNames = bson_new_from_data ( ( const uint8_t * ) namesBuf , valueLen ) ; } free ( namesBuf ) ; if ( ! bson_iter_init_find ( & bIter , bsonNames , name ) ) { bson_append_int32 ( bsonNames , name , -1 , 42 ) ; } else { } namesBuf = g_memdup2 ( bson_get_data ( bsonNames ) , bsonNames -> len ) ; j_kv_put ( kvObjectNames , namesBuf , bsonNames -> len , g_free , batch2 ) ; g_assert_true ( j_batch_execute ( batch2 ) == true ) ; free ( name ) ; bson_destroy ( bsonNames ) ; j_kv_unref ( kvObjectNames ) ; j_batch_unref ( batch ) ; j_batch_unref ( batch2 ) ; j_semantics_unref ( semantics ) ; }
Writes name of variable/attribute to Julea KV.
Writes name of variable / attribute to Julea KV .
// std::cout << "kvName: " << kvName << std::endl; // std::cout << "nameSpace: " << nameSpace << std::endl; // std::cout << "paramName: " << paramName << std::endl; /** store all variable names for a file = namespace */ /* Check if variable name is already in kv store */ // std::cout << "++ Julea Interaction Writer:  " << name // << " already in kv store. " << std::endl; // err = j_batch_execute(batch2); // free(namesBuf); //TODO: why does this lead to segfaults?