ffaad7649566c35b015694219f73aba8b6705902,src/fonduer/utils/utils_udf.py,,add_keys,#Any#Any#Any#,129
Before Change
//
// In the future, it would be nice if this could be refactored into a insert
// if not exists type of syntax.
while True:
existing_keys = set(k.name for k in session.query(key_table).all())
new_keys = set(keys).difference(existing_keys)
// Bulk insert all new feature keys
if new_keys:
try:
session.execute(
key_table.__table__.insert(), [{"name": key} for key in new_keys]
)
session.commit()
return
except Exception:
continue
else:
// All keys have been inserted already
return
After Change
// new keys, insert with on_conflict_do_nothing.
stmt = insert(key_table.__table__).values([{"name": key} for key in keys])
stmt = stmt.on_conflict_do_nothing(constraint=key_table.__table__.primary_key)
session.execute(stmt)
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances Project Name: HazyResearch/fonduer
Commit Name: ffaad7649566c35b015694219f73aba8b6705902
Time: 2018-09-01
Author: lwhsiao@stanford.edu
File Name: src/fonduer/utils/utils_udf.py
Class Name:
Method Name: add_keys
Project Name: commonsense/conceptnet5
Commit Name: 2a437760c9344a20a5785f5b4706950c911534b6
Time: 2015-04-08
Author: rob@luminoso.com
File Name: conceptnet5/formats/sql.py
Class Name: EdgeIndexReader
Method Name: random
Project Name: pantsbuild/pants
Commit Name: dbf744f0af02efeab9fefc708292786385aec030
Time: 2020-10-08
Author: greg.shuflin@toolchain.com
File Name: src/python/pants/bin/remote_pants_runner.py
Class Name: RemotePantsRunner
Method Name: _connect_and_execute