Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
sparsehash file io
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
a.anand  
View profile  
 More options Sep 17, 11:59 am
From: "a.anand" <ashok.an...@gmail.com>
Date: Thu, 17 Sep 2009 08:59:38 -0700 (PDT)
Local: Thurs, Sep 17 2009 11:59 am
Subject: sparsehash file io
hi.. i am using sparsehash api of reading and writing hashtables to
files (using read_metadata and read_nopointer_data).  for reading, i
create a new hashtable and read from file into this hashtable. as i
clear the items in the new hashtable, i get sometimes error like
double pointer corruption, or terminate called after throwing an
instance of std::length error. I am using std::string as key, any clue
why these errors are coming up?

thanks
ashok


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Craig Silverstein  
View profile  
 More options Sep 17, 12:01 pm
From: Craig Silverstein <csilv...@google.com>
Date: Thu, 17 Sep 2009 09:01:35 -0700
Local: Thurs, Sep 17 2009 12:01 pm
Subject: Re: sparsehash file io

} i get sometimes error like double pointer corruption, or terminate
} called after throwing an instance of std::length error. I am using
} std::string as key, any clue why these errors are coming up?

You will have to use placement new to initialize the strings.  Can you
give a code sample of what you're doing now?

craig


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ashok Anand  
View profile  
 More options Sep 17, 1:06 pm
From: Ashok Anand <ashok.an...@gmail.com>
Date: Thu, 17 Sep 2009 12:06:25 -0500
Local: Thurs, Sep 17 2009 1:06 pm
Subject: Re: sparsehash file io
here is the sample..

 #define key_t std::string

// loc_t is a structure with 3 unsigned integer fields
 sparse_hash_map<key_t, loc_t> myMap;
// for writing to file pointed by pointer fp
 myMap.write_metadata(fp);
 myMap.write_nopointer_data(fp);
// for reading from file pointed by fp
sparse_hash_map<key_t, loc_t> rMap;
 rMap.read_metadata(fp);
 rMap.read_nopointer_data(fp);
// after reading and lookup is done
 rMap.clear();

is it not the right way? please let me know

thanks
ashok


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Craig Silverstein  
View profile  
 More options Sep 17, 1:37 pm
From: Craig Silverstein <csilv...@google.com>
Date: Thu, 17 Sep 2009 10:37:53 -0700
Local: Thurs, Sep 17 2009 1:37 pm
Subject: Re: sparsehash file io

} here is the sample..
}
}  #define key_t std::string
}
} // loc_t is a structure with 3 unsigned integer fields
}  sparse_hash_map<key_t, loc_t> myMap;
} // for writing to file pointed by pointer fp
}  myMap.write_metadata(fp);
}  myMap.write_nopointer_data(fp);
} // for reading from file pointed by fp
} sparse_hash_map<key_t, loc_t> rMap;
}  rMap.read_metadata(fp);
}  rMap.read_nopointer_data(fp);
} // after reading and lookup is done
}  rMap.clear();

Ah, I see.  That won't work at all because string has pointers in it.
read/write_nopointer is intended for Plain Old Data types.  You will
need to do something more complicated.  Look at the documentation; it
has an example of how to use read/write IO with non-trivial key/value
types -- I forget the exact example, but it may even be for a string.

craig


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
TopBoy  
View profile  
 More options Sep 23, 9:48 pm
From: TopBoy <cntop...@gmail.com>
Date: Wed, 23 Sep 2009 18:48:14 -0700 (PDT)
Local: Wed, Sep 23 2009 9:48 pm
Subject: Re: sparsehash file io
I use the char* as the key, so it does not work either?

On Sep 18, 1:37 am, Craig Silverstein <csilv...@google.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Craig Silverstein  
View profile  
 More options Sep 24, 3:03 pm
From: Craig Silverstein <csilv...@google.com>
Date: Thu, 24 Sep 2009 12:03:02 -0700
Local: Thurs, Sep 24 2009 3:03 pm
Subject: Re: sparsehash file io

} I use the char* as the key, so it does not work either?

No.  char* definitely doesn't fall into the category of "nopointer
data".

craig


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google