Skip to content

Commit

Permalink
name_lengths std::vector --> stxxl::vector
Browse files Browse the repository at this point in the history
  • Loading branch information
rparanjpe-tesla committed Dec 16, 2015
1 parent 63a5932 commit 5c3398c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -314,6 +314,7 @@ include_directories(SYSTEM ${STXXL_INCLUDE_DIR})
target_link_libraries(OSRM ${STXXL_LIBRARY})
target_link_libraries(osrm-extract ${STXXL_LIBRARY})
target_link_libraries(osrm-prepare ${STXXL_LIBRARY})
target_link_libraries(datastructure-tests ${STXXL_LIBRARY})

set(OpenMP_FIND_QUIETLY ON)
find_package(OpenMP)
Expand Down
3 changes: 2 additions & 1 deletion data_structures/range_table.hpp
Expand Up @@ -35,6 +35,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <fstream>
#include <vector>
#include <array>
#include <stxxl/vector>

/*
* These pre-declarations are needed because parsing C++ is hard
Expand Down Expand Up @@ -82,7 +83,7 @@ template <unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY> class RangeTable
}

// construct table from length vector
explicit RangeTable(const std::vector<unsigned> &lengths)
explicit RangeTable(const stxxl::vector<unsigned> &lengths)
{
const unsigned number_of_blocks = [&lengths]()
{
Expand Down
2 changes: 1 addition & 1 deletion extractor/extraction_containers.hpp
Expand Up @@ -71,7 +71,7 @@ class ExtractionContainers
STXXLNodeVector all_nodes_list;
STXXLEdgeVector all_edges_list;
stxxl::vector<char> name_char_data;
std::vector<unsigned> name_lengths;
stxxl::vector<unsigned> name_lengths;
STXXLRestrictionsVector restrictions_list;
STXXLWayIDStartEndVector way_start_end_id_list;
std::unordered_map<OSMNodeID, NodeID> external_to_internal_node_id_map;
Expand Down
18 changes: 10 additions & 8 deletions unit_tests/data_structures/range_table.cpp
Expand Up @@ -38,7 +38,7 @@ typedef RangeTable<BLOCK_SIZE, false> TestRangeTable;

BOOST_AUTO_TEST_SUITE(range_table)

void ConstructionTest(std::vector<unsigned> lengths, std::vector<unsigned> offsets)
void ConstructionTest(stxxl::vector<unsigned> lengths, std::vector<unsigned> offsets)
{
BOOST_ASSERT(lengths.size() == offsets.size() - 1);

Expand All @@ -52,7 +52,7 @@ void ConstructionTest(std::vector<unsigned> lengths, std::vector<unsigned> offse
}
}

void ComputeLengthsOffsets(std::vector<unsigned> &lengths,
void ComputeLengthsOffsets(stxxl::vector<unsigned> &lengths,
std::vector<unsigned> &offsets,
unsigned num)
{
Expand All @@ -76,7 +76,7 @@ void ComputeLengthsOffsets(std::vector<unsigned> &lengths,

BOOST_AUTO_TEST_CASE(serialization_test)
{
std::vector<unsigned> lengths;
stxxl::vector<unsigned> lengths;
std::vector<unsigned> offsets;
ComputeLengthsOffsets(lengths, offsets, (BLOCK_SIZE + 1) * 10);

Expand All @@ -98,32 +98,34 @@ BOOST_AUTO_TEST_CASE(serialization_test)
BOOST_AUTO_TEST_CASE(construction_test)
{
// only offset empty block
ConstructionTest({1}, {0, 1});
stxxl::vector<unsigned> empty_lengths;
empty_lengths.push_back(1);
ConstructionTest(empty_lengths, {0, 1});
// first block almost full => sentinel is last element of block
// [0] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, (16)}
std::vector<unsigned> almost_full_lengths;
stxxl::vector<unsigned> almost_full_lengths;
std::vector<unsigned> almost_full_offsets;
ComputeLengthsOffsets(almost_full_lengths, almost_full_offsets, BLOCK_SIZE);
ConstructionTest(almost_full_lengths, almost_full_offsets);

// first block full => sentinel is offset of new block, next block empty
// [0] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
// [(153)] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
std::vector<unsigned> full_lengths;
stxxl::vector<unsigned> full_lengths;
std::vector<unsigned> full_offsets;
ComputeLengthsOffsets(full_lengths, full_offsets, BLOCK_SIZE + 1);
ConstructionTest(full_lengths, full_offsets);

// first block full and offset of next block not sentinel, but the first differential value
// [0] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
// [153] {(17), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
std::vector<unsigned> over_full_lengths;
stxxl::vector<unsigned> over_full_lengths;
std::vector<unsigned> over_full_offsets;
ComputeLengthsOffsets(over_full_lengths, over_full_offsets, BLOCK_SIZE + 2);
ConstructionTest(over_full_lengths, over_full_offsets);

// test multiple blocks
std::vector<unsigned> multiple_lengths;
stxxl::vector<unsigned> multiple_lengths;
std::vector<unsigned> multiple_offsets;
ComputeLengthsOffsets(multiple_lengths, multiple_offsets, (BLOCK_SIZE + 1) * 10);
ConstructionTest(multiple_lengths, multiple_offsets);
Expand Down

0 comments on commit 5c3398c

Please sign in to comment.