Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constant value to make the code more readable #568

Merged
merged 4 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ import (
"github.com/polarsignals/frostdb/wal"
)

const (
B = 1
KiB = 1024 * B
MiB = 1024 * KiB
GiB = 1024 * MiB
TiB = 1024 * GiB
)

type ColumnStore struct {
mtx *sync.RWMutex
dbs map[string]*DB
Expand Down Expand Up @@ -89,8 +97,8 @@ func New(
indexConfig: DefaultIndexConfig(),
indexDegree: 2,
splitSize: 2,
granuleSizeBytes: 1 * 1024 * 1024, // 1MB granule size before splitting
activeMemorySize: 512 * 1024 * 1024, // 512MB
granuleSizeBytes: 1 * MiB,
activeMemorySize: 512 * MiB,
}

for _, option := range options {
Expand Down
16 changes: 8 additions & 8 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestDBWithWALAndBucket(t *testing.T) {
WithWAL(),
WithStoragePath(dir),
WithReadWriteStorage(sinksource),
WithActiveMemorySize(100*1024),
WithActiveMemorySize(100*KiB),
)
require.NoError(t, err)
db, err := c.DB(context.Background(), "test")
Expand All @@ -71,7 +71,7 @@ func TestDBWithWALAndBucket(t *testing.T) {
WithWAL(),
WithStoragePath(dir),
WithReadWriteStorage(sinksource),
WithActiveMemorySize(100*1024),
WithActiveMemorySize(100*KiB),
)
require.NoError(t, err)
defer c.Close()
Expand Down Expand Up @@ -1358,7 +1358,7 @@ func Test_DB_ReadOnlyQuery(t *testing.T) {
WithWAL(),
WithStoragePath(dir),
WithReadWriteStorage(sinksource),
WithActiveMemorySize(100*1024),
WithActiveMemorySize(100*KiB),
)
require.NoError(t, err)
db, err := c.DB(context.Background(), "test")
Expand All @@ -1383,7 +1383,7 @@ func Test_DB_ReadOnlyQuery(t *testing.T) {
WithWAL(),
WithStoragePath(dir),
WithReadWriteStorage(sinksource),
WithActiveMemorySize(100*1024),
WithActiveMemorySize(100*KiB),
)
require.NoError(t, err)
defer c.Close()
Expand Down Expand Up @@ -1867,7 +1867,7 @@ func Test_DB_DropStorage(t *testing.T) {
WithLogger(logger),
WithWAL(),
WithStoragePath(dir),
WithActiveMemorySize(1024*1024),
WithActiveMemorySize(1*MiB),
)
defer func() {
_ = c.Close()
Expand Down Expand Up @@ -1909,7 +1909,7 @@ func Test_DB_DropStorage(t *testing.T) {
WithLogger(logger),
WithWAL(),
WithStoragePath(dir),
WithActiveMemorySize(1024*1024),
WithActiveMemorySize(1*MiB),
)
defer func() {
_ = c.Close()
Expand Down Expand Up @@ -2009,8 +2009,8 @@ func Test_DB_SnapshotOnClose(t *testing.T) {
WithLogger(logger),
WithStoragePath(dir),
WithWAL(),
WithActiveMemorySize(1024*1024*1024),
WithSnapshotTriggerSize(1024*1024*1024),
WithActiveMemorySize(1*GiB),
WithSnapshotTriggerSize(1*GiB),
WithManualBlockRotation(),
)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion store.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (b *DefaultObjstoreBucket) openBlockFile(ctx context.Context, blockName str
file, err := parquet.OpenFile(
r,
size,
parquet.ReadBufferSize(5*1024*1024), // 5MB read buffers
parquet.ReadBufferSize(5*MiB), // 5MB read buffers
parquet.SkipBloomFilters(true),
parquet.FileReadMode(parquet.ReadModeAsync),
)
Expand Down
2 changes: 1 addition & 1 deletion table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ func Test_Table_DynamicColumnNotDefined(t *testing.T) {
func TestTableUniquePrimaryIndex(t *testing.T) {
c, err := New(WithGranuleSizeBytes(1), WithIndexConfig([]*index.LevelConfig{
{Level: index.L0, MaxSize: 180},
{Level: index.L1, MaxSize: 1024 * 1024 * 1024 * 1024},
{Level: index.L1, MaxSize: 1 * TiB},
}))
require.NoError(t, err)
defer c.Close()
Expand Down