Compressing large arrays

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

Compressing large arrays

Christoph Thiede

Hi,


today I learned that I can use #byte64Encoded to compress ByteArrays (and #mimeDecodeToBytes: to uncompress it again).

However, I wonder whether there is an option to do the same for arrays that elements' are not limited to bytes. Concretely, I have got an array of integers in range (-20601 to: 20935), so I can map it to 6 or 8 bytes per value. Does Squeak support any way to compress such an array to a stream?


Best,

Christoph


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: Compressing large arrays

Yoshiki Ohshima-3
For values in that range, you can store them in a typed array called
ShortIntegerArray. (not 6 or 8 bytes but 2 bytes per value). Then,
there are some bit manipulation magic to get bytes and simply store
them into a file for example.

On Mon, Sep 30, 2019 at 9:31 AM Thiede, Christoph
<[hidden email]> wrote:

>
> Hi,
>
>
> today I learned that I can use #byte64Encoded to compress ByteArrays (and #mimeDecodeToBytes: to uncompress it again).
>
> However, I wonder whether there is an option to do the same for arrays that elements' are not limited to bytes. Concretely, I have got an array of integers in range (-20601 to: 20935), so I can map it to 6 or 8 bytes per value. Does Squeak support any way to compress such an array to a stream?
>
>
> Best,
>
> Christoph
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



--
-- Yoshiki
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Compressing large arrays

Christoph Thiede

Thank you for your reply. I already thought about bit manipulation, but actually, I was searching for an existing interface for this purpose. So there is no one (yet)?


Von: Beginners <[hidden email]> im Auftrag von Yoshiki Ohshima <[hidden email]>
Gesendet: Montag, 30. September 2019 20:30:37
An: A friendly place to get answers to even the most basic questions about Squeak.
Betreff: Re: [Newbies] Compressing large arrays
 
For values in that range, you can store them in a typed array called
ShortIntegerArray. (not 6 or 8 bytes but 2 bytes per value). Then,
there are some bit manipulation magic to get bytes and simply store
them into a file for example.

On Mon, Sep 30, 2019 at 9:31 AM Thiede, Christoph
<[hidden email]> wrote:
>
> Hi,
>
>
> today I learned that I can use #byte64Encoded to compress ByteArrays (and #mimeDecodeToBytes: to uncompress it again).
>
> However, I wonder whether there is an option to do the same for arrays that elements' are not limited to bytes. Concretely, I have got an array of integers in range (-20601 to: 20935), so I can map it to 6 or 8 bytes per value. Does Squeak support any way to compress such an array to a stream?
>
>
> Best,
>
> Christoph
>
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



--
-- Yoshiki
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: Compressing large arrays

Yoshiki Ohshima-3
The thing to use is the hackBits: method of Form class.  It is a bit
tricky to use, but some examples can be found here:

http://forum.world.st/Get-raw-24-Bit-image-data-into-a-Form-td4846845.html

basically the BitBlt mechanism can take byte objects as well as word
objects and "render" one kind onto another.

On Tue, Oct 1, 2019 at 3:14 AM Thiede, Christoph
<[hidden email]> wrote:

>
> Thank you for your reply. I already thought about bit manipulation, but actually, I was searching for an existing interface for this purpose. So there is no one (yet)?
>
> ________________________________
> Von: Beginners <[hidden email]> im Auftrag von Yoshiki Ohshima <[hidden email]>
> Gesendet: Montag, 30. September 2019 20:30:37
> An: A friendly place to get answers to even the most basic questions about Squeak.
> Betreff: Re: [Newbies] Compressing large arrays
>
> For values in that range, you can store them in a typed array called
> ShortIntegerArray. (not 6 or 8 bytes but 2 bytes per value). Then,
> there are some bit manipulation magic to get bytes and simply store
> them into a file for example.
>
> On Mon, Sep 30, 2019 at 9:31 AM Thiede, Christoph
> <[hidden email]> wrote:
> >
> > Hi,
> >
> >
> > today I learned that I can use #byte64Encoded to compress ByteArrays (and #mimeDecodeToBytes: to uncompress it again).
> >
> > However, I wonder whether there is an option to do the same for arrays that elements' are not limited to bytes. Concretely, I have got an array of integers in range (-20601 to: 20935), so I can map it to 6 or 8 bytes per value. Does Squeak support any way to compress such an array to a stream?
> >
> >
> > Best,
> >
> > Christoph
> >
> > _______________________________________________
> > Beginners mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>
>
> --
> -- Yoshiki
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



--
-- Yoshiki
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Compressing large arrays

Christoph Thiede

Mh, actually I was not talking about Forms but about sound samples ...


Von: Beginners <[hidden email]> im Auftrag von Yoshiki Ohshima <[hidden email]>
Gesendet: Dienstag, 1. Oktober 2019 16:04:06
An: A friendly place to get answers to even the most basic questions about Squeak.
Betreff: Re: [Newbies] Compressing large arrays
 
The thing to use is the hackBits: method of Form class.  It is a bit
tricky to use, but some examples can be found here:

http://forum.world.st/Get-raw-24-Bit-image-data-into-a-Form-td4846845.html

basically the BitBlt mechanism can take byte objects as well as word
objects and "render" one kind onto another.

On Tue, Oct 1, 2019 at 3:14 AM Thiede, Christoph
<[hidden email]> wrote:
>
> Thank you for your reply. I already thought about bit manipulation, but actually, I was searching for an existing interface for this purpose. So there is no one (yet)?
>
> ________________________________
> Von: Beginners <[hidden email]> im Auftrag von Yoshiki Ohshima <[hidden email]>
> Gesendet: Montag, 30. September 2019 20:30:37
> An: A friendly place to get answers to even the most basic questions about Squeak.
> Betreff: Re: [Newbies] Compressing large arrays
>
> For values in that range, you can store them in a typed array called
> ShortIntegerArray. (not 6 or 8 bytes but 2 bytes per value). Then,
> there are some bit manipulation magic to get bytes and simply store
> them into a file for example.
>
> On Mon, Sep 30, 2019 at 9:31 AM Thiede, Christoph
> <[hidden email]> wrote:
> >
> > Hi,
> >
> >
> > today I learned that I can use #byte64Encoded to compress ByteArrays (and #mimeDecodeToBytes: to uncompress it again).
> >
> > However, I wonder whether there is an option to do the same for arrays that elements' are not limited to bytes. Concretely, I have got an array of integers in range (-20601 to: 20935), so I can map it to 6 or 8 bytes per value. Does Squeak support any way to compress such an array to a stream?
> >
> >
> > Best,
> >
> > Christoph
> >
> > _______________________________________________
> > Beginners mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>
>
> --
> -- Yoshiki
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



--
-- Yoshiki
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: Compressing large arrays

Yoshiki Ohshima-3
Just to note that the hackBits: technique can be used any words and
bytes objects, including ShortIntegerArray.


On Tue, Oct 1, 2019 at 11:47 AM Thiede, Christoph
<[hidden email]> wrote:

>
> Mh, actually I was not talking about Forms but about sound samples ...
>
> ________________________________
> Von: Beginners <[hidden email]> im Auftrag von Yoshiki Ohshima <[hidden email]>
> Gesendet: Dienstag, 1. Oktober 2019 16:04:06
> An: A friendly place to get answers to even the most basic questions about Squeak.
> Betreff: Re: [Newbies] Compressing large arrays
>
> The thing to use is the hackBits: method of Form class.  It is a bit
> tricky to use, but some examples can be found here:
>
> http://forum.world.st/Get-raw-24-Bit-image-data-into-a-Form-td4846845.html
>
> basically the BitBlt mechanism can take byte objects as well as word
> objects and "render" one kind onto another.
>
> On Tue, Oct 1, 2019 at 3:14 AM Thiede, Christoph
> <[hidden email]> wrote:
> >
> > Thank you for your reply. I already thought about bit manipulation, but actually, I was searching for an existing interface for this purpose. So there is no one (yet)?
> >
> > ________________________________
> > Von: Beginners <[hidden email]> im Auftrag von Yoshiki Ohshima <[hidden email]>
> > Gesendet: Montag, 30. September 2019 20:30:37
> > An: A friendly place to get answers to even the most basic questions about Squeak.
> > Betreff: Re: [Newbies] Compressing large arrays
> >
> > For values in that range, you can store them in a typed array called
> > ShortIntegerArray. (not 6 or 8 bytes but 2 bytes per value). Then,
> > there are some bit manipulation magic to get bytes and simply store
> > them into a file for example.
> >
> > On Mon, Sep 30, 2019 at 9:31 AM Thiede, Christoph
> > <[hidden email]> wrote:
> > >
> > > Hi,
> > >
> > >
> > > today I learned that I can use #byte64Encoded to compress ByteArrays (and #mimeDecodeToBytes: to uncompress it again).
> > >
> > > However, I wonder whether there is an option to do the same for arrays that elements' are not limited to bytes. Concretely, I have got an array of integers in range (-20601 to: 20935), so I can map it to 6 or 8 bytes per value. Does Squeak support any way to compress such an array to a stream?
> > >
> > >
> > > Best,
> > >
> > > Christoph
> > >
> > > _______________________________________________
> > > Beginners mailing list
> > > [hidden email]
> > > http://lists.squeakfoundation.org/mailman/listinfo/beginners
> >
> >
> >
> > --
> > -- Yoshiki
> > _______________________________________________
> > Beginners mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/mailman/listinfo/beginners
> > _______________________________________________
> > Beginners mailing list
> > [hidden email]
> > http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>
>
> --
> -- Yoshiki
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
> _______________________________________________
> Beginners mailing list
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



--
-- Yoshiki
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners