mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-05 08:10:50 +00:00
added compression to bytes method;renamed fragment_container
This commit is contained in:
parent
a4ed1d9a8c
commit
f04d2f3474
3 changed files with 19 additions and 4 deletions
|
|
@ -1,6 +1,11 @@
|
|||
package index
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"io/ioutil"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Rank struct {
|
||||
Key, Count uint64
|
||||
|
|
@ -125,12 +130,19 @@ func NewGetBytes(bh BitmapHandle) *CmdGetBytes {
|
|||
|
||||
func (cmd *CmdGetBytes) Execute(f *Fragment) Calculation {
|
||||
bm, _ := f.getBitmap(cmd.bitmap)
|
||||
return bm.ToBytes()
|
||||
//*Compress it
|
||||
var b bytes.Buffer
|
||||
w := gzip.NewWriter(&b)
|
||||
w.Write(bm.ToBytes())
|
||||
w.Flush()
|
||||
w.Close()
|
||||
|
||||
return b.Bytes()
|
||||
}
|
||||
|
||||
type CmdFromBytes struct {
|
||||
*Responder
|
||||
bytes []byte
|
||||
compressed_bytes []byte
|
||||
}
|
||||
|
||||
func NewFromBytes(bytes []byte) *CmdFromBytes {
|
||||
|
|
@ -138,7 +150,10 @@ func NewFromBytes(bytes []byte) *CmdFromBytes {
|
|||
}
|
||||
|
||||
func (cmd *CmdFromBytes) Execute(f *Fragment) Calculation {
|
||||
reader, _ := gzip.NewReader(bytes.NewReader(cmd.compressed_bytes))
|
||||
b, _ := ioutil.ReadAll(reader)
|
||||
|
||||
result := NewBitmap()
|
||||
result.FromBytes(cmd.bytes)
|
||||
result.FromBytes(b)
|
||||
return f.AllocHandle(result)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue