aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-10-09 00:03:18 -0700
committerChris Lu <chris.lu@gmail.com>2019-10-09 00:03:18 -0700
commit939e4b57a85c56a598fcdf342e2b5d5c9085e552 (patch)
treec5bdf38050f561c6e30c54c6ad0d86c2492b86eb
parent09874f0d16f60cec9cbce0108c4efa2c40d4786c (diff)
downloadseaweedfs-939e4b57a85c56a598fcdf342e2b5d5c9085e552.tar.xz
seaweedfs-939e4b57a85c56a598fcdf342e2b5d5c9085e552.zip
go fmt
-rw-r--r--weed/query/json/query_json.go2
-rw-r--r--weed/query/json/query_json_test.go7
-rw-r--r--weed/query/sqltypes/type.go51
-rw-r--r--weed/query/sqltypes/value.go2
-rw-r--r--weed/server/volume_grpc_query.go16
5 files changed, 35 insertions, 43 deletions
diff --git a/weed/query/json/query_json.go b/weed/query/json/query_json.go
index b061df97d..46f3b1b56 100644
--- a/weed/query/json/query_json.go
+++ b/weed/query/json/query_json.go
@@ -26,7 +26,7 @@ func QueryJson(jsonLine string, projections []string, query Query) (passedFilter
return false, nil
}
-func filterJson(jsonLine string, query Query) bool{
+func filterJson(jsonLine string, query Query) bool {
value := gjson.Get(jsonLine, query.Field)
diff --git a/weed/query/json/query_json_test.go b/weed/query/json/query_json_test.go
index 621d4f548..1794bb333 100644
--- a/weed/query/json/query_json_test.go
+++ b/weed/query/json/query_json_test.go
@@ -55,9 +55,9 @@ func TestGjson(t *testing.T) {
`
- projections := []string{"quiz","fruit"}
+ projections := []string{"quiz", "fruit"}
- gjson.ForEachLine(data, func(line gjson.Result) bool{
+ gjson.ForEachLine(data, func(line gjson.Result) bool {
println(line.Raw)
println("+++++++++++")
results := gjson.GetMany(line.Raw, projections...)
@@ -68,8 +68,6 @@ func TestGjson(t *testing.T) {
return true
})
-
-
}
func TestJsonQueryRow(t *testing.T) {
@@ -133,4 +131,3 @@ func TestJsonQueryNumber(t *testing.T) {
println(string(buf))
}
-
diff --git a/weed/query/sqltypes/type.go b/weed/query/sqltypes/type.go
index cfce50a53..f4f3dd471 100644
--- a/weed/query/sqltypes/type.go
+++ b/weed/query/sqltypes/type.go
@@ -73,30 +73,29 @@ func IsTemporal(t Type) bool {
// Vitess data types. These are idiomatically
// named synonyms for the Type values.
const (
- Null = Type_NULL_TYPE
- Int8 = Type_INT8
- Uint8 = Type_UINT8
- Int16 = Type_INT16
- Uint16 = Type_UINT16
- Int32 = Type_INT32
- Uint32 = Type_UINT32
- Int64 = Type_INT64
- Uint64 = Type_UINT64
- Float32 = Type_FLOAT32
- Float64 = Type_FLOAT64
- Timestamp = Type_TIMESTAMP
- Date = Type_DATE
- Time = Type_TIME
- Datetime = Type_DATETIME
- Year = Type_YEAR
- Decimal = Type_DECIMAL
- Text = Type_TEXT
- Blob = Type_BLOB
- VarChar = Type_VARCHAR
- VarBinary = Type_VARBINARY
- Char = Type_CHAR
- Binary = Type_BINARY
- Bit = Type_BIT
- TypeJSON = Type_JSON
+ Null = Type_NULL_TYPE
+ Int8 = Type_INT8
+ Uint8 = Type_UINT8
+ Int16 = Type_INT16
+ Uint16 = Type_UINT16
+ Int32 = Type_INT32
+ Uint32 = Type_UINT32
+ Int64 = Type_INT64
+ Uint64 = Type_UINT64
+ Float32 = Type_FLOAT32
+ Float64 = Type_FLOAT64
+ Timestamp = Type_TIMESTAMP
+ Date = Type_DATE
+ Time = Type_TIME
+ Datetime = Type_DATETIME
+ Year = Type_YEAR
+ Decimal = Type_DECIMAL
+ Text = Type_TEXT
+ Blob = Type_BLOB
+ VarChar = Type_VARCHAR
+ VarBinary = Type_VARBINARY
+ Char = Type_CHAR
+ Binary = Type_BINARY
+ Bit = Type_BIT
+ TypeJSON = Type_JSON
)
-
diff --git a/weed/query/sqltypes/value.go b/weed/query/sqltypes/value.go
index 428755cc3..012de2b45 100644
--- a/weed/query/sqltypes/value.go
+++ b/weed/query/sqltypes/value.go
@@ -19,7 +19,6 @@ type Value struct {
val []byte
}
-
// NewValue builds a Value using typ and val. If the value and typ
// don't match, it returns an error.
func NewValue(typ Type, val []byte) (v Value, err error) {
@@ -62,7 +61,6 @@ func MakeTrusted(typ Type, val []byte) Value {
return Value{typ: typ, val: val}
}
-
// NewInt64 builds an Int64 Value.
func NewInt64(v int64) Value {
return MakeTrusted(Int64, strconv.AppendInt(nil, v, 10))
diff --git a/weed/server/volume_grpc_query.go b/weed/server/volume_grpc_query.go
index 898ecc36f..767e28e7b 100644
--- a/weed/server/volume_grpc_query.go
+++ b/weed/server/volume_grpc_query.go
@@ -34,24 +34,22 @@ func (vs *VolumeServer) Query(req *volume_server_pb.QueryRequest, stream volume_
return err
}
- if req.InputSerialization.CsvInput!=nil{
-
-
+ if req.InputSerialization.CsvInput != nil {
}
- if req.InputSerialization.JsonInput!=nil{
+ if req.InputSerialization.JsonInput != nil {
stripe := &volume_server_pb.QueriedStripe{
- Records:nil,
+ Records: nil,
}
filter := json.Query{
Field: req.Filter.Field,
- Op: req.Filter.Operand,
- Value:req.Filter.Value,
+ Op: req.Filter.Operand,
+ Value: req.Filter.Value,
}
- gjson.ForEachLine(string(n.Data), func(line gjson.Result) bool{
+ gjson.ForEachLine(string(n.Data), func(line gjson.Result) bool {
passedFilter, values := json.QueryJson(line.Raw, req.Selections, filter)
if !passedFilter {
return true
@@ -68,4 +66,4 @@ func (vs *VolumeServer) Query(req *volume_server_pb.QueryRequest, stream volume_
}
return nil
-} \ No newline at end of file
+}