Class: Flydata::QueryBasedSync::RecordSizeEstimator

Inherits:
Object
  • Object
show all
Defined in:
lib/flydata/query_based_sync/record_size_estimator.rb

Constant Summary collapse

BASE_DATA_SIZE =

Data size for the static part of sent record “row”:{,“type”:“update”,“respect_order”:true,

"src_pos":"10051:10051:\t10520:10052:\t{\"id\":\"1000000000\"}",
"v":2,"seq":10000000,"table_name":"","table_rev":1}
162

Instance Method Summary collapse

Constructor Details

#initialize(table_name, num_columns) ⇒ RecordSizeEstimator

Returns a new instance of RecordSizeEstimator.



11
12
13
# File 'lib/flydata/query_based_sync/record_size_estimator.rb', line 11

def initialize(table_name, num_columns)
  @base_record_size = calc_base_record_size(table_name, num_columns)
end

Instance Method Details

#calc_record_size(record) ⇒ Object

Calculate a record size for emitting



16
17
18
# File 'lib/flydata/query_based_sync/record_size_estimator.rb', line 16

def calc_record_size(record)
  @base_record_size + record.values.inject(0){|r, v| r+=v.to_s.size}
end