// Copyright 2021 Molecula Corp. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package ingest import ( "fmt" "testing" "time" "github.com/molecula/featurebase/v2/shardwidth" ) func unusableSampleTranslator(keys ...string) (map[string]uint64, error) { out := make(map[string]uint64, len(keys)) for _, key := range keys { out[key] = uint64(len(out)) * 13 } return out, nil } func TestSimpleCodec(t *testing.T) { c, _ := NewJSONCodec(nil) _ = c.AddSetField("set", nil) _ = c.AddSetField("setkeys", unusableSampleTranslator) _ = c.AddMutexField("mutex", nil) _ = c.AddMutexField("mutexkeys", unusableSampleTranslator) _ = c.AddTimeQuantumField("tq", nil) _ = c.AddIntField("int", nil) _ = c.AddIntField("intkeys", unusableSampleTranslator) epoch, err := time.Parse("2006-01-02", "2020-01-01") if err != nil { t.Fatalf("can't parse sample epoch time: %v", err) } _ = c.AddTimestampField("ts", time.Millisecond, epoch.Unix()*1000) _ = c.AddDecimalField("dec", 2) _ = c.AddBoolField("bool") var nextShard = uint64(1<