| 109 | } |
| 110 | |
| 111 | func (t *Tablet) SetValueAt(value interface{}, columnIndex, rowIndex int) error { |
| 112 | |
| 113 | if columnIndex < 0 || columnIndex > len(t.measurementSchemas) { |
| 114 | return fmt.Errorf("illegal argument columnIndex %d", columnIndex) |
| 115 | } |
| 116 | |
| 117 | if rowIndex < 0 || rowIndex > t.maxRowNumber { |
| 118 | return fmt.Errorf("illegal argument rowIndex %d", rowIndex) |
| 119 | } |
| 120 | |
| 121 | if value == nil { |
| 122 | // Init the bitMap to mark nil value |
| 123 | if t.bitMaps == nil { |
| 124 | t.bitMaps = make([]*BitMap, len(t.values)) |
| 125 | } |
| 126 | if t.bitMaps[columnIndex] == nil { |
| 127 | t.bitMaps[columnIndex] = NewBitMap(t.maxRowNumber) |
| 128 | } |
| 129 | // Mark the nil value position |
| 130 | t.bitMaps[columnIndex].Mark(rowIndex) |
| 131 | return nil |
| 132 | } |
| 133 | |
| 134 | switch t.measurementSchemas[columnIndex].DataType { |
| 135 | case BOOLEAN: |
| 136 | values := t.values[columnIndex].([]bool) |
| 137 | switch v := value.(type) { |
| 138 | case bool: |
| 139 | values[rowIndex] = v |
| 140 | case *bool: |
| 141 | values[rowIndex] = *v |
| 142 | default: |
| 143 | return fmt.Errorf("illegal argument value %v %v", value, reflect.TypeOf(value)) |
| 144 | } |
| 145 | case INT32: |
| 146 | values := t.values[columnIndex].([]int32) |
| 147 | switch v := value.(type) { |
| 148 | case int32: |
| 149 | values[rowIndex] = v |
| 150 | case *int32: |
| 151 | values[rowIndex] = *v |
| 152 | default: |
| 153 | return fmt.Errorf("illegal argument value %v %v", value, reflect.TypeOf(value)) |
| 154 | } |
| 155 | case INT64, TIMESTAMP: |
| 156 | values := t.values[columnIndex].([]int64) |
| 157 | switch v := value.(type) { |
| 158 | case int64: |
| 159 | values[rowIndex] = v |
| 160 | case *int64: |
| 161 | values[rowIndex] = *v |
| 162 | default: |
| 163 | return fmt.Errorf("illegal argument value %v %v", value, reflect.TypeOf(value)) |
| 164 | } |
| 165 | case FLOAT: |
| 166 | values := t.values[columnIndex].([]float32) |
| 167 | switch v := value.(type) { |
| 168 | case float32: |