db

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeKey      = "currentTimeStamp"
	Ram          = "ram"
	WrittenItems = "writtenItems"
	Speed        = "speed"
)

Variables

Functions

func InitialDbServer added in v1.0.2

func InitialDbServer(ip string, port int64, dbPath, itemDbPath string, startReadConfigTime time.Time) error

Types

type AddGroupColumnInfo

type AddGroupColumnInfo struct {
	GroupName   string   `json:"groupName"`
	ColumnNames []string `json:"columnNames"`
}

type AddGroupInfo

type AddGroupInfo struct {
	GroupName   string   `json:"groupName"`
	ColumnNames []string `json:"columnNames"`
}

type AddItemInfo

type AddItemInfo struct {
	GroupName string              `json:"groupName"`
	Values    []map[string]string `json:"values"`
}

type BatchWriteString

type BatchWriteString struct {
	GroupName     string      `json:"groupName"`
	ItemValues    []ItemValue `json:"itemValues"`
	WithTimeStamp bool        `json:"withTimeStamp"`
}

type Cols

type Cols struct {
	EffectedCols int `json:"effectedCols"`
}

function return effectedCol {"effectedCols": 1}

type ColumnNameError

type ColumnNameError struct {
	ErrorInfo string
}

func (ColumnNameError) Error

func (cn ColumnNameError) Error() string

type DeadZone

type DeadZone struct {
	ItemName      string `json:"itemName"`
	DeadZoneCount int    `json:"deadZoneCount"`
}

type DeletedGroupColumnInfo

type DeletedGroupColumnInfo struct {
	GroupName   string   `json:"groupName"`
	ColumnNames []string `json:"columnNames"`
}

type DeletedGroupInfo

type DeletedGroupInfo struct {
	GroupNames []string `json:"groupNames"`
}

type DeletedHistoricalDataInfo

type DeletedHistoricalDataInfo struct {
	ItemNames  []string    `json:"itemNames"`
	TimeStamps []TimeStamp `json:"timeStamps"`
}

type ExcelError

type ExcelError struct {
	ErrorInfo string
}

func (ExcelError) Error

func (oe ExcelError) Error() string

type Gdb

type Gdb struct {
	DbPath     string // path of leveldb
	ItemDbPath string // path of item of leveldb
	// contains filtered or unexported fields
}

func NewGdb

func NewGdb(dbPath, itemDbPath string) (*Gdb, error)

func (*Gdb) AddGroupColumns added in v1.0.1

func (gdb *Gdb) AddGroupColumns(info AddGroupColumnInfo) (Cols, error)

add columns to group, all columns type are text

func (*Gdb) AddGroups added in v1.0.1

func (gdb *Gdb) AddGroups(groupInfos ...AddGroupInfo) (Rows, error)

add group to GDB

func (*Gdb) AddItems

func (gdb *Gdb) AddItems(itemInfo AddItemInfo) (Rows, error)

func (*Gdb) AddItemsByExcel added in v1.0.2

func (gdb *Gdb) AddItemsByExcel(groupName, filePath string) (Rows, error)

add items by excel

func (*Gdb) BatchWrite

func (gdb *Gdb) BatchWrite(b BatchWriteString) (Rows, error)

func (*Gdb) DeleteGroupColumns added in v1.0.1

func (gdb *Gdb) DeleteGroupColumns(info DeletedGroupColumnInfo) (Cols, error)

delete columns from group, the operation is atomic

func (*Gdb) DeleteGroups added in v1.0.1

func (gdb *Gdb) DeleteGroups(groupInfos DeletedGroupInfo) (Rows, error)

delete group from GDB notes: Since leveldb uses the default bloom filter deleting the key may affect performance. Therefore, when deleting groups and items in the current version, only the content in SQLite will be deleted, and the keys in the real-time and historical databases of leveldb will not be deleted.

func (*Gdb) DeleteHistoricalData

func (gdb *Gdb) DeleteHistoricalData(itemNames []string, timeStamps []TimeStamp) (Rows, error)

func (*Gdb) DeleteItems

func (gdb *Gdb) DeleteItems(itemInfo ItemInfo) (Rows, error)

func (*Gdb) GetGroupProperty added in v1.0.1

func (gdb *Gdb) GetGroupProperty(groupNames ...string) (map[string]GroupProperty, error)

get the column and item count of the given groupName

func (*Gdb) GetGroups added in v1.0.1

func (gdb *Gdb) GetGroups() (GroupInfo, error)

get group name

func (*Gdb) GetHistoricalData

func (gdb *Gdb) GetHistoricalData(itemNames []string, startTimeStamps []int, endTimeStamps []int, intervals []int) (cmap.ConcurrentMap, error)

get historical data

func (*Gdb) GetHistoricalDataWithCondition

func (gdb *Gdb) GetHistoricalDataWithCondition(itemNames []string, startTime []int, endTime []int, intervals []int, filterCondition string, zones ...DeadZone) (cmap.ConcurrentMap, error)

filter condition must be correct js expression,itemName should be startedWith by item. eg: item["itemName1"]>10 && item["itemName2"] > 30 .... It should be noted that the entire judgment is based on the itemName with less historical value in the condition. If the longest itemName is used as the benchmark, we cannot make an accurate judgment on the AND logic in it. Just imagine the history of Item1 It is [3,4,5], and item2 is [10,11]. If item1 is used as the benchmark, we cannot determine how much other elements of item2 should be expanded, because the condition may have complicated logic about item1 and item2 And or logic, no matter what the number is expanded, there may be a judgment error.

func (*Gdb) GetHistoricalDataWithStamp

func (gdb *Gdb) GetHistoricalDataWithStamp(itemNames []string, timeStamps ...[]int) (cmap.ConcurrentMap, error)

get history data according to the given time stamps

func (*Gdb) GetItems added in v1.0.1

func (gdb *Gdb) GetItems(itemInfo ItemInfo) ([]map[string]string, error)

func (*Gdb) GetItemsWithCount added in v1.0.1

func (gdb *Gdb) GetItemsWithCount(itemInfo ItemInfo) (Items, error)

func (*Gdb) GetRawHistoricalData added in v1.0.2

func (gdb *Gdb) GetRawHistoricalData(itemNames ...string) (cmap.ConcurrentMap, error)

get raw(that is all ) historical data, it should only be used for debugging

func (*Gdb) GetRealTimeData

func (gdb *Gdb) GetRealTimeData(itemNames ...string) (cmap.ConcurrentMap, error)

get realTime data

func (*Gdb) UpdateGroupColumnNames added in v1.0.1

func (gdb *Gdb) UpdateGroupColumnNames(info UpdatedGroupColumnInfo) (Cols, error)

update column names of group, the operation is atomic

func (*Gdb) UpdateGroupNames added in v1.0.1

func (gdb *Gdb) UpdateGroupNames(groupInfos ...UpdatedGroupInfo) (Rows, error)

update groupNames, the operation is atomic

func (*Gdb) UpdateItems

func (gdb *Gdb) UpdateItems(itemInfo ItemInfo) (Rows, error)

type GroupInfo

type GroupInfo struct {
	GroupNames []string `json:"groupNames"`
}

function return GroupName, every item of slice is the name of group {"groupNames": ["1DCS", "2DCS"]}

type GroupProperty

type GroupProperty struct {
	ItemCount       string   `json:"itemCount"`
	ItemColumnNames []string `json:"itemColumnNames"`
}

function return GroupProperty {"itemCount": 10, "itemColumnNames": ["units", "type"]}

type HistoricalDataInfo

type HistoricalDataInfo struct {
	ItemNames       []string   `json:"itemNames"`       // ItemNames
	TimeStamps      [][]int    `json:"timeStamps"`      // time stamp
	StartTimes      []int      `json:"startTimes"`      // startTime Unix TimeStamp
	EndTimes        []int      `json:"endTimes"`        // endTime Unix TimeStamp
	Intervals       []int      `json:"intervals"`       // interval
	FilterCondition string     `json:"filterCondition"` // filter condition: item["itemNames1"] > 100
	DeadZones       []DeadZone `json:"deadZones"`       // deadZone filter condition
}

type ItemInfo

type ItemInfo struct {
	GroupName string `json:"groupName"`
	Column    string `json:"column"`
	StartRow  int    `json:"startRow"`
	RowCount  int    `json:"rowCount"`
	Condition string `json:"condition"`
	Clause    string `json:"clause"`
}

type ItemValue added in v1.0.2

type ItemValue struct {
	ItemName  string `json:"itemName"`
	Value     string `json:"value"`
	TimeStamp string `json:"timeStamp"`
}

type Items

type Items struct {
	ItemCount  int64               `json:"itemCount"`
	ItemValues []map[string]string `json:"itemValues"`
}

type OperationResponseData

type OperationResponseData struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type RealTimeDataString

type RealTimeDataString struct {
	ItemNames []string `json:"itemNames"` // ItemNames
}

type ResponseData

type ResponseData struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

type Rows

type Rows struct {
	EffectedRows int `json:"effectedRows"`
}

function return effectedRow {"effectedRows": 1}

type TimeStamp

type TimeStamp struct {
	StartTime string `json:"startTime"`
	EndTime   string `json:"endTime"`
}

type UpdatedGroupColumnInfo

type UpdatedGroupColumnInfo struct {
	GroupName      string   `json:"groupName"`
	OldColumnNames []string `json:"oldColumnNames"`
	NewColumnNames []string `json:"newColumnNames"`
}

type UpdatedGroupInfo

type UpdatedGroupInfo struct {
	OldGroupName string `json:"oldGroupName"`
	NewGroupName string `json:"newGroupName"`
}

Jump to

Keyboard shortcuts

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