Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if docs_in_bulk == self.bulk_size:
break
return docs_in_bulk, current_bulk
def __exit__(self, exc_type, exc_val, exc_tb):
self.file_source.close()
return False
register_param_source_for_operation(track.OperationType.Bulk, BulkIndexParamSource)
register_param_source_for_operation(track.OperationType.Search, SearchParamSource)
register_param_source_for_operation(track.OperationType.CreateIndex, CreateIndexParamSource)
register_param_source_for_operation(track.OperationType.DeleteIndex, DeleteIndexParamSource)
register_param_source_for_operation(track.OperationType.CreateIndexTemplate, CreateIndexTemplateParamSource)
register_param_source_for_operation(track.OperationType.DeleteIndexTemplate, DeleteIndexTemplateParamSource)
register_param_source_for_operation(track.OperationType.Sleep, SleepParamSource)
# Also register by name, so users can use it too
register_param_source_for_name("file-reader", BulkIndexParamSource)
current_bulk.append("{\"doc\":%s}" % document)
else:
current_bulk.append(document)
else:
current_bulk.append(document)
docs_in_bulk += 1
if docs_in_bulk == self.bulk_size:
break
return docs_in_bulk, current_bulk
def __exit__(self, exc_type, exc_val, exc_tb):
self.file_source.close()
return False
register_param_source_for_operation(track.OperationType.Bulk, BulkIndexParamSource)
register_param_source_for_operation(track.OperationType.Search, SearchParamSource)
register_param_source_for_operation(track.OperationType.CreateIndex, CreateIndexParamSource)
register_param_source_for_operation(track.OperationType.DeleteIndex, DeleteIndexParamSource)
register_param_source_for_operation(track.OperationType.CreateIndexTemplate, CreateIndexTemplateParamSource)
register_param_source_for_operation(track.OperationType.DeleteIndexTemplate, DeleteIndexTemplateParamSource)
register_param_source_for_operation(track.OperationType.Sleep, SleepParamSource)
# Also register by name, so users can use it too
register_param_source_for_name("file-reader", BulkIndexParamSource)
elif v == "stop-ml-datafeed":
return OperationType.StopMlDatafeed
elif v == "create-ml-job":
return OperationType.CreateMlJob
elif v == "delete-ml-job":
return OperationType.DeleteMlJob
elif v == "open-ml-job":
return OperationType.OpenMlJob
elif v == "close-ml-job":
return OperationType.CloseMlJob
elif v == "sleep":
return OperationType.Sleep
elif v == "delete-snapshot-repository":
return OperationType.DeleteSnapshotRepository
elif v == "create-snapshot-repository":
return OperationType.CreateSnapshotRepository
elif v == "restore-snapshot":
return OperationType.RestoreSnapshot
elif v == "wait-for-recovery":
return OperationType.WaitForRecovery
elif v == "put-settings":
return OperationType.PutSettings
else:
raise KeyError("No enum value for [%s]" % v)
elif v == "create-ml-job":
return OperationType.CreateMlJob
elif v == "delete-ml-job":
return OperationType.DeleteMlJob
elif v == "open-ml-job":
return OperationType.OpenMlJob
elif v == "close-ml-job":
return OperationType.CloseMlJob
elif v == "sleep":
return OperationType.Sleep
elif v == "delete-snapshot-repository":
return OperationType.DeleteSnapshotRepository
elif v == "create-snapshot-repository":
return OperationType.CreateSnapshotRepository
elif v == "restore-snapshot":
return OperationType.RestoreSnapshot
elif v == "wait-for-recovery":
return OperationType.WaitForRecovery
elif v == "put-settings":
return OperationType.PutSettings
else:
raise KeyError("No enum value for [%s]" % v)
def matches(self, task):
try:
return OperationType.from_hyphenated_string(task.operation.type).admin_op
except KeyError:
return False
else:
current_bulk.append(document)
docs_in_bulk += 1
if docs_in_bulk == self.bulk_size:
break
return docs_in_bulk, current_bulk
def __exit__(self, exc_type, exc_val, exc_tb):
self.file_source.close()
return False
register_param_source_for_operation(track.OperationType.Bulk, BulkIndexParamSource)
register_param_source_for_operation(track.OperationType.Search, SearchParamSource)
register_param_source_for_operation(track.OperationType.CreateIndex, CreateIndexParamSource)
register_param_source_for_operation(track.OperationType.DeleteIndex, DeleteIndexParamSource)
register_param_source_for_operation(track.OperationType.CreateIndexTemplate, CreateIndexTemplateParamSource)
register_param_source_for_operation(track.OperationType.DeleteIndexTemplate, DeleteIndexTemplateParamSource)
register_param_source_for_operation(track.OperationType.Sleep, SleepParamSource)
# Also register by name, so users can use it too
register_param_source_for_name("file-reader", BulkIndexParamSource)
elif v == "delete-ml-datafeed":
return OperationType.DeleteMlDatafeed
elif v == "start-ml-datafeed":
return OperationType.StartMlDatafeed
elif v == "stop-ml-datafeed":
return OperationType.StopMlDatafeed
elif v == "create-ml-job":
return OperationType.CreateMlJob
elif v == "delete-ml-job":
return OperationType.DeleteMlJob
elif v == "open-ml-job":
return OperationType.OpenMlJob
elif v == "close-ml-job":
return OperationType.CloseMlJob
elif v == "sleep":
return OperationType.Sleep
elif v == "delete-snapshot-repository":
return OperationType.DeleteSnapshotRepository
elif v == "create-snapshot-repository":
return OperationType.CreateSnapshotRepository
elif v == "restore-snapshot":
return OperationType.RestoreSnapshot
elif v == "wait-for-recovery":
return OperationType.WaitForRecovery
elif v == "put-settings":
return OperationType.PutSettings
else:
raise KeyError("No enum value for [%s]" % v)
elif v == "open-ml-job":
return OperationType.OpenMlJob
elif v == "close-ml-job":
return OperationType.CloseMlJob
elif v == "sleep":
return OperationType.Sleep
elif v == "delete-snapshot-repository":
return OperationType.DeleteSnapshotRepository
elif v == "create-snapshot-repository":
return OperationType.CreateSnapshotRepository
elif v == "restore-snapshot":
return OperationType.RestoreSnapshot
elif v == "wait-for-recovery":
return OperationType.WaitForRecovery
elif v == "put-settings":
return OperationType.PutSettings
else:
raise KeyError("No enum value for [%s]" % v)
elif v == "delete-index":
return OperationType.DeleteIndex
elif v == "create-index-template":
return OperationType.CreateIndexTemplate
elif v == "delete-index-template":
return OperationType.DeleteIndexTemplate
elif v == "shrink-index":
return OperationType.ShrinkIndex
elif v == "create-ml-datafeed":
return OperationType.CreateMlDatafeed
elif v == "delete-ml-datafeed":
return OperationType.DeleteMlDatafeed
elif v == "start-ml-datafeed":
return OperationType.StartMlDatafeed
elif v == "stop-ml-datafeed":
return OperationType.StopMlDatafeed
elif v == "create-ml-job":
return OperationType.CreateMlJob
elif v == "delete-ml-job":
return OperationType.DeleteMlJob
elif v == "open-ml-job":
return OperationType.OpenMlJob
elif v == "close-ml-job":
return OperationType.CloseMlJob
elif v == "sleep":
return OperationType.Sleep
elif v == "delete-snapshot-repository":
return OperationType.DeleteSnapshotRepository
elif v == "create-snapshot-repository":
return OperationType.CreateSnapshotRepository
elif v == "restore-snapshot":
return OperationType.RestoreSnapshot
current_bulk.append(document)
else:
current_bulk.append(document)
docs_in_bulk += 1
if docs_in_bulk == self.bulk_size:
break
return docs_in_bulk, current_bulk
def __exit__(self, exc_type, exc_val, exc_tb):
self.file_source.close()
return False
register_param_source_for_operation(track.OperationType.Bulk, BulkIndexParamSource)
register_param_source_for_operation(track.OperationType.Search, SearchParamSource)
register_param_source_for_operation(track.OperationType.CreateIndex, CreateIndexParamSource)
register_param_source_for_operation(track.OperationType.DeleteIndex, DeleteIndexParamSource)
register_param_source_for_operation(track.OperationType.CreateIndexTemplate, CreateIndexTemplateParamSource)
register_param_source_for_operation(track.OperationType.DeleteIndexTemplate, DeleteIndexTemplateParamSource)
register_param_source_for_operation(track.OperationType.Sleep, SleepParamSource)
# Also register by name, so users can use it too
register_param_source_for_name("file-reader", BulkIndexParamSource)