Skip to content

Commit

Permalink
Sort types within each shard before printing
Browse files Browse the repository at this point in the history
Reviewed By: chikit

Differential Revision: D61627756

fbshipit-source-id: 9bef11aafbccd4f8474525b061933985aced2da2
  • Loading branch information
Deepak Singh authored and facebook-github-bot committed Aug 29, 2024
1 parent 46c5c34 commit 51af829
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 2 additions & 1 deletion compiler/crates/schema-print/src/print_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ pub fn print_types_directives_as_shards_in_parallel(
// Base shards
let mut shards = shard_map
.into_par_iter()
.map(|(shard_key, shard)| {
.map(|(shard_key, mut shard)| {
shard.sort_by_key(|(type_name, _type)| type_name.lookup());
let printer = ShardPrinter::new(schema, shard);
// Print directives
let content = if shard_key == 0 {
Expand Down
8 changes: 2 additions & 6 deletions compiler/crates/schema-print/src/shard_printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

use std::collections::BTreeMap;

use fnv::FnvHashMap;
use fnv::FnvHashSet;
use intern::string_key::StringKey;
Expand Down Expand Up @@ -100,10 +98,8 @@ pub fn generate_shard_map(
shard_count: usize,
types_to_print: FnvHashSet<StringKey>,
) -> FnvHashMap<usize, Vec<(StringKey, Type)>> {
// Sort to ensure deterministic output
let ordered_type_map = schema.get_type_map().collect::<BTreeMap<_, _>>();
ordered_type_map
.into_iter()
schema
.get_type_map()
.map(|(type_name, type_)| {
(
calculate_hash(&type_name.lookup()) as usize % shard_count,
Expand Down

0 comments on commit 51af829

Please sign in to comment.