@@ -25,7 +25,6 @@ import (
25
25
"fmt"
26
26
"math"
27
27
"path"
28
- "sort"
29
28
"strconv"
30
29
"strings"
31
30
"sync"
@@ -50,7 +49,7 @@ func NewPartitionMngr(schemaConfig *config.Schema, cont v3io.Container, v3ioConf
50
49
return nil , err
51
50
}
52
51
newMngr := & PartitionManager {schemaConfig : schemaConfig , cyclic : false , container : cont , currentPartitionInterval : currentPartitionInterval , v3ioConfig : v3ioConfig }
53
- err = newMngr .updatePartitionsFromSchema (schemaConfig , nil )
52
+ err = newMngr .updatePartitionsFromSchema (schemaConfig )
54
53
if err != nil {
55
54
return nil , err
56
55
}
@@ -141,7 +140,7 @@ func (p *PartitionManager) createAndUpdatePartition(t int64) (*DBPartition, erro
141
140
}
142
141
p .currentPartitionInterval = partition .partitionInterval
143
142
144
- schemaPartition := & config.Partition {StartTime : partition .startTime , SchemaInfo : p . schemaConfig . PartitionSchemaInfo }
143
+ schemaPartition := & config.Partition {StartTime : partition .startTime }
145
144
if p .headPartition == nil || time > p .headPartition .startTime {
146
145
p .headPartition = partition
147
146
p .partitions = append (p .partitions , partition )
@@ -182,24 +181,6 @@ func (p *PartitionManager) updateSchema() error {
182
181
err = p .container .PutObjectSync (& v3io.PutObjectInput {Path : schemaFilePath , Body : data })
183
182
if err != nil {
184
183
outerError = err
185
- return
186
- }
187
- attributes := make (map [string ]interface {}, len (p .partitions ))
188
- for _ , part := range p .partitions {
189
- marshalledPartition , err := json .Marshal (part .ToMap ())
190
- if err != nil {
191
- outerError = err
192
- return
193
- }
194
- attributes [part .GetPartitionAttributeName ()] = marshalledPartition
195
- }
196
-
197
- input := & v3io.PutItemInput {Path : schemaFilePath , Attributes : attributes }
198
- _ , err := p .container .PutItemSync (input )
199
-
200
- if err != nil {
201
- outerError = errors .Wrap (err , "failed to update partitions table." )
202
- return
203
184
}
204
185
}
205
186
})
@@ -256,7 +237,7 @@ func (p *PartitionManager) ReadAndUpdateSchema() (err error) {
256
237
err = errors .Wrap (err , "Failed to create timer ReadAndUpdateSchemaTimer." )
257
238
return
258
239
}
259
- schemaInfoResp , err := p .container .GetItemSync (& v3io.GetItemInput {Path : schemaFilePath , AttributeNames : []string {"** " }})
240
+ schemaInfoResp , err := p .container .GetItemSync (& v3io.GetItemInput {Path : schemaFilePath , AttributeNames : []string {"__mtime_secs" , "__mtime_nsecs " }})
260
241
if err != nil {
261
242
err = errors .Wrapf (err , "Failed to read schema at path '%s'." , schemaFilePath )
262
243
return
@@ -280,29 +261,13 @@ func (p *PartitionManager) ReadAndUpdateSchema() (err error) {
280
261
p .schemaMtimeNanosecs = mtimeNsecs
281
262
282
263
metricReporter .WithTimer ("ReadAndUpdateSchemaTimer" , func () {
283
- err = p .updatePartitionsFromSchema (nil , schemaGetItemResponse )
284
- return
264
+ err = p .updatePartitionsFromSchema (nil )
285
265
})
286
266
}
287
267
return
288
268
}
289
269
290
- func (p * PartitionManager ) updatePartitionsFromSchema (schemaConfig * config.Schema , schemaGetItemResponse * v3io.GetItemOutput ) error {
291
- var currentSchemaVersion int
292
- if schemaConfig == nil {
293
- currentSchemaVersion = p .schemaConfig .TableSchemaInfo .Version
294
- } else {
295
- currentSchemaVersion = schemaConfig .TableSchemaInfo .Version
296
- }
297
-
298
- if currentSchemaVersion == 4 && p .v3ioConfig .LoadPartitionsFromSchemaAttr {
299
- return p .newLoadPartitions (schemaGetItemResponse )
300
- }
301
-
302
- return p .oldLoadPartitions (schemaConfig )
303
- }
304
-
305
- func (p * PartitionManager ) oldLoadPartitions (schema * config.Schema ) error {
270
+ func (p * PartitionManager ) updatePartitionsFromSchema (schema * config.Schema ) error {
306
271
if schema == nil {
307
272
schemaFilePath := p .GetSchemaFilePath ()
308
273
resp , innerError := p .container .GetObjectSync (& v3io.GetObjectInput {Path : schemaFilePath })
@@ -334,58 +299,6 @@ func (p *PartitionManager) oldLoadPartitions(schema *config.Schema) error {
334
299
return nil
335
300
}
336
301
337
- func (p * PartitionManager ) newLoadPartitions (schemaAttributesResponse * v3io.GetItemOutput ) error {
338
- if p .container == nil { // Tests use case only
339
- return nil
340
- }
341
-
342
- if schemaAttributesResponse == nil {
343
- schemaFilePath := p .GetSchemaFilePath ()
344
- schemaInfoResp , err := p .container .GetItemSync (& v3io.GetItemInput {Path : schemaFilePath , AttributeNames : []string {"*" }})
345
- if err != nil {
346
- return errors .Wrapf (err , "Failed to read schema at path '%s'." , schemaFilePath )
347
- }
348
-
349
- schemaAttributesResponse = schemaInfoResp .Output .(* v3io.GetItemOutput )
350
- }
351
-
352
- p .partitions = []* DBPartition {}
353
- for partitionStartTime , partitionAttrBlob := range schemaAttributesResponse .Item {
354
- // Only process "partition" attributes
355
- if ! strings .HasPrefix (partitionStartTime , partitionAttributePrefix ) {
356
- continue
357
- }
358
- intStartTime , err := strconv .ParseInt (partitionStartTime [1 :], 10 , 64 )
359
- if err != nil {
360
- return errors .Wrapf (err , "invalid partition name '%v'" , partitionStartTime )
361
- }
362
-
363
- partPath := path .Join (p .Path (), strconv .FormatInt (intStartTime / 1000 , 10 )) + "/"
364
-
365
- partitionAttr := make (map [string ]interface {}, 5 )
366
- err = json .Unmarshal (partitionAttrBlob .([]byte ), & partitionAttr )
367
- if err != nil {
368
- return err
369
- }
370
- newPart , err := NewDBPartitionFromMap (p , intStartTime , partPath , partitionAttr )
371
- if err != nil {
372
- return err
373
- }
374
- p .partitions = append (p .partitions , newPart )
375
- if p .headPartition == nil {
376
- p .headPartition = newPart
377
- } else if p .headPartition .startTime < newPart .startTime {
378
- p .headPartition = newPart
379
- }
380
- }
381
-
382
- sort .SliceStable (p .partitions , func (i , j int ) bool {
383
- return p .partitions [i ].startTime < p .partitions [j ].startTime
384
- })
385
-
386
- return nil
387
- }
388
-
389
302
//if inclusive is true than partial partitions (not fully in range) will be retireved as well
390
303
func (p * PartitionManager ) PartsForRange (mint , maxt int64 , inclusive bool ) []* DBPartition {
391
304
var parts []* DBPartition
0 commit comments