mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Sumo ensemble parameters: handle string properties.
This commit is contained in:
@@ -101,3 +101,25 @@ QString RifArrowTools::readFirstRowsOfTable( const QByteArray& contents )
|
||||
|
||||
return tableText;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::string> RifArrowTools::chunkedArrayToStringVector( const std::shared_ptr<arrow::ChunkedArray>& chunkedArray )
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
|
||||
for ( int i = 0; i < chunkedArray->num_chunks(); ++i )
|
||||
{
|
||||
auto chunk = std::static_pointer_cast<arrow::StringArray>( chunkedArray->chunk( i ) );
|
||||
for ( int j = 0; j < chunk->length(); ++j )
|
||||
{
|
||||
if ( !chunk->IsNull( j ) )
|
||||
{
|
||||
result.push_back( chunk->Value( j ).data() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@@ -19,7 +19,9 @@
|
||||
#pragma once
|
||||
|
||||
#undef signals
|
||||
#include <arrow/array/array_binary.h>
|
||||
#include <arrow/array/array_primitive.h>
|
||||
|
||||
#define signals Q_SIGNALS
|
||||
|
||||
#include <limits>
|
||||
@@ -67,5 +69,8 @@ std::vector<CType> chunkedArrayToVector( const std::shared_ptr<arrow::ChunkedArr
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::string> chunkedArrayToStringVector( const std::shared_ptr<arrow::ChunkedArray>& chunkedArray );
|
||||
|
||||
QString readFirstRowsOfTable( const QByteArray& contents );
|
||||
|
||||
}; // namespace RifArrowTools
|
||||
|
@@ -32,6 +32,8 @@
|
||||
#include "RimSummaryCaseSumo.h"
|
||||
#include "RimSummarySumoDataSource.h"
|
||||
|
||||
#include <arrow/type_fwd.h>
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimSummaryEnsembleSumo, "RimSummaryEnsembleSumo" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -347,8 +349,9 @@ void RimSummaryEnsembleSumo::distributeParametersDataToRealizations( std::shared
|
||||
}
|
||||
}
|
||||
|
||||
std::map<std::string, std::vector<double>> doubleValuesForRealizations;
|
||||
std::map<std::string, std::vector<int64_t>> intValuesForRealizations;
|
||||
std::map<std::string, std::vector<double>> doubleValuesForRealizations;
|
||||
std::map<std::string, std::vector<int64_t>> intValuesForRealizations;
|
||||
std::map<std::string, std::vector<std::string>> stringValuesForRealizations;
|
||||
for ( std::string columnName : table->ColumnNames() )
|
||||
{
|
||||
if ( columnName != "REAL" )
|
||||
@@ -367,6 +370,11 @@ void RimSummaryEnsembleSumo::distributeParametersDataToRealizations( std::shared
|
||||
std::vector<int64_t> values = RifArrowTools::chunkedArrayToVector<arrow::Int64Array, int64_t>( column );
|
||||
intValuesForRealizations[columnName] = values;
|
||||
}
|
||||
else if ( column->type()->id() == arrow::Type::STRING )
|
||||
{
|
||||
std::vector<std::string> values = RifArrowTools::chunkedArrayToStringVector( column );
|
||||
stringValuesForRealizations[columnName] = values;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -416,6 +424,11 @@ void RimSummaryEnsembleSumo::distributeParametersDataToRealizations( std::shared
|
||||
double value = it->second[realizationNumber];
|
||||
parameters->addParameter( QString::fromStdString( columnName ), value );
|
||||
}
|
||||
else if ( auto it = stringValuesForRealizations.find( columnName ); it != stringValuesForRealizations.end() )
|
||||
{
|
||||
QString value = QString::fromStdString( it->second[realizationNumber] );
|
||||
parameters->addParameter( QString::fromStdString( columnName ), value );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user