Unverified Commit 11049198 authored by William F Godoy's avatar William F Godoy Committed by GitHub
Browse files

Merge pull request #1056 from williamfgc/single_bpfile

Support for reading adios1 single file
parents ccdfafa0 f2ad4a8b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -85,7 +85,8 @@ void BP3Reader::ReadVariableBlocks(Variable<T> &variable)
                {
                    const std::string subFileName =
                        m_BP3Deserializer.GetBPSubFileName(
                            m_Name, subStreamBoxInfo.SubStreamID);
                            m_Name, subStreamBoxInfo.SubStreamID,
                            m_BP3Deserializer.m_Minifooter.HasSubFiles);

                    m_SubFileManager.OpenFileID(
                        subFileName, subStreamBoxInfo.SubStreamID, Mode::Read,
+10 −3
Original line number Diff line number Diff line
@@ -195,9 +195,10 @@ BP3Base::GetBPSubStreamNames(const std::vector<std::string> &names) const
}

std::string BP3Base::GetBPSubFileName(const std::string &name,
                                      const size_t subFileIndex) const noexcept
                                      const size_t subFileIndex,
                                      const bool hasSubFiles) const noexcept
{
    return GetBPSubStreamName(name, subFileIndex);
    return GetBPSubStreamName(name, subFileIndex, hasSubFiles);
}

size_t BP3Base::GetBPIndexSizeInData(const std::string &variableName,
@@ -832,8 +833,14 @@ BP3Base::SetBP3Operation(const std::string type) const noexcept

// PRIVATE
std::string BP3Base::GetBPSubStreamName(const std::string &name,
                                        const size_t rank) const noexcept
                                        const size_t rank,
                                        const bool hasSubFiles) const noexcept
{
    if (!hasSubFiles)
    {
        return name;
    }

    const std::string bpName = helper::AddExtension(name, ".bp");

    // path/root.bp.dir/root.bp.Index
+6 −4
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ public:
        uint64_t PGIndexStart;
        uint64_t VarsIndexStart;
        uint64_t AttributesIndexStart;
        uint8_t Version = 3;
        int8_t Version = 3;
        bool IsLittleEndian = true;
        bool HasSubFiles = false;
    };
@@ -227,7 +227,8 @@ public:
    std::string GetBPMetadataFileName(const std::string &name) const noexcept;

    std::string GetBPSubFileName(const std::string &name,
                                 const size_t subFileIndex) const noexcept;
                                 const size_t subFileIndex,
                                 const bool hasSubFiles = true) const noexcept;

    /**
     * Returns the estimated variable index size. Used by ResizeBuffer public
@@ -595,8 +596,9 @@ protected:
        noexcept;

private:
    std::string GetBPSubStreamName(const std::string &name,
                                   const size_t rank) const noexcept;
    std::string GetBPSubStreamName(const std::string &name, const size_t rank,
                                   const bool hasSubFiles = true) const
        noexcept;

    /**
     * Specialized template for string and other types
+1 −0
Original line number Diff line number Diff line
@@ -361,6 +361,7 @@ inline void BP3Base::ParseCharacteristics(const std::vector<char> &buffer,
                characteristics.Statistics.Value =
                    helper::ReadValue<T>(buffer, position, isLittleEndian);
                characteristics.Statistics.IsValue = true;
                characteristics.EntryShapeID = ShapeID::GlobalValue;
                // adding Min Max for global and local values
                characteristics.Statistics.Min =
                    characteristics.Statistics.Value;
+11 −6
Original line number Diff line number Diff line
@@ -71,9 +71,10 @@ void BP3Deserializer::ParseMinifooter(const BufferSTL &bufferSTL)
    {
        if (helper::IsLittleEndian() != m_Minifooter.IsLittleEndian)
        {
            throw std::runtime_error("ERROR: reader found BigEndian bp file, "
            throw std::runtime_error(
                "ERROR: reader found BigEndian bp file, "
                "this version of ADIOS2 wasn't compiled "
                                     "with -DADIOS2_USE_ENDIAN_REVERSE=ON "
                "with the cmake flag -DADIOS2_USE_ENDIAN_REVERSE=ON "
                "explicitly, in call to Open\n");
        }
    }
@@ -81,12 +82,16 @@ void BP3Deserializer::ParseMinifooter(const BufferSTL &bufferSTL)

    position += 1;

    const uint8_t subFilesIndex = helper::ReadValue<uint8_t>(
    const int8_t fileType = helper::ReadValue<int8_t>(
        buffer, position, m_Minifooter.IsLittleEndian);
    if (subFilesIndex > 0)
    if (fileType == 3)
    {
        m_Minifooter.HasSubFiles = true;
    }
    else if (fileType == 0 || fileType == 2)
    {
        m_Minifooter.HasSubFiles = false;
    }

    m_Minifooter.Version = helper::ReadValue<uint8_t>(
        buffer, position, m_Minifooter.IsLittleEndian);