Skip to content

--mempool-max-rows-num option #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clickhouse-mysql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Main(Daemon):
elif self.config.is_table_migrate():
migrator = self.config.table_migrator()
migrator.chwriter = self.config.writer()
migrator.pool_max_rows_num = self.config.mempool_max_rows_num()
migrator.migrate()

else:
Expand Down
7 changes: 7 additions & 0 deletions src/cliopts.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ def config():
default=100000,
help='Max events number to pool - triggering pool flush'
)
argparser.add_argument(
'--mempool-max-rows-num',
type=int,
default=100000,
help='Max rows number to pool - triggering pool flush'
)
argparser.add_argument(
'--mempool-max-flush-interval',
type=int,
Expand Down Expand Up @@ -290,6 +296,7 @@ def config():
'pid_file': args.pid_file,
'mempool': args.mempool or args.csvpool, # csvpool assumes mempool to be enabled
'mempool-max-events-num': args.mempool_max_events_num,
'mempool-max-rows-num': args.mempool_max_rows_num,
'mempool-max-flush-interval': args.mempool_max_flush_interval,
'csvpool': args.csvpool,
},
Expand Down
6 changes: 6 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def nice_pause(self):
def pid_file(self):
return self.config['app-config']['pid_file']

def mempool_max_events_num(self):
return self.config['app-config']['mempool-max-events-num']

def mempool_max_rows_num(self):
return self.config['app-config']['mempool-max-rows-num']

def is_daemon(self):
return self.config['app-config']['daemon']

Expand Down
3 changes: 2 additions & 1 deletion src/tablemigrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class TableMigrator(TableProcessor):

cursorclass = SSDictCursor
chwriter = None
pool_max_rows_num = 100000

def migrate(self):
dbs = self.dbs_tables_lists()
Expand All @@ -27,7 +28,7 @@ def migrate_table(self, db=None, table=None, ):
self.cursor.execute("SELECT * FROM {0}".format(self.create_full_table_name(db=db, table=table)))
cnt = 0;
while True:
rows = self.cursor.fetchmany(10000)
rows = self.cursor.fetchmany(self.pool_max_rows_num)
if not rows:
break
self.chwriter.dst_schema = db
Expand Down