Commit Graph

141 Commits

Author SHA1 Message Date
LFC
ccda17248e feat: unify servers and mysql server in datanode (#172)
* address PR comments

address PR comments

use 3306 for mysql server's default port

upgrade metric to version 0.20

move crate "servers" out of "common"

make mysql io threads count configurable in config file

add snafu backtrace for errors with source

use common-server error for mysql server

add test for grpc server

refactor testing codes

fix rustfmt check

start mysql server in datanode

move grpc server codes from datanode to common-servers

feat: unify servers

* rebase develop and resolve conflicts

* remove an unnecessary todo

Co-authored-by: luofucong <luofucong@greptime.com>
2022-08-17 14:29:12 +08:00
evenyag
6d23118aa0 chore: Resolves remaining comments in #168 (#175)
* fix: Rename current_timestamp to current_time_millis, fix resolution

Fix current_timestamp returns seconds resolution, also add a test for
this method

* chore: Use slice of array instead of Vec

Save some heap allocations

* test: Compare std and chrono timestamp

The original test always success even the current_time_millis returns in
seconds resolution

* chore: Store current time in gmt_created/gmt_modified
2022-08-17 12:11:08 +08:00
Lei, Huang
a1c4921933 feat: impl create table sql execution (#168)
* catalog manager allocates table id

* rebase develop

* add some tests

* add some more test

* fix some cr comments

* insert into system catalog

* use slice pattern to simplify code

* add optional dependencies

* add sql-to-request test

* successfully recover

* fix unit tests

* rebase develop

* add some tests

* fix some cr comments

* fix some cr comments

* add a lock to CatalogManager

* feat: add gmt_created and gmt_modified columns to system catalog table
2022-08-17 10:53:19 +08:00
fys
34133fae5a feat: impl select (grpc) (#138)
* SelectExpr: change to oneof expr

* Convert between Vec<u8> and SelectResult

* Chore: use encode_to_vec and decode, instead of encode_length_delimited_to_vec and decode_length_delimited

* Chore: move bitset into separate file

* Grpc select impl
2022-08-15 18:31:47 +08:00
dennis zhuang
60dc77d1d9 feat: adds datanode config file supporting, close #156 (#167)
* feat: adds datanode config file supporting, close #156

* doc: update readme

* fix: address CR problems

* fix: remove unused log
2022-08-15 16:17:56 +08:00
Lei, Huang
b695881c6a fix: logstore read supports namespace isolation (#163)
* logstore read supports namespace isolation

* add namespace isolation test

* update

* revert unexpected changes

* Update log.rs

remove unnecessary info log

* reformat code
2022-08-15 11:43:48 +08:00
Lei, Huang
28b7a7cf35 fix develop (#166) 2022-08-12 14:21:52 +08:00
LFC
4098c57446 feat: MySQL protocol server (#158)
* MySQL protocol server

* fix: Rustfmt check

* fix: resolve PR comments

Co-authored-by: luofucong <luofucong@greptime.com>
2022-08-12 11:41:45 +08:00
dennis zhuang
41ffbe82f8 feat: impl table manifest (#157)
* feat: impl TableManifest and refactor table engine, object store etc.

* feat: persist table metadata when creating it

* fix: remove unused file src/storage/src/manifest/impl.rs

* feat: impl recover table info from manifest

* test: add open table test and table manifest test

* fix: resolve CR problems

* fix: compile error and remove region id

* doc: describe parent_dir

* fix: address CR problems

* fix: typo

* Revert "fix: compile error and remove region id"

This reverts commit c14c250f8a.

* fix: compile error and generate region id by table_id and region number
2022-08-12 10:47:33 +08:00
Jiachun Feng
ea40616cfe chore: avoid clone column names (#161) 2022-08-12 10:09:23 +08:00
Lei, Huang
1dd780d857 feat: implement catalog manager (#129)
Implement catalog manager that provides a vision of all existing tables while instance start. Current implementation is based on local table engine, all catalog info is stored in an system catalog table.
2022-08-11 15:43:59 +08:00
Lei, Huang
2c7e83c792 ci: ignore error.rs in coverage (#162) 2022-08-11 15:01:45 +08:00
Jiachun Feng
ffd637e5f5 chore: replace bitvec impl (#159)
* chore: replace bitvec impl

* chore: lazy init bitvec
2022-08-11 10:00:20 +08:00
Lei, Huang
d141fbc674 fix: log store write and read (#97)
* add pwrite

* write

* fix write

* error handling in write thread

* wrap some LogFile field to state field

* remove some unwraps

* reStructure some code

* implement file chunk

* composite chunk decode

* add test for chunk stream

* fix buffer test

* remove some useless code

* add test for read_at and file_chunk_stream

* use bounded channel to implement back pressure

* reimplement entry read and decoding

* add some doc

* clean some code

* use Sender::blocking_send to replace manually spawn

* support synchronous file chunk stream

* remove useless clone

* remove set_offset from Entry trait

* cr: fix some comments

* fix: add peek methods for Buffer

* add test for read at the middle of file

* fix some minor issues on comments

* rebase on to develop

* add peek_to_slice and read_to_slice

* initialize file chunk on heap

* fix some comments in CR

* respect entry id set outside LogStore

* fix unit test

* Update src/log-store/src/fs/file.rs

Co-authored-by: evenyag <realevenyag@gmail.com>

* fix some cr comments

Co-authored-by: evenyag <realevenyag@gmail.com>
2022-08-10 11:16:04 +08:00
egg
8d51ad3429 feat: write_batch proto codec (#122)
* feat: protobuf codec

* chore: minor fix

* chore: beatify the macro code

* chore: minor fix

* chore: by cr

* chore: by cr and impl wal with proto

* bugfix: invalid num_rows for multi put_data in mutations

Co-authored-by: jiachun <jiachun_fjc@163.com>
2022-08-09 19:57:51 +08:00
evenyag
567510fa3e ci: Add pr title checker (#155) 2022-08-08 18:27:02 +08:00
Lei, Huang
80372720bb refactor: open_region return None if region does not exist (#145)
* refactor: open_region return None if region does not exist

* fix some unit tests

* fix some CR comments
2022-08-08 16:53:52 +08:00
evenyag
f98d406580 refactor(storage): Add region id and name to metadata (#140)
* refactor(storage): Add region id and name to metadata

Add region id and name to `RegionMetadata`, simplify input arguments of
`RegionImpl::create()` and `RegionImpl::new()` method, since id and name
are already in metadata/version.

To avoid an atomic load of `Version` each time we access the region
id/name, we still store a copy of id/name in `SharedData`.

* chore: Remove todo in OpenOptions

Create region if missing when opening the region would be hard to
implement, since sometimes we may don't known the exact region schema user
would like to have.

* refactor: Make id and name of region readonly

By making `id` and `name` fields of `SharedData` and `RegionMetadata`
private and only exposing a pub getter.
2022-08-08 16:46:51 +08:00
dennis zhuang
e9d6546c12 feat: impl create_table for MitoEngine, #125 (#142)
* feat: impl create_table for MitoEngine, #125

* fix: typo

* fix: address CR problems

* fix: address CR problems

* fix: address CR problems

* fix: format

* refactor: minor change
2022-08-08 15:36:00 +08:00
LFC
e833167ad6 feat: extract MemTable to ease testing (#133)
* feat: memtable backed by DataFusion to ease testing

* move test utility codes out of src folder

* Implement our own MemTable because DataFusion's MemTable does not support limit; and replace the original testing numbers table.

* fix: address PR comments

* fix: "testutil" -> "test-util"

* roll back "NumbersTable"

Co-authored-by: luofucong <luofucong@greptime.com>
2022-08-05 13:58:05 +08:00
Ning Sun
97be052b33 feat: update tonic/prost and simplify build requirements (#130)
* feat: update tonic/prost and simplify build requirements

* doc: update readme for protoc installtion
2022-08-04 23:11:39 +08:00
evenyag
fb4495eb46 feat: Adds TableEngine::open_table() (#132)
* feat: Add `open_table()` method to `TableEngine`

* feat: Implements MitoEngine::open_table()

For simplicity, this implementation just use the table name as region
name, and using that name to open a region for that table. It also
introduce a mutex to avoid opening the same table simultaneously.

* refactor: Shorten generic param name

Use `S` instead of `Store` for `MitoEngine`.

* test: Mock storage engine for table engine test

Add a `MockEngine` to mock the storage engine, so that testing the mito
table engine can sometimes use the mocked storage.

* test: Add open table test

Also remove `storage::gen_region_name` method, and always use table name
as default region name, so the table engine can open the table created
by `create_table()`.

* chore: Add open table log
2022-08-04 17:35:17 +08:00
evenyag
56fae412d2 feat: Implements replay (#135)
* feat: Implements RegionWriter::replay()

Refactors `preprocess_write()`, wraps time ranges calculation and
memtable creation to `prepare_memtables()` so these logic can be reused
by `WriterInner::replay()`. Then implements `WriterInner::replay()`
which reads write batch from wal and inserts it into memtables.

* feat: Use sequence in request as committed sequence

Also checks that sequence should increase monotonically and returns
error if found sequence decreases

* chore: Remove OpenOptions param from RegionWriter::replay

* test: Add region reopen tests

refactor(storage): Rename read_write test mod to basic

refactor(storage): Move common region test logic to TesterBase

Let read/write Tester and flush Tester share the same TesterBase struct,
which implements common operations like put/full_scan.

* feat: Constructs RegionImpl in open()

Constructs RegionImpl after replay in `RegionImpl::open()`

* feat: Adds RegionImpl::create()

Adds `RegionImpl::create()` method to persist region metadata to
manifest, then create the RegionImpl instance, so the storage engine
just invoke `RegionImpl::create()` instead of `RegionImpl::new()` to
create the region instance, and don't need to update manifest after
creating region instance anymore. Now `RegionImpl::new()` need to takes
version instead of metadata as input.

This change is also a necessary part to pass the region open test, since
to open a region,  need to persist something to manifest first.

* feat: Pass region open test

Use LocalFileLogStore for region test since NoopLogStore won't persist
data to the file system.

Create dir in `LocalFileLogStore::open` if it is not exist, so we don't
need to create the dir before using the logstore.

To pass the test, we always recover from flushed_sequence and use
`req_sequence + 1` as last sequence.

* test: Test reopen region multiple times

* chore: Address CR comments

Add more info to replay log and add an assert to check committed
sequence after reopen.

* refactor: Add cfg(test) to Version::new()

Remove `VersionControl::new()`, and add `#[cfg(test)]` to
`Version::new()` as it is only used by tests.
2022-08-04 17:00:01 +08:00
Lei, Huang
7395920bc8 move catalog-related traits and struct to a catalog crate (#134) 2022-08-04 11:05:28 +08:00
dennis zhuang
6db6106829 feat: impl recovering version from manifest for region (#127)
* feat: impl recovering version from manifest for region

* refactor: rename try_apply_edit to replay_edit

* fix: remove println

* fix: address CR problems

* feat: remove Metadata in manifest trait and update region manifest state after recovering
2022-08-03 11:05:52 +08:00
Ning Sun
e3267673a9 refactor: use auto generated collection build function (#128)
* refactor: use auto generated collection build function

* refactor: change functions of ColumeFamilyDescriptorBuilder to be owned
2022-08-03 09:21:28 +08:00
Jiachun Feng
1a06a7be88 feat: decode WAL entry (#123)
* feat: decode wal entry

* chore: todo message
2022-08-02 17:52:00 +08:00
Ning Sun
cd42f308a8 refactor: remove constructors from trait (#121)
* refactor: remove constructors from trait

* refactor: move PutOp into its parent type

* refactor: move put constructor to write request

* refactor: change visibility of PutData constructors

call from WriteRequest instead

* refactor: consistent naming for entry constructor

* refactor: fix constructor form Namespace trait

* refactor: remove comment code

* doc: fix doc comments
2022-08-02 16:25:03 +08:00
Lei, Huang
b5fcdae01d LogStore::read takes a reference to namespace (#126) 2022-08-02 12:59:08 +08:00
Lei, Huang
868098d2b7 feat: impl Logstore::read by LogFile::create_stream (#124)
* feat: bridge LogStore::read to LogFile::create_stream

* fix some CR comments
2022-08-02 11:14:28 +08:00
Lei, Huang
96b4ed01f7 refactor: Make TableEngine object safe (#119)
* refactor: Make TableEngine object safe

* define TableEngineRef

* fix some comments

* replace table::engine::Error with table::error::Error
2022-08-01 15:37:11 +08:00
evenyag
f06968f4f5 feat: Engine::open_region code skeleton (#120)
* refactor: Move fields in SharedData to EngineInner

Since `SharedData` isn't shared now, we move all its fields to
EngineInner, and remove the `SharedData` struct, also remove the
unused config field.

* feat: Store RegionSlot in engine's region map

A `RegionSlot` has three possible state:
- Opening
- Creating
- Ready (Holds the `RegionImpl`)

Also use the `RegionSlot` as a placeholder in the region map to indicate
the region is opening/creating, so another open/create request will
fail immediately. The `SlotGuard` is used to clean the slot if we failed
to create/open the region.

* feat: Add a blank method `RegionImpl::open`

* feat: Remove MetadataId from Manifest

Now metadata id of manifest is unused, also unnecessary as we have
manifest dir to build the manifest, but constructing the manifest
still needs a passing region id as argument, which is unavailable
during opening region. So we remove the metadata id from manifest so
`region_store_config()` don't need region id as input anymore

* feat: Remove region id from logstore::Namespace and Wal

This is necessary for implementing open, since we don't have region
id this time, but we need to build Wal and its logstore namespace. Now
this is ok as id is not actually used by logstore.

* feat: Setup `open_region` code skeleton
2022-07-29 17:52:33 +08:00
Ning Sun
62cb649389 refactor: use derive_builder for boilerplate builders (#116)
* refactor: remove boilerplate builder code with derive_builder macro

* refactor: better build creation using Default::default()

* refactor: resolve api change issues in benchmark code

* refactor: address some review issues

* refactor: address clippy issues

* chore: doc and todo update

* refactor: add builder for RegionDescriptor
2022-07-29 14:31:12 +08:00
fys
45490b6293 select result proto definition (#118) 2022-07-29 11:11:23 +08:00
dennis zhuang
df577ad7f8 feat: impl create table sql parser (#115)
* feat: impl create table sql parser

* feat: checking time index columns size

* refactor: move TS_INDEX to statement

* fix: address CR problems

* refactor: remove parser_error! macro
2022-07-29 11:03:36 +08:00
evenyag
03e965954a feat: implement read framework (#108)
* feat: implement read framework

feat: chunk reader builder

refactor: rename BatchIteratorPtr to BoxedBatchIterator

feat: BatchReader to read batch from ssts

feat: Add a ConcatReader to concat sst readers

test: Add tests for concat reader

chore: Fix clippy

* feat: implement SST parquet reader (#109)

* feat: implement parquet sst reader

* chores: fix some CR comments

* gst

* fix sst writer flush issue

* feat: Implement FsAccessLayer::read_sst

* fix: remove lifetime from ChunkStream

* refactor: Store file name in FileMeta

- Store file name instead of path (`region-name/file-name`) in FileMeta.
- `AccessLayer::read()` takes file name instead of path, so the read/write api are consistent

Co-authored-by: Lei, Huang <6406592+v0y4g3r@users.noreply.github.com>
Co-authored-by: Lei, HUANG <mrsatangel@gmail.com>
2022-07-28 11:46:51 +08:00
fys
3b2716ed70 feat: impl insert via grpc (#102)
* fix: build protobuf

* feat: impl grpc insert

* Add an example of grpc insert

* fix: cargo clippy

* cr
2022-07-28 10:25:22 +08:00
Lei, HUANG
3e42334b92 chores: change readme 2022-07-27 15:14:10 +08:00
Ning Sun
f81dfc9bed feat: add fmt::Debug for RegionImpl 2022-07-27 15:04:51 +08:00
evenyag
c9db093af7 feat: Cherry picks lost commits of flush (#111)
* fix: Fix write stall blocks flush applying version

refactor: Use store config to help constructing Region

chore: Address CR comments

* feat: adds manifest protocol supporting and refactor region metadata protocol

feat: ignore sqlparser log

refactor: PREV_VERSION_KEY constant

refactor: minor change for checking readable/writable

fix: address CR problems

refactor: use binary literal

Co-authored-by: Dennis Zhuang <killme2008@gmail.com>
2022-07-26 15:52:39 +08:00
evenyag
bf5975ca3e feat: Prototype of the storage engine (#107)
* feat: memtable flush (#63)

* wip: memtable flush

* optimize schema conversion

* remove unnecessary import

* add parquet file verfication

* add backtrace to error

* chore: upgrade opendal to 0.9 and fixed some problems

* rename error

* fix: error description

Co-authored-by: Dennis Zhuang <killme2008@gmail.com>

* feat: region manifest service (#57)

* feat: adds Manifest API

* feat: impl region manifest service

* refactor: by CR comments

* fix: storage error mod test

* fix: tweak storage cargo

* fix: tweak storage cargo

* refactor: by CR comments

* refactor: rename current_version

* feat: add wal writer (#60)

* feat: add Wal

* upgrade engine for wal

* fix: unit test for wal

* feat: wal into region

* fix: unix test

* fix clippy

* chore: by cr

* chore: by cr

* chore: prevent test data polution

* chore: by cr

* minor fix

* chore: by cr

* feat: Implement flush (#65)

* feat: Flush framework

- feat: Add id to memtable
- refactor: Rename MemtableSet/MutableMemtables to MemtableVersion/MemtableSet
- feat: Freeze memtable
- feat: Trigger flush
- feat: Background job pool
- feat: flush job
- feat: Sst access layer
- feat: Custom Deserialize for StringBytes
- feat: Use RegionWriter to apply file metas
- feat: Apply version edit
- chore: Remove unused imports

refactor: Use ParquetWriter to replace FlushTask

refactor: FsAccessLayer takes object store as param

chore: Remove todo from doc comments

feat: Move wal to WriterContext

chore: Fix clippy

chore: Add backtrace to WriteWal error

* feat: adds manifest to region and refactor sst/manifest dir config (#72)

* feat: adds manifest to region and refactor sst/manifest dir with EngineConfig

* refactor: ensure path ends with '/' in ManifestLogStorage

* fix: style

* refactor: normalize storage directory path and minor changes by CR

* refactor: doesn't need slash any more

* feat: Implement apply_edit() and add timestamp index to schema (#73)

* feat: Implement VersionControl::apply_edit()

* feat: Add timestamp index to schema

* feat: Implement Schema::timestamp_column()

* feat: persist region metadata to manifest (#74)

* feat: persist metadata when creating region or sst files

* fix: revert FileMeta comment

* feat: resolve todo

* fix: clippy warning

* fix: revert files_to_remove type in RegionEdit

* feat: impl SizeBasedStrategy for flush (#76)

* feat: impl SizeBasedStrategy for flush

* doc: get_mutable_limitation

* fix: code style and comment

* feat: align timestamp (#75)

* feat: align timestamps in write batch

* fix cr comments

* fix timestamp overflow

* simplify overflow check

* fix cr comments

* fix clippy issues

* test: Fix region tests (comment out some unsupported tests) (#82)

* feat: flush job (#80)

* feat: flush job

* fix cr comments

* move file name instead of clone

* comment log file test (#84)

* feat: improve MemtableVersion (#78)

* feat: improve MemtableVersion

* feat: remove flushed immutable memtables and test MemtableVersion

* refactor: by CR comments

* refactor: clone kv in iterator

* fix: clippy warning

* refactor: Make BatchIterator supertrait of Iterator (#85)

* refactor: rename Version to ManifestVersion and move out manifest from ShareData (#83)

* feat: Insert multiple memtables by time range (#77)

* feat: memtable::Inserter supports insert multiple memtables by time range

* chore: Update timestamp comment

* test: Add tests for Inserter

* test: Fix region tests (comment out some unsupported tests)

* refactor: align_timestamp() use TimestampMillis::aligned_by_bucket()

* chore: rename aligned_by_bucket to align_by_bucket

* fix: Fix compile errors

* fix: sst and manifest dir (#86)

* Set RowKeyDescriptor::enable_version_column to false by default

* feat: Implement write stall (#90)

* feat: Implement write stall

* chore: Update comments

* feat: Support reading multiple memtables (#93)

* feat: Support reading multiple memtables

* test: uncomment tests rely on snapshot read

* feat: wal format (#70)

* feat: wal codec

* chore: minor fix

* chore: comment

* chore: by cr

* chore: write_batch_codec mod

* chore: by cr

* chore: upgrade proto

* chore: by cr

* fix failing test

* fix failing test

* feat: manifest to wal (#100)

* feat: write manifest to wal

* chore: sequence into wal

* chore: by cr

* chore: by cr

* refactor: create log store (#104)

Co-authored-by: dennis zhuang <killme2008@gmail.com>
Co-authored-by: Lei, Huang <6406592+v0y4g3r@users.noreply.github.com>
Co-authored-by: fariygirl <clickmetoday@163.com>
Co-authored-by: Jiachun Feng <jiachun_feng@proton.me>
Co-authored-by: Lei, HUANG <mrsatangel@gmail.com>

* chore: Fix clippy

Co-authored-by: Lei, Huang <6406592+v0y4g3r@users.noreply.github.com>
Co-authored-by: Dennis Zhuang <killme2008@gmail.com>
Co-authored-by: Jiachun Feng <jiachun_feng@proton.me>
Co-authored-by: fariygirl <clickmetoday@163.com>
Co-authored-by: Lei, HUANG <mrsatangel@gmail.com>
2022-07-25 15:26:00 +08:00
LFC
2b064265bf feat: UDAF made generically (#91)
* feat: UDAF implementation backed by DataFusion.

Directly Transplant DataFusion's UDAF related structs, traits and functions, like `AggregateUDF`, `Accumulator` or `create_udaf` etc.

Implement median UDAF on top of it and used in unit testing.

Refs: #61

* feat: UDAF made generically

Refs: #61

* fix: cargo fmt

* fix: use prelude

* fix: uniform the name

* fix: move maybe commonly used functions together

* fix: make comments more clear

* fix: resolve conversations in CR

* fix: store input types in AccumulatorCreator, and use ScalarVector's iterator

* feat: introducing List value and List datatype

* refactor: use ArcSwap instead of Mutext

* refactor: shorten some namings

* refactor: move median UDAF out of tests

* refactor: rename

* feat: aggregate function registry

* fix: make `Value` satisfy ordering again

* fix: clippy warnings

* doc: add "how to write aggregate function"

* fix: address PR comments

* fix: trying to get rid of unwraps

Co-authored-by: luofucong <luofucong@greptime.com>
2022-07-25 10:35:36 +08:00
Lei, Huang
c126b480fd doc: add openssl install instructions to README.md (#99)
* doc: add openssl install instructions to README.md

* remove newline
2022-07-20 14:03:58 +08:00
evenyag
18509bacfa docs: Add prerequisites part to readme (#94) 2022-07-19 19:01:08 +08:00
天空好像下雨~
267a47e9dd move interp from test to numpy (#88)
* move interp from test to numpy

* move interp from test to numpy

* move interp from test to numpy

* move interp from test to numpy

* move interp from test to numpy
2022-07-18 15:38:30 +08:00
天空好像下雨~
403b94c948 feat: add operator interp (#66)
* benchmark

* bench:add read/write for memtable

* numpy-interp

* fix cast

* implement tests

* implement tests

Co-authored-by: 张心怡 <zhangxinyi@zhangxinyideMacBook-Pro.local>
2022-07-15 10:49:44 +08:00
fys
ad020284d3 feat: define proto for InsertExpr (grpc) (#79)
* feat: implement InsertExpr

* 1.InsertExpr reverted to previous version 2.add InsertBatch message

* add two SemanticTypes: TAG, TIMESTAMP

* chore: format proto files

* chore: add some comments about "Column"

* fix: rename "semanticType" -> "semantic_type"

* fix: unique number in InsertBatch

* fix: type of f64_values

* chore: move insertbatch and column to insert.proto

* chore: rename "ExprHeader" to "Header"

* fix: ExprHeader not found in this scope
2022-07-14 16:36:56 +08:00
天空好像下雨~
8852c9bc32 bench: read/write for memtable (#52)
* benchmark

* fix style

Co-authored-by: 张心怡 <zhangxinyi@zhangxinyideMacBook-Pro.local>
2022-07-11 17:44:22 +08:00
Lei, Huang
65890e09f6 doc: contributing.md (#67) 2022-07-07 15:54:34 +08:00
Jiachun Feng
6cf1da35ee feat: add grpc impl (#50)
* feat: add grpc impl

* feat: add grpc server

* some ut

* verson format: a.b

* code style

* admin request/response

* by cr

* admin api

* by cr

* chore: by cr

* chore: by cr
2022-07-06 20:56:16 +08:00