asByteArray and back forth

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

asByteArray and back forth

Maarten Mostert

Hi,

 

I want to convert anOrderedCollection with things to a ByteArray to get it into Glrop:

 

I have been trying things like

 

self task_res_selections: ((BinaryObjectStorage

onNew: 'Resources' asByteArray readWriteStream)

nextPut: (OrderedCollection with: aResourceKeyColl);

close)

 

 

To get things back I do:

 

| boss storeCollection |

boss := self task_res_selections.

boss isNil

ifTrue: [^nil]

ifFalse:

[boss reset.

storeCollection := boss next.

^storeCollection first]

 

 

This does not give an error but doesn't really write to the database as Glorp needs a real ByteArray to do do.

Can someone indicate how to convert back and forth from an ByteArray.

 

Thanks,

 

@+Maarten,

 

 


 

 

 

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: asByteArray and back forth

Tom Robinson
Maarten,

Are you trying to send this to a Blob field?

On 8/16/13 6:38 AM, [hidden email] wrote:

Hi,

 

I want to convert anOrderedCollection with things to a ByteArray to get it into Glrop:

 

I have been trying things like

 

self task_res_selections: ((BinaryObjectStorage

onNew: 'Resources' asByteArray readWriteStream)

nextPut: (OrderedCollection with: aResourceKeyColl);

close)

 

 

To get things back I do:

 

| boss storeCollection |

boss := self task_res_selections.

boss isNil

ifTrue: [^nil]

ifFalse:

[boss reset.

storeCollection := boss next.

^storeCollection first]

 

 

This does not give an error but doesn't really write to the database as Glorp needs a real ByteArray to do do.

Can someone indicate how to convert back and forth from an ByteArray.

 

Thanks,

 

@+Maarten,

 

 


 

 

 

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: asByteArray and back forth

Maarten Mostert

HiTom,

 

Yes I do !

 

> "Tom Robinson" <[hidden email]> |

Maarten,

Are you trying to send this to a Blob field?

On 8/16/13 6:38 AM, [hidden email] wrote:

Hi,

 

I want to convert anOrderedCollection with things to a ByteArray to get it into Glrop:

 

I have been trying things like

 

self task_res_selections: ((BinaryObjectStorage

onNew: 'Resources' asByteArray readWriteStream)

nextPut: (OrderedCollection with: aResourceKeyColl);

close)

 

 

To get things back I do:

 

| boss storeCollection |

boss := self task_res_selections.

boss isNil

ifTrue: [^nil]

ifFalse:

[boss reset.

storeCollection := boss next.

^storeCollection first]

 

 

This does not give an error but doesn't really write to the database as Glorp needs a real ByteArray to do do.

Can someone indicate how to convert back and forth from an ByteArray.

 

Thanks,

 

@+Maarten,

 

 


 

 

 

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: asByteArray and back forth

Tom Robinson
Maarten,

If you look at class Store.Glorp.StoreBlob, you will find how Store does this. The method StoreBlob class>>#forObject: basically does what you're looking for. For an example of creating an instance, look at StoreProperty>>#named:forObject:in:.

I haven't looked at what you have to do with just Glorp lately, but let me know if examination of these pieces (and possibly the StoreDescriptorSystem hierarchy) raises more questions...

Tom

On 8/16/13 8:04 AM, [hidden email] wrote:

HiTom,

 

Yes I do !

 

> "Tom Robinson" [hidden email] |

Maarten,

Are you trying to send this to a Blob field?

On 8/16/13 6:38 AM, [hidden email] wrote:

Hi,

 

I want to convert anOrderedCollection with things to a ByteArray to get it into Glrop:

 

I have been trying things like

 

self task_res_selections: ((BinaryObjectStorage

onNew: 'Resources' asByteArray readWriteStream)

nextPut: (OrderedCollection with: aResourceKeyColl);

close)

 

 

To get things back I do:

 

| boss storeCollection |

boss := self task_res_selections.

boss isNil

ifTrue: [^nil]

ifFalse:

[boss reset.

storeCollection := boss next.

^storeCollection first]

 

 

This does not give an error but doesn't really write to the database as Glorp needs a real ByteArray to do do.

Can someone indicate how to convert back and forth from an ByteArray.

 

Thanks,

 

@+Maarten,

 

 


 

 

 

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: asByteArray and back forth

Maarten Mostert

Hi Tom,

 

This does the job, where aResourceKeyColl can probably whatever object lessthen 32k, thanks

 

task_res_selections: aResourceKeyColl

"task_res_selections  <> BinaryObjectStorage"


| myByteArray |

myByteArray := #Resources asByteArray.

(BinaryObjectStorage onNew: myByteArray readWriteStream)

nextPut: (OrderedCollection with: aResourceKeyColl);

close.

self task_res_selections_bits: myByteArray


 

task_res_selections

"task_res_selections  <> BinaryObjectStorage"

 

| boss |

boss := self task_res_selections_bits.

boss isNil

ifTrue: [^OrderedCollection new]

ifFalse: [^(BinaryObjectStorage onOldNoScan: boss readStream) next first]

 

 


 

> "Tom Robinson" <[hidden email]> |

Maarten,

If you look at class Store.Glorp.StoreBlob, you will find how Store does this. The method StoreBlob class>>#forObject: basically does what you're looking for. For an example of creating an instance, look at StoreProperty>>#named:forObject:in:.

I haven't looked at what you have to do with just Glorp lately, but let me know if examination of these pieces (and possibly the StoreDescriptorSystem hierarchy) raises more questions...

Tom

On 8/16/13 8:04 AM, [hidden email] wrote:

HiTom,

 

Yes I do !

 

> "Tom Robinson" [hidden email] |

Maarten,

Are you trying to send this to a Blob field?

On 8/16/13 6:38 AM, [hidden email] wrote:

Hi,

 

I want to convert anOrderedCollection with things to a ByteArray to get it into Glrop:

 

I have been trying things like

 

self task_res_selections: ((BinaryObjectStorage

onNew: 'Resources' asByteArray readWriteStream)

nextPut: (OrderedCollection with: aResourceKeyColl);

close)

 

 

To get things back I do:

 

| boss storeCollection |

boss := self task_res_selections.

boss isNil

ifTrue: [^nil]

ifFalse:

[boss reset.

storeCollection := boss next.

^storeCollection first]

 

 

This does not give an error but doesn't really write to the database as Glorp needs a real ByteArray to do do.

Can someone indicate how to convert back and forth from an ByteArray.

 

Thanks,

 

@+Maarten,

 

 


 

 

 

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "glorp-group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/glorp-group.
For more options, visit https://groups.google.com/groups/opt_out.