diff --git a/cmd/roaring-migrate/ctim_darwin.go b/cmd/roaring-migrate/ctim_darwin.go new file mode 100644 index 000000000..0b50491ab --- /dev/null +++ b/cmd/roaring-migrate/ctim_darwin.go @@ -0,0 +1,27 @@ +// Copyright 2017 Pilosa 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. + +// +build darwin + +package main + +import ( + "syscall" +) + +func CTimeNano(stat *syscall.Stat_t) int64 { + NANOS := int64(1e9) // number of nanosecs in 1 sec + ts := stat.Ctimespec + return ts.Sec*NANOS + ts.Nsec +} diff --git a/cmd/roaring-migrate/ctim_linux.go b/cmd/roaring-migrate/ctim_linux.go new file mode 100644 index 000000000..b9e5d70e1 --- /dev/null +++ b/cmd/roaring-migrate/ctim_linux.go @@ -0,0 +1,25 @@ +// Copyright 2017 Pilosa 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. + +// +build linux + +package main + +import ( + "syscall" +) + +func CTimeNano(stat *syscall.Stat_t) int64 { + return stat.Ctim.Nano() +} diff --git a/cmd/roaring-migrate/main.go b/cmd/roaring-migrate/main.go index 60ff5bf7c..8b5b62d6c 100644 --- a/cmd/roaring-migrate/main.go +++ b/cmd/roaring-migrate/main.go @@ -24,7 +24,7 @@ import ( "strings" "syscall" - "github.com/molecula/featurebase/v2" + pilosa "github.com/molecula/featurebase/v2" "github.com/molecula/featurebase/v2/rbf" "github.com/molecula/featurebase/v2/rbf/cfg" "github.com/molecula/featurebase/v2/roaring" @@ -148,7 +148,7 @@ func BuildSchema(dataDir string) ([]byte, error) { l = &local{ Name: index, Fields: make([]*pilosa.FieldInfo, 0), - CreatedAt: uint64(stat.Ctim.Nano()), + CreatedAt: uint64(CTimeNano(stat)), Options: *io, } //index options @@ -158,7 +158,7 @@ func BuildSchema(dataDir string) ([]byte, error) { field := t[2] if field != "_exists" { - fi, err := pilosa.UnmarshalFieldOptions(field, stat.Ctim.Nano(), content) + fi, err := pilosa.UnmarshalFieldOptions(field, CTimeNano(stat), content) if err != nil { return err }