db

package
v1.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

Variables

Functions

This section is empty.

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 [][]string `json:"itemValues"` // 要写入的数据[[ItemNames...],[Values...]] or [[ItemNames...],[Values...],[TimeStamp...]]
}

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) AddCalcItemHandler

func (gdb *Gdb) AddCalcItemHandler(c *gin.Context)

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) AddGroupColumnsHandler

func (gdb *Gdb) AddGroupColumnsHandler(c *gin.Context)

func (*Gdb) AddGroups added in v1.0.1

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

add group to GDB

func (*Gdb) AddGroupsHandler

func (gdb *Gdb) AddGroupsHandler(c *gin.Context)

group handler

func (*Gdb) AddItems

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

func (*Gdb) AddItemsHandler

func (gdb *Gdb) AddItemsHandler(c *gin.Context)

item handler

func (*Gdb) BatchWrite

func (gdb *Gdb) BatchWrite(kv [][]string, withTimeStamp bool) (Rows, error)

Batch write real-time data

kv : Key-value pair to be written
withTimeStamp: Whether there is a time stamp when writing, if not, the default is the current time Unix timestamp
if it is true, then v should be like [[ItemNames...],[Values...],[UnixTimeStamp... ]]

func (*Gdb) BatchWriteHandler

func (gdb *Gdb) BatchWriteHandler(c *gin.Context)

data handler

func (*Gdb) Calc

func (gdb *Gdb) Calc() error

calc

func (*Gdb) DeleteCalculationItemHandler

func (gdb *Gdb) DeleteCalculationItemHandler(c *gin.Context)

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) DeleteGroupColumnsHandler

func (gdb *Gdb) DeleteGroupColumnsHandler(c *gin.Context)

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) DeleteGroupsHandler

func (gdb *Gdb) DeleteGroupsHandler(c *gin.Context)

func (*Gdb) DeleteHistoricalData

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

func (*Gdb) DeleteHistoricalDataHandler

func (gdb *Gdb) DeleteHistoricalDataHandler(c *gin.Context)

delete historical data, you should stop other operation when deleting historical data

func (*Gdb) DeleteItems

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

func (*Gdb) DeleteItemsHandler

func (gdb *Gdb) DeleteItemsHandler(c *gin.Context)

func (*Gdb) GetCalcItemHandler

func (gdb *Gdb) GetCalcItemHandler(c *gin.Context)

func (*Gdb) GetDbInfoHandler

func (gdb *Gdb) GetDbInfoHandler(c *gin.Context)

get db info : ram, writtenItems, timestamp, speed

func (*Gdb) GetDbSpeedHistoryHandler

func (gdb *Gdb) GetDbSpeedHistoryHandler(c *gin.Context)

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) GetGroupPropertyHandler

func (gdb *Gdb) GetGroupPropertyHandler(c *gin.Context)

func (*Gdb) GetGroups added in v1.0.1

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

get group name

func (*Gdb) GetGroupsHandler

func (gdb *Gdb) GetGroupsHandler(c *gin.Context)

func (*Gdb) GetHistoricalData

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

get historical data

func (*Gdb) GetHistoricalDataHandler

func (gdb *Gdb) GetHistoricalDataHandler(c *gin.Context)

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) GetHistoricalDataWithConditionHandler

func (gdb *Gdb) GetHistoricalDataWithConditionHandler(c *gin.Context)

func (*Gdb) GetHistoricalDataWithStamp

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

get history data according to the given time stamps

func (*Gdb) GetHistoricalDataWithStampHandler

func (gdb *Gdb) GetHistoricalDataWithStampHandler(c *gin.Context)

func (*Gdb) GetItems added in v1.0.1

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

func (*Gdb) GetItemsHandler

func (gdb *Gdb) GetItemsHandler(c *gin.Context)

func (*Gdb) GetItemsWithCount added in v1.0.1

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

func (*Gdb) GetJsCodeHandler

func (gdb *Gdb) GetJsCodeHandler(c *gin.Context)

func (*Gdb) GetLogsHandler

func (gdb *Gdb) GetLogsHandler(c *gin.Context)

func (*Gdb) GetProcessInfo

func (gdb *Gdb) GetProcessInfo() error

monitor

func (*Gdb) GetRealTimeData

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

get realTime data

func (*Gdb) GetRealTimeDataHandler

func (gdb *Gdb) GetRealTimeDataHandler(c *gin.Context)

func (*Gdb) HandleAddItemsByExcel

func (gdb *Gdb) HandleAddItemsByExcel(c *gin.Context)

func (*Gdb) HandleGetItemsWithCount

func (gdb *Gdb) HandleGetItemsWithCount(c *gin.Context)

func (*Gdb) HandleGetUerInfo

func (gdb *Gdb) HandleGetUerInfo(c *gin.Context)

func (*Gdb) HandleUploadFile

func (gdb *Gdb) HandleUploadFile(c *gin.Context)

func (*Gdb) HandleUserLogin

func (gdb *Gdb) HandleUserLogin(c *gin.Context)

page handler

func (*Gdb) StartCalculationItemHandler

func (gdb *Gdb) StartCalculationItemHandler(c *gin.Context)

func (*Gdb) StopCalculationItemHandler

func (gdb *Gdb) StopCalculationItemHandler(c *gin.Context)

func (*Gdb) UpdateCalcItemHandler

func (gdb *Gdb) UpdateCalcItemHandler(c *gin.Context)

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) UpdateGroupColumnNamesHandler

func (gdb *Gdb) UpdateGroupColumnNamesHandler(c *gin.Context)

func (*Gdb) UpdateGroupNames added in v1.0.1

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

update groupNames, the operation is atomic

func (*Gdb) UpdateGroupNamesHandler

func (gdb *Gdb) UpdateGroupNamesHandler(c *gin.Context)

func (*Gdb) UpdateItems

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

func (*Gdb) UpdateItemsHandler

func (gdb *Gdb) UpdateItemsHandler(c *gin.Context)

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      []string   `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 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