github.com/rohankumardubey/aresdb@v0.0.2-0.20190517170215-e54e3ca06b9c/metastore/common/model.go (about) 1 // Copyright (c) 2017-2018 Uber Technologies, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package common 16 17 // ColumnConfig defines the schema of a column config that can be mutated by 18 // UpdateColumn API call. 19 // swagger:model columnConfig 20 type ColumnConfig struct { 21 // ColumnEvictionConfig : For column level in-memory eviction, it’s the best 22 // effort TTL for in-memory data. 23 // Column level eviction has nothing to do with data availability, but based 24 // on how much data we pre-loaded, the major impact will be there for query 25 // performance. Here we bring in two priorities configs: Preloading days and 26 // Priority. 27 // - Preloading days is defined at each column level to indicate how many 28 // recent days data we want to preload to host memory. This is best effort 29 // operation. 30 // - Priority is defined at each column level to indicate the priority of 31 // each column. When data eviction happens, we will rely on column priority 32 // to decide which column will be evicted first. 33 // High number implies high priority. 34 PreloadingDays int `json:"preloadingDays,omitempty"` 35 Priority int64 `json:"priority,omitempty"` 36 } 37 38 // Column defines the schema of a column from MetaStore. 39 // swagger:model column 40 type Column struct { 41 // Immutable, columns cannot be renamed. 42 Name string `json:"name"` 43 // Immutable, columns cannot have their types changed. 44 Type string `json:"type"` 45 // Deleted columns are kept as placeholders in Table.Columns. 46 // read only: true 47 Deleted bool `json:"deleted,omitempty"` 48 // We store the default value as string here since it's from user input. 49 // Nil means the default value is NULL. Actual default value of column data type 50 // should be stored in memstore. 51 DefaultValue *string `json:"defaultValue,omitempty"` 52 53 // Whether to compare characters case insensitively for enum columns. It only matters 54 // for ingestion client as it's the place to concert enum strings to enum values. 55 CaseInsensitive bool `json:"caseInsensitive,omitempty"` 56 57 // Whether disable enum cases auto expansion. 58 DisableAutoExpand bool `json:"disableAutoExpand,omitempty"` 59 60 // Mutable column configs. 61 Config ColumnConfig `json:"config,omitempty"` 62 63 // HLLEnabled determines whether a column is enabled for hll cardinality estimation 64 // HLLConfig is immutable 65 HLLConfig HLLConfig `json:"hllConfig,omitempty"` 66 } 67 68 // HLLConfig defines hll configuration 69 // swagger:model hllConfig 70 type HLLConfig struct { 71 IsHLLColumn bool `json:"isHLLColumn,omitempty"` 72 } 73 74 // TableConfig defines the table configurations that can be changed 75 // swagger:model tableConfig 76 type TableConfig struct { 77 // Common table configs 78 79 // Initial setting of number of buckets for primary key 80 // if equals to 0, default will be used 81 InitialPrimaryKeyNumBuckets int `json:"initPrimaryKeyNumBuckets,omitempty"` 82 83 // Size of each live batch, should be sufficiently large. 84 BatchSize int `json:"batchSize,omitempty" validate:"min=1"` 85 86 // Specifies how often to create a new redo log file. 87 RedoLogRotationInterval int `json:"redoLogRotationInterval,omitempty" validate:"min=1"` 88 89 // Specifies the size limit of a single redo log file. 90 MaxRedoLogFileSize int `json:"maxRedoLogFileSize,omitempty" validate:"min=1"` 91 92 // Fact table specific configs 93 94 // Number of minutes after event time before a record can be archived. 95 ArchivingDelayMinutes uint32 `json:"archivingDelayMinutes,omitempty" validate:"min=1"` 96 // Specifies how often archiving runs. 97 ArchivingIntervalMinutes uint32 `json:"archivingIntervalMinutes,omitempty" validate:"min=1"` 98 99 // Specifies how often backfill runs. 100 BackfillIntervalMinutes uint32 `json:"backfillIntervalMinutes,omitempty" validate:"min=1"` 101 102 // Upper limit of current backfill buffer size + backfilling buffer size. 103 BackfillMaxBufferSize int64 `json:"backfillMaxBufferSize,omitempty" validate:"min=1"` 104 105 // Backfill buffer size in bytes that will trigger a backfill job. 106 BackfillThresholdInBytes int64 `json:"backfillThresholdInBytes,omitempty" validate:"min=1"` 107 108 // Size of each live batch used by backfill job. 109 BackfillStoreBatchSize int `json:"backfillStoreBatchSize,omitempty" validate:"min=1"` 110 111 // Records with timestamp older than now - RecordRetentionInDays will be skipped 112 // during ingestion and backfill. 0 means unlimited days. 113 RecordRetentionInDays int `json:"recordRetentionInDays,omitempty" validate:"min=1"` 114 115 // Dimension table specific configs 116 117 // Number of mutations to accumulate before creating a new snapshot. 118 SnapshotThreshold int `json:"snapshotThreshold,omitempty" validate:"min=1"` 119 120 // Specifies how often snapshot runs. 121 SnapshotIntervalMinutes int `json:"snapshotIntervalMinutes,omitempty" validate:"min=1"` 122 123 AllowMissingEventTime bool `json:"allowMissingEventTime,omitempty"` 124 } 125 126 // Table defines the schema and configurations of a table from MetaStore. 127 // swagger:model table 128 type Table struct { 129 // Name of the table, immutable. 130 Name string `json:"name"` 131 // Index to Columns also serves as column IDs. 132 Columns []Column `json:"columns"` 133 // IDs of primary key columns. This field is immutable. 134 PrimaryKeyColumns []int `json:"primaryKeyColumns"` 135 // Whether this is a fact table. 136 IsFactTable bool `json:"isFactTable"` 137 138 // table configurations 139 Config TableConfig `json:"config"` 140 141 // Fact table only. 142 // IDs of columns to sort based upon. 143 ArchivingSortColumns []int `json:"archivingSortColumns,omitempty"` 144 145 // Incarnation gets incremented every time an table name is reused 146 // only used for controller managed schema in cluster setting 147 Incarnation int `json:"incarnation"` 148 // Version gets incremented every time when schema is updated 149 // only used for controller managed schema in cluster setting 150 Version int `json:"version"` 151 } 152 153 // IsEnumColumn checks whether a column is enum column 154 func (c *Column) IsEnumColumn() bool { 155 return c.Type == BigEnum || c.Type == SmallEnum 156 } 157 158 // IsOverwriteOnlyDataType checks whether a column is overwrite only 159 func (c *Column) IsOverwriteOnlyDataType() bool { 160 switch c.Type { 161 case Uint8, Int8, Uint16, Int16, Uint32, Int32, Float32, Int64: 162 return false 163 default: 164 return true 165 } 166 } 167 168 // ShardOwnership defines an instruction on whether the receiving instance 169 // should start to own or disown the specified table shard. 170 type ShardOwnership struct { 171 TableName string 172 Shard int 173 ShouldOwn bool 174 }