run a topological sort and rebuild indexes on read-from-stream