parser

package
v0.0.0-...-9337120 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeUnknown = iota
	Int
	Float
	String
	DateTime
	ElasticDateTime
	IntArray
	FloatArray
	StringArray
	DateTimeArray
)

Variables

View Source
var (
	Layouts = []string{
		"2006-01-02 15:04:05",
	}
	Epoch            = time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)
	ErrParseDateTime = errors.Errorf("value doesn't contain DateTime")
)
View Source
var SysColumn = map[string]string{
	"xwl_account_id":      "账户ID",
	"xwl_distinct_id":     "访客ID",
	"xwl_reg_time":        "用户注册时间",
	"xwl_server_time":     "服务端入库时间",
	"xwl_update_time":     "用户信息最后修改时间",
	"xwl_kafka_offset":    "kafka偏移量",
	"xwl_part_date":       "事件入库时间",
	"xwl_part_event":      "事件名",
	"xwl_lib_version":     "SDK版本",
	"xwl_os":              "用户操作系统",
	"xwl_ip":              "事件生成时用户所在IP",
	"xwl_screen_width":    "用户屏幕宽度",
	"xwl_screen_height":   "用户屏幕高度",
	"xwl_device_id":       "用户设备ID",
	"xwl_network_type":    "用户网络类型",
	"xwl_device_model":    "用户机型",
	"xwl_city":            "用户所在城市",
	"xwl_province":        "用户所在省份",
	"xwl_lib":             "SDK语言",
	"xwl_scene":           "场景值",
	"xwl_manufacturer":    "设备提供商",
	"xwl_os_version":      "用户操作系统版本",
	"xwl_cpu":             "cpu",
	"xwl_client_time":     "客户端上报时间",
	"xwl_browser_version": "浏览器版本号",
	"xwl_browser":         "浏览器类型",
	"xwl_kafka_partition": "kafka分区",
}

*系统字段

View Source
var TypeRemarkMap = map[int]string{
	TypeUnknown:     "未知类型",
	Int:             "数字类型",
	Float:           "浮点数类型",
	String:          "字符串类型",
	DateTime:        "时间类型",
	ElasticDateTime: "时间类型",
	IntArray:        "数字数组类型",
	FloatArray:      "浮点数数组类型",
	StringArray:     "字符串数组类型",
	DateTimeArray:   "时间数组类型",
}

Functions

func FjDetectType

func FjDetectType(v *fastjson.Value) (typ int)

func GetValueByType

func GetValueByType(metric *FastjsonMetric, cwt *model.ColumnWithType) (val interface{})

func UnixFloat

func UnixFloat(sec float64) (t time.Time)

func WhichType

func WhichType(typ string) (dataType int, nullable bool)

Types

type FastjsonMetric

type FastjsonMetric struct {
	// contains filtered or unexported fields
}

func (*FastjsonMetric) GetArray

func (c *FastjsonMetric) GetArray(key string, typ int) (val interface{})

func (*FastjsonMetric) GetDateTime

func (c *FastjsonMetric) GetDateTime(key string, nullable bool) (val interface{})

func (*FastjsonMetric) GetElasticDateTime

func (c *FastjsonMetric) GetElasticDateTime(key string, nullable bool) (val interface{})

func (*FastjsonMetric) GetFloat

func (c *FastjsonMetric) GetFloat(key string, nullable bool) (val interface{})

func (*FastjsonMetric) GetInt

func (c *FastjsonMetric) GetInt(key string, nullable bool) (val interface{})

func (*FastjsonMetric) GetNewKeys

func (c *FastjsonMetric) GetNewKeys(knownKeys *sync.Map, newKeys *sync.Map) (foundNew bool)

func (*FastjsonMetric) GetParseObject

func (c *FastjsonMetric) GetParseObject() (v *fastjson.Value)

func (*FastjsonMetric) GetString

func (c *FastjsonMetric) GetString(key string, nullable bool) (val interface{})

func (*FastjsonMetric) ParseDateTime

func (c *FastjsonMetric) ParseDateTime(val string) (t time.Time, err error)

type FastjsonParser

type FastjsonParser struct {
	// contains filtered or unexported fields
}

func (*FastjsonParser) Parse

func (p *FastjsonParser) Parse(bs []byte) (metric *FastjsonMetric, err error)

type Parser

type Parser interface {
	Parse(bs []byte) (metric *FastjsonMetric, err error)
}

Parse is the Parser interface

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool may be used for pooling Parsers for similarly typed JSONs.

func NewParserPool

func NewParserPool(name string) (pp *Pool, err error)

NewParserPool creates a parser pool

func (*Pool) Get

func (pp *Pool) Get() Parser

Get returns a Parser from pp.

The Parser must be Put to pp after use.

func (*Pool) Put

func (pp *Pool) Put(p Parser)

Put returns p to pp.

p and objects recursively returned from p cannot be used after p is put into pp.

type TypeInfo

type TypeInfo struct {
	Type     int
	Nullable bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL