help on stxxl::vectors

pavan842
2011-10-01
2013-04-25
  • pavan842

    pavan842 - 2011-10-01

    #include <stxxl.h>
    #include <iostream>
    #include <vector>

    using namespace stxxl;

    class datanode
    {
        public:
        vector <int> v;
        void pushele(int i)
        {
            for(int j=0;j<10;j++)
                v.push_back(i*10+j);
        }
    };

    vector <datanode> data(10);

    int main()
    {

        for(int i=0;i<10;i++)
            data_.pushele(i);

        return 0;
    }

    the above code is throwing an error std::bad_alloc, I have allocated 7gb external space, can anyone tel what's the problem.

    _

     
  • pavan842

    pavan842 - 2011-10-01

    I have even tried the other one, it's also giving the same error as mentioned above

    #include <stxxl.h>
    #include <iostream>
    #include <vector>

    using namespace stxxl;

    class datanode
    {
        public:
        vector <int> v;
    };

    int main()
    {
        vector <datanode> data(10);

        for(int i=0;i<10;i++)
            for(int j=0;j<10;j++)
                data_.v.push_back(i*10+j);

        return 0;
    }

    _

     
  • Mohammed Mediani

    instead of : vector <int> v;
    use: stxxl::vector <int> v;
    and so on

     
  • Mohammed Mediani

    sorry,
    try to use std vector of stxxl vectors, instead. Using stxxl vectors of stxxl vectors is not recommended if I remember well,

     
  • pavan842

    pavan842 - 2011-10-02

    I cant use a std::vector inside a class, since my data in that vector can go beyond main memory limit.

    Doesn't the library support such a feature?

     
  • Johannes Singler

    The library only supports std::vector<stxxl::vector<T>>, but not the other way around. An stxxl::vector makes sense from maybe 1 million elements, but the sqaure of that usually hardly fits on any disk any more.  So do you have a vector of vectors of largely varying size?  Or can you map two-dimensional structure into a one-dimensional one easily?

     
  • pavan842

    pavan842 - 2011-10-07

    Thanks for the info..

     

Log in to post a comment.