Skip to content

Commit 73197eb

Browse files
[arcane,std] Ajoute récupération du hash de comparaison en relecture.
Renomme aussi 'compare_hash' en 'comparison_hash'.
1 parent 29ddb20 commit 73197eb

8 files changed

+38
-13
lines changed

arcane/src/arcane/std/BasicGenericReader.cc

+13-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ initialize(const String& path, Int32 rank)
121121
if (!hash_algorithm_name.null())
122122
hash_algorithm = BasicReaderWriterCommon::_createHashAlgorithm(m_application, hash_algorithm_name);
123123

124-
for (Integer i = 0, is = variables_elem.size(); i < is; ++i) {
125-
XmlNode n = variables_elem[i];
124+
for (const XmlNode& n : variables_elem) {
126125
String var_full_name = n.attrValue("full-name");
127126
m_variables_data_info.add(var_full_name, n);
128127
}
@@ -239,6 +238,18 @@ readItemGroup(const String& group_full_name, Int64Array& written_unique_ids,
239238
/*---------------------------------------------------------------------------*/
240239
/*---------------------------------------------------------------------------*/
241240

241+
String BasicGenericReader::
242+
comparisonHashValue(const String& var_full_name) const
243+
{
244+
Ref<VariableDataInfo> vdi = m_variables_data_info.find(var_full_name);
245+
if (vdi.get())
246+
return vdi->comparisonHashValue();
247+
return {};
248+
}
249+
250+
/*---------------------------------------------------------------------------*/
251+
/*---------------------------------------------------------------------------*/
252+
242253
} // namespace Arcane::impl
243254

244255
/*---------------------------------------------------------------------------*/

arcane/src/arcane/std/BasicGenericWriter.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ initialize(const String& path, Int32 rank)
6262

6363
void BasicGenericWriter::
6464
writeData(const String& var_full_name, const ISerializedData* sdata,
65-
const String& compare_hash)
65+
const String& comparison_hash)
6666
{
6767
//TODO: Verifier que initialize() a bien été appelé.
6868
auto var_data_info = m_variables_data_info.add(var_full_name, sdata);
6969
KeyValueTextWriter* writer = m_text_writer.get();
7070
var_data_info->setFileOffset(writer->fileOffset());
71-
var_data_info->setCompareHashValue(compare_hash);
71+
var_data_info->setComparisonHashValue(comparison_hash);
7272
info(4) << " SDATA name=" << var_full_name << " nb_element=" << sdata->nbElement()
7373
<< " dim=" << sdata->nbDimension() << " datatype=" << sdata->baseDataType()
7474
<< " nb_basic_element=" << sdata->nbBaseElement()

arcane/src/arcane/std/BasicReader.cc

+11-2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ initialize()
7171
}
7272
String data_compressor_name;
7373
String hash_algorithm_name;
74+
String comparison_hash_algorithm_name;
7475
if (has_db_file) {
7576
UniqueArray<Byte> bytes;
7677
pm->ioMng()->collectiveRead(db_filename, bytes, false);
@@ -82,10 +83,12 @@ initialize()
8283
m_nb_written_part = jv_arcane_db.expectedChild("NbPart").valueAsInt32();
8384
data_compressor_name = jv_arcane_db.child("DataCompressor").value();
8485
hash_algorithm_name = jv_arcane_db.child("HashAlgorithm").value();
86+
comparison_hash_algorithm_name = jv_arcane_db.child("ComparisonHashAlgorithm").value();
8587
info() << "**--** Begin read using database version=" << m_version
8688
<< " nb_part=" << m_nb_written_part
8789
<< " compressor=" << data_compressor_name
88-
<< " hash_algorithm=" << hash_algorithm_name;
90+
<< " hash_algorithm=" << hash_algorithm_name
91+
<< " comparison_hash_algorithm=" << comparison_hash_algorithm_name;
8992
}
9093
else {
9194
// Ancien format
@@ -120,6 +123,10 @@ initialize()
120123
Ref<IHashAlgorithm> v = _createHashAlgorithm(m_application, hash_algorithm_name);
121124
m_forced_rank_to_read_text_reader->setHashAlgorithm(v);
122125
}
126+
if (!comparison_hash_algorithm_name.empty()) {
127+
Ref<IHashAlgorithm> v = _createHashAlgorithm(m_application, comparison_hash_algorithm_name);
128+
m_comparison_hash_algorithm = v;
129+
}
123130
}
124131
}
125132

@@ -130,7 +137,7 @@ void BasicReader::
130137
_directReadVal(VariableMetaData* varmd, IData* data)
131138
{
132139
info(4) << "DIRECT READ VAL v=" << varmd->fullName();
133-
140+
134141
bool is_item_variable = !varmd->itemFamilyName().null();
135142
Int32 nb_rank_to_read = m_nb_rank_to_read;
136143
// S'il s'agit d'une variable qui n'est pas sur le maillage,
@@ -153,6 +160,8 @@ _directReadVal(VariableMetaData* varmd, IData* data)
153160
String vname = varmd->fullName();
154161
info(4) << " TRY TO READ var_full_name=" << vname;
155162
m_global_readers[i]->readData(vname, written_data[i]);
163+
if (i==0 && m_comparison_hash_algorithm.get() )
164+
info(5) << "COMPARISON_HASH =" << m_global_readers[i]->comparisonHashValue(vname);
156165
}
157166

158167
if (is_item_variable) {

arcane/src/arcane/std/BasicWriter.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ _endWriteV3()
325325
String name;
326326
if (m_compare_hash_algorithm.get())
327327
name = m_compare_hash_algorithm->name();
328-
jsw.write("CompareHashAlgorithm", name);
328+
jsw.write("ComparisonHashAlgorithm", name);
329329
}
330330
}
331331
}

arcane/src/arcane/std/VariableDataInfo.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ VariableDataInfo(const String& full_name, const XmlNode& element)
8181
// L'attribut 'compare-hash' est nul si on repart d'une veille protection (avant Arcane 3.12)
8282
XmlNode hash_attr = element.attr("compare-hash");
8383
if (!hash_attr.null())
84-
m_compare_hash_value = hash_attr.value();
84+
m_comparison_hash_value = hash_attr.value();
8585
}
8686
}
8787

@@ -102,7 +102,7 @@ write(XmlNode element) const
102102
_addAttribute(element, "memory-size", m_memory_size);
103103
_addAttribute(element, "file-offset", m_file_offset);
104104
_addAttribute(element, "shape-size", m_shape.dimensions().size());
105-
_addAttribute(element, "compare-hash", m_compare_hash_value);
105+
_addAttribute(element, "comparison-hash", m_comparison_hash_value);
106106
{
107107
String s;
108108
if (builtInPutValue(m_shape.dimensions().smallView(), s))

arcane/src/arcane/std/internal/BasicReader.h

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class BasicReader
8888
IItemGroupFinder* m_item_group_finder;
8989
Ref<KeyValueTextReader> m_forced_rank_to_read_text_reader; //!< Lecteur pour le premier rang à lire.
9090
Ref<IDataCompressor> m_data_compressor;
91+
Ref<IHashAlgorithm> m_comparison_hash_algorithm;
9192

9293
private:
9394

arcane/src/arcane/std/internal/BasicReaderWriter.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@ class IGenericReader
9898
virtual void readData(const String& var_full_name, IData* data) = 0;
9999
virtual void readItemGroup(const String& group_name, Int64Array& written_unique_ids,
100100
Int64Array& wanted_unique_ids) = 0;
101+
virtual String comparisonHashValue(const String& var_full_name) const = 0;
101102
};
102103

103104
/*---------------------------------------------------------------------------*/
104105
/*---------------------------------------------------------------------------*/
105-
106+
/*!
107+
* \brief Implémentation basique de \a IGenericReader
108+
*/
106109
class BasicGenericReader
107110
: public TraceAccessor
108111
, public IGenericReader
@@ -119,6 +122,7 @@ class BasicGenericReader
119122
void readData(const String& var_full_name, IData* data) override;
120123
void readItemGroup(const String& group_name, Int64Array& written_unique_ids,
121124
Int64Array& wanted_unique_ids) override;
125+
String comparisonHashValue(const String& var_full_name) const override;
122126

123127
private:
124128

arcane/src/arcane/std/internal/VariableDataInfo.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class VariableDataInfo
5656
const ArrayShape& shape() const { return m_shape; }
5757
void setFileOffset(Int64 v) { m_file_offset = v; }
5858
Int64 fileOffset() const { return m_file_offset; }
59-
void setCompareHashValue(const String& v) { m_compare_hash_value = v; }
60-
const String& compareHashValue() const { return m_compare_hash_value; }
59+
void setComparisonHashValue(const String& v) { m_comparison_hash_value = v; }
60+
const String& comparisonHashValue() const { return m_comparison_hash_value; }
6161

6262
public:
6363

@@ -109,7 +109,7 @@ class VariableDataInfo
109109
Int64 m_memory_size = 0;
110110
Int64 m_file_offset = 0;
111111
ArrayShape m_shape;
112-
String m_compare_hash_value;
112+
String m_comparison_hash_value;
113113
};
114114

115115
/*---------------------------------------------------------------------------*/

0 commit comments

Comments
 (0)