Skip to content
This repository was archived by the owner on Aug 13, 2019. It is now read-only.

Commit 6f9bbc7

Browse files
Open db in Read only mode (#588)
* Added db read only open mode and use it for the tsdb cli. Signed-off-by: Krasi Georgiev <[email protected]>
1 parent 3df36b4 commit 6f9bbc7

File tree

13 files changed

+559
-139
lines changed

13 files changed

+559
-139
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
## Master / unreleased
1+
## master / unreleased
2+
3+
- [FEATURE] Added `DBReadOnly` to allow opening a database in read only mode.
4+
- `DBReadOnly.Blocks()` exposes a slice of `BlockReader`s.
5+
- `BlockReader` interface - removed MinTime/MaxTime methods and now exposes the full block meta via `Meta()`.
6+
27

38
- [FEATURE] `chunckenc.Chunk.Iterator` method now takes a `chunckenc.Iterator` interface as an argument for reuse.
49

block.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,8 @@ type BlockReader interface {
138138
// Tombstones returns a TombstoneReader over the block's deleted data.
139139
Tombstones() (TombstoneReader, error)
140140

141-
// MinTime returns the min time of the block.
142-
MinTime() int64
143-
144-
// MaxTime returns the max time of the block.
145-
MaxTime() int64
141+
// Meta provides meta information about the block reader.
142+
Meta() BlockMeta
146143
}
147144

148145
// Appendable defines an entity to which data can be appended.

block_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ func TestBlockSize(t *testing.T) {
175175
testutil.Ok(t, blockInit.Close())
176176
}()
177177
expSizeInit = blockInit.Size()
178-
actSizeInit, err := testutil.DirSize(blockInit.Dir())
179-
testutil.Ok(t, err)
178+
actSizeInit := testutil.DirSize(t, blockInit.Dir())
180179
testutil.Equals(t, expSizeInit, actSizeInit)
181180
}
182181

@@ -185,7 +184,7 @@ func TestBlockSize(t *testing.T) {
185184
testutil.Ok(t, blockInit.Delete(1, 10, labels.NewMustRegexpMatcher("", ".*")))
186185
expAfterDelete := blockInit.Size()
187186
testutil.Assert(t, expAfterDelete > expSizeInit, "after a delete the block size should be bigger as the tombstone file should grow %v > %v", expAfterDelete, expSizeInit)
188-
actAfterDelete, err := testutil.DirSize(blockDirInit)
187+
actAfterDelete := testutil.DirSize(t, blockDirInit)
189188
testutil.Ok(t, err)
190189
testutil.Equals(t, expAfterDelete, actAfterDelete, "after a delete reported block size doesn't match actual disk size")
191190

@@ -199,8 +198,7 @@ func TestBlockSize(t *testing.T) {
199198
testutil.Ok(t, blockAfterCompact.Close())
200199
}()
201200
expAfterCompact := blockAfterCompact.Size()
202-
actAfterCompact, err := testutil.DirSize(blockAfterCompact.Dir())
203-
testutil.Ok(t, err)
201+
actAfterCompact := testutil.DirSize(t, blockAfterCompact.Dir())
204202
testutil.Assert(t, actAfterDelete > actAfterCompact, "after a delete and compaction the block size should be smaller %v,%v", actAfterDelete, actAfterCompact)
205203
testutil.Equals(t, expAfterCompact, actAfterCompact, "after a delete and compaction reported block size doesn't match actual disk size")
206204
}

0 commit comments

Comments
 (0)