STORABLE precondition question?

4 messages Options
Embed this post
Permalink
BruceMount

STORABLE precondition question?

Reply Threaded More More options
Print post
Permalink
Well, I didn't get a single answer to my garbage collection question, so maybe I'll have better luck with this.

I watched the learning map on storable object and am trying it.  I have a loop that stored thousands of object to the file system using independent_store from SED_STORABLE_FACILITIES, called as:

store_handler.independent_store (a_history, writer, True).

The loop works fine for over 17,000 objects and then throws an precondition exception of:

a_writer_ready: <0000000000E51D24> Precondition violated.

I looked at this precondition andit is just the result of a function, which I can't decipher further.  Does anyone know what it means I'm doing wrong when this precondition gets triggered?  (Also, it would help if there were comments in the code to explain non-obvious preconditions.)

Thanks,

--Bruce


Emmanuel Stapf

RE: STORABLE precondition question?

Reply Threaded More More options
Print post
Permalink
> Well, I didn't get a single answer to my garbage collection question, so
> maybe I'll have better luck with this.

I'll get back to you on that one.
 

> I watched the learning map on storable object and am trying it.  I have a
> loop that stored thousands of object to the file system using
> independent_store from SED_STORABLE_FACILITIES, called as:
>
> store_handler.independent_store (a_history, writer, True).
>
> The loop works fine for over 17,000 objects and then throws an
> precondition exception of:
>
> a_writer_ready: <0000000000E51D24> Precondition violated.
>
> I looked at this precondition andit is just the result of a function,
> which I can't decipher further.  Does anyone know what it means I'm doing
> wrong when this precondition gets triggered?  (Also, it would help if
> there were comments in the code to explain non-obvious preconditions.)

Basically it requires you to set the associated `writer' to write mode, and if the
`writer' represents a FILE, that the file has `is_open_write' property.

Usually before calling independent_store, you just need to do:

writer.set_for_writing
store_handler.independent_store (a_history, writer, True)

Hope this helps,
Manu



------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------  
BruceMount

Re: STORABLE precondition question?

Reply Threaded More More options
Print post
Permalink
Manu:

Thanks for your response.  Unfortunately, I was already doing what you suggested, which is why I'm confused.  The code is below (dots added to preserve indenting).

store_object(a_history : HISTORY; a_filename : STRING) is
-- Store 'a-order' in file 'a_filename'.
require
....order_exists : (a_history /= Void)
....file_name_exists : (a_filename /= Void and then not a_filename.is_empty)
local
....store_handler : SED_STORABLE_FACILITIES
....writer        : SED_MEDIUM_READER_WRITER
....my_file       : RAW_FILE
do
....create my_file.make_open_write(a_filename)
....create store_handler
....create writer.make(my_file)
....writer.set_for_writing
....store_handler.independent_store (a_history, writer, True)
....my_file.close
end


This is pretty much the code from the learning map on eiffel.com.  I call store_object inside a loop and, per the last email, it works fine for 17,000+ times and then triggers the precondition failure.

--Bruce  

Emmanuel Stapf

RE: Re: STORABLE precondition question?

Reply Threaded More More options
Print post
Permalink
> This is pretty much the code from the learning map on eiffel.com.  I call
> store_object inside a loop and, per the last email, it works fine for
> 17,000+ times and then triggers the precondition failure.

The fact that it works before indicates something else. We would need more
information about the context of the failure such as the stack trace and any
information that could be relevant.

Regards,
Manu

------------------------------------------------------------------------  
Eiffel Software
805-685-1006
http://www.eiffel.com       
Customer support: http://support.eiffel.com       
User group: http://groups.eiffel.com/join       
------------------------------------------------------------------------