write operation refactoring for generate_indexes

RUBY-676