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

feat:(storage): Finish basic storage module. #10

Merged
merged 1 commit into from
Jun 25, 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
39 changes: 39 additions & 0 deletions go/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.EXPORT_ALL_VARIABLES:

define HELP_INFO
Usage:
make <Target>

Target:
all build all executables (default)
protos compile server protobuf files
prepare prepare dependencies
clean clean artifacts
endef


.PHONY: all
all: prepare\
protos \

.PHONY: prepare
prepare:
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@latest


.PHONY: protos
protos:
$(MAKE) -C proto/mainfest
$(MAKE) -C proto/scheme

.PHONY: clean-protos
clean-protos:
$(MAKE) -C proto/mainfest clean
$(MAKE) -C proto/scheme clean


.PHONY: clean
clean: clean-protos \

18 changes: 18 additions & 0 deletions go/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
A lib to store and query scalar and vector data.


## install dependencies

```bash
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
````
## generate proto

```bash
cd proto
mkdir manifest_proto
mkdir schema_proto
protoc --go_out=./manifest_proto --go_opt=paths=source_relative manifest_proto
protoc --go_out=./schema_proto --go_opt=paths=source_relative schema.proto

```
7 changes: 7 additions & 0 deletions go/common/constant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package common

const KReadBatchSize = 1024
const KManifestTempFileName = "manifest.tmp"
const KManifestFileName = "manifest"
const KParquetDataFileSuffix = ".parquet"
const KOffsetFieldName = "__offset"
1 change: 1 addition & 0 deletions go/common/fs_util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package common
37 changes: 37 additions & 0 deletions go/common/result/result.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package result

import (
"github.com/milvus-io/milvus-storage-format/common/status"
)

type Result[T any] struct {
value *T
status *status.Status
}

func NewResult[T any](value T) *Result[T] {
return &Result[T]{value: &value}
}

func NewResultFromStatus[T any](status status.Status) *Result[T] {
return &Result[T]{status: &status}
}

func (r *Result[T]) Ok() bool {
return r.value != nil
}

func (r *Result[T]) HasValue() bool {
return r.value != nil
}

func (r *Result[T]) Value() T {
if r.value == nil {
panic("value is nil")
}
return *r.value
}

func (r *Result[T]) Status() *status.Status {
return r.status
}
73 changes: 73 additions & 0 deletions go/common/status/status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package status

type Code int32

const (
KOk Code = 0
kArrowError Code = 1
kInvalidArgument Code = 2
kInternalStateError Code = 3
)

type Status struct {
code Code
msg string
}

func NewStatus(code Code, msg string) *Status {
return &Status{
code: code,
msg: msg,
}
}

func (s *Status) Code() Code {
return s.code
}

func (s *Status) Msg() string {
return s.msg
}

func OK() Status {
return Status{
code: KOk,
}
}

func ArrowError(msg string) Status {
return Status{
code: kArrowError,
msg: msg,
}
}

func InvalidArgument(msg string) Status {
return Status{
code: kInvalidArgument,
msg: msg,
}
}

func InternalStateError(msg string) Status {
return Status{
code: kInternalStateError,
msg: msg,
}
}

func (s *Status) IsOK() bool {
return s.code == KOk
}

func (s *Status) IsArrowError() bool {
return s.code == kArrowError
}

func (s *Status) IsInvalidArgument() bool {
return s.code == kInvalidArgument
}

func (s *Status) IsInternalStateError() bool {
return s.code == kInternalStateError
}
Loading