user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 18/20] xapcmd: favor 'shard' over 'part' in local variables
  2019-06-15  8:46  7% [PATCH 00/20] v2: use consistent terminology Eric Wong
@ 2019-06-15  8:47  5% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2019-06-15  8:47 UTC (permalink / raw)
  To: meta

Yet another step to keeping our naming consistent with Xapian
terminology.
---
 lib/PublicInbox/Xapcmd.pm | 70 +++++++++++++++++++--------------------
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm
index 5e4ac87..819d782 100644
--- a/lib/PublicInbox/Xapcmd.pm
+++ b/lib/PublicInbox/Xapcmd.pm
@@ -17,13 +17,13 @@ our @COMPACT_OPT = qw(jobs|j=i quiet|q blocksize|b=s no-full|n fuller|F);
 
 sub commit_changes ($$$) {
 	my ($ibx, $tmp, $opt) = @_;
-	my $new_parts = $opt->{reshard};
+	my $reshard = $opt->{reshard};
 	my $reindex = $opt->{reindex};
 	my $im = $ibx->importer(0);
 	$im->lock_acquire if !$opt->{-coarse_lock};
 
 	$SIG{INT} or die 'BUG: $SIG{INT} not handled';
-	my @old_part;
+	my @old_shard;
 
 	while (my ($old, $new) = each %$tmp) {
 		my @st = stat($old);
@@ -41,7 +41,7 @@ sub commit_changes ($$$) {
 		}
 
 		if (!defined($new)) { # culled shard
-			push @old_part, $old;
+			push @old_shard, $old;
 			next;
 		}
 
@@ -58,7 +58,7 @@ sub commit_changes ($$$) {
 				die "failed to remove $prev: $!\n";
 		}
 	}
-	remove_tree(@old_part);
+	remove_tree(@old_shard);
 	$tmp->done;
 	if (!$opt->{-coarse_lock}) {
 		$opt->{-skip_lock} = 1;
@@ -66,9 +66,9 @@ sub commit_changes ($$$) {
 		if ($im->can('count_shards')) {
 			my $pr = $opt->{-progress};
 			my $n = $im->count_shards;
-			if (defined $new_parts && $n != $new_parts) {
+			if (defined $reshard && $n != $reshard) {
 				die
-"BUG: counted $n shards after resharding to $new_parts";
+"BUG: counted $n shards after resharding to $reshard";
 			}
 			my $prev = $im->{shards};
 			if ($pr && $prev != $n) {
@@ -171,17 +171,17 @@ sub run {
 	my $tmp = PublicInbox::Xtmpdirs->new;
 	my $v = $ibx->{version} ||= 1;
 	my @q;
-	my $new_parts = $opt->{reshard};
-	if (defined $new_parts && $new_parts <= 0) {
+	my $reshard = $opt->{reshard};
+	if (defined $reshard && $reshard <= 0) {
 		die "--reshard must be a positive number\n";
 	}
 
 	# we want temporary directories to be as deep as possible,
 	# so v2 shards can keep "xap$SCHEMA_VERSION" on a separate FS.
 	if ($v == 1) {
-		if (defined $new_parts) {
+		if (defined $reshard) {
 			warn
-"--reshard=$new_parts ignored for v1 $ibx->{mainrepo}\n";
+"--reshard=$reshard ignored for v1 $ibx->{mainrepo}\n";
 		}
 		my $old_parent = dirname($old);
 		same_fs_or_die($old_parent, $old);
@@ -191,28 +191,28 @@ sub run {
 		push @q, [ $old, $wip ];
 	} else {
 		opendir my $dh, $old or die "Failed to opendir $old: $!\n";
-		my @old_parts;
+		my @old_shards;
 		while (defined(my $dn = readdir($dh))) {
 			if ($dn =~ /\A[0-9]+\z/) {
-				push @old_parts, $dn;
+				push @old_shards, $dn;
 			} elsif ($dn eq '.' || $dn eq '..') {
 			} elsif ($dn =~ /\Aover\.sqlite3/) {
 			} else {
 				warn "W: skipping unknown dir: $old/$dn\n"
 			}
 		}
-		die "No Xapian parts found in $old\n" unless @old_parts;
+		die "No Xapian shards found in $old\n" unless @old_shards;
 
-		my ($src, $max_part);
-		if (!defined($new_parts) || $new_parts == scalar(@old_parts)) {
+		my ($src, $max_shard);
+		if (!defined($reshard) || $reshard == scalar(@old_shards)) {
 			# 1:1 copy
-			$max_part = scalar(@old_parts) - 1;
+			$max_shard = scalar(@old_shards) - 1;
 		} else {
 			# M:N copy
-			$max_part = $new_parts - 1;
-			$src = [ map { "$old/$_" } @old_parts ];
+			$max_shard = $reshard - 1;
+			$src = [ map { "$old/$_" } @old_shards ];
 		}
-		foreach my $dn (0..$max_part) {
+		foreach my $dn (0..$max_shard) {
 			my $tmpl = "$dn-XXXXXXXX";
 			my $wip = tempdir($tmpl, DIR => $old);
 			same_fs_or_die($old, $wip);
@@ -220,7 +220,7 @@ sub run {
 			push @q, [ $src // $cur , $wip ];
 			$tmp->{$cur} = $wip;
 		}
-		# mark old parts to be unlinked
+		# mark old shards to be unlinked
 		if ($src) {
 			$tmp->{$_} ||= undef for @$src;
 		}
@@ -305,7 +305,7 @@ sub compact ($$) {
 }
 
 sub cpdb_loop ($$$;$$) {
-	my ($src, $dst, $pr_data, $cur_part, $new_parts) = @_;
+	my ($src, $dst, $pr_data, $cur_shard, $reshard) = @_;
 	my ($pr, $fmt, $nr, $pfx);
 	if ($pr_data) {
 		$pr = $pr_data->{pr};
@@ -326,9 +326,9 @@ sub cpdb_loop ($$$;$$) {
 		eval {
 			for (; $it != $end; $it++) {
 				my $docid = $it->get_docid;
-				if (defined $new_parts) {
-					my $dst_part = $docid % $new_parts;
-					next if $dst_part != $cur_part;
+				if (defined $reshard) {
+					my $dst_shard = $docid % $reshard;
+					next if $dst_shard != $cur_shard;
 				}
 				my $doc = $src->get_document($docid);
 				$dst->replace_document($docid, $doc);
@@ -350,14 +350,14 @@ sub cpdb_loop ($$$;$$) {
 sub cpdb ($$) {
 	my ($args, $opt) = @_;
 	my ($old, $new) = @$args;
-	my ($src, $cur_part);
-	my $new_parts;
+	my ($src, $cur_shard);
+	my $reshard;
 	if (ref($old) eq 'ARRAY') {
-		($cur_part) = ($new =~ m!xap[0-9]+/([0-9]+)\b!);
-		defined $cur_part or
+		($cur_shard) = ($new =~ m!xap[0-9]+/([0-9]+)\b!);
+		defined $cur_shard or
 			die "BUG: could not extract shard # from $new";
-		$new_parts = $opt->{reshard};
-		defined $new_parts or die 'BUG: got array src w/o --reshard';
+		$reshard = $opt->{reshard};
+		defined $reshard or die 'BUG: got array src w/o --reshard';
 
 		# resharding, M:N copy means have full read access
 		foreach (@$old) {
@@ -410,8 +410,8 @@ sub cpdb ($$) {
 				# we can only estimate when resharding,
 				# because removed spam causes slight imbalance
 				my $est = '';
-				if (defined $cur_part && $new_parts > 1) {
-					$tot = int($tot/$new_parts);
+				if (defined $cur_shard && $reshard > 1) {
+					$tot = int($tot/$reshard);
 					$est = 'around ';
 				}
 				my $fmt = "$pfx % ".length($tot)."u/$tot\n";
@@ -422,15 +422,15 @@ sub cpdb ($$) {
 		};
 	} while (cpdb_retryable($src, $pfx));
 
-	if (defined $new_parts) {
+	if (defined $reshard) {
 		# we rely on document IDs matching NNTP article number,
-		# so we can't have the combined DB support rewriting
+		# so we can't have the Xapian sharding DB support rewriting
 		# document IDs.  Thus we iterate through each shard
 		# individually.
 		$src = undef;
 		foreach (@$old) {
 			my $old = Search::Xapian::Database->new($_);
-			cpdb_loop($old, $dst, $pr_data, $cur_part, $new_parts);
+			cpdb_loop($old, $dst, $pr_data, $cur_shard, $reshard);
 		}
 	} else {
 		cpdb_loop($src, $dst, $pr_data);
-- 
EW


^ permalink raw reply related	[relevance 5%]

* [PATCH 00/20] v2: use consistent terminology
@ 2019-06-15  8:46  7% Eric Wong
  2019-06-15  8:47  5% ` [PATCH 18/20] xapcmd: favor 'shard' over 'part' in local variables Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2019-06-15  8:46 UTC (permalink / raw)
  To: meta

Modern Xapian docs and code refer to multi-DB uses as "shards";
so replace the term "partition" with the term "shard".  This
way, we'll minimize the learning curve for people new to
public-inbox or Xapian.

We also still had a few places where we referred to git epochs
as "partitions", so fix those up and be consistent with the
majority of our own docs and code.

Eric Wong (20):
  doc: rename our Xapian "partitions" to "shards"
  v2writable: update comments regarding xcpdb --reshard
  admin|xapcmd: user-facing messages say "shard"
  rename reference to git epochs as "partitions"
  searchidxpart: start using "shard" in user-visible places
  v2writable: count_partitions => count_shards
  v2writable: rename {partitions} field to {shards}
  tests: change messages to use "shard" instead of partition
  inboxwritable: s/partitions/shards/ in local var
  v2: rename SearchIdxPart => SearchIdxShard
  xapcmd: update comments referencing "partitions"
  search*: rename {partition} => {shard}
  v2writable: avoid "part" in internal subs and fields
  v2writable: rename local vars to match Xapian terminology
  adminedit: "part" => "shard" for local variables
  v2writable: use "epoch" consistently when referring to git repos
  search: use "shard" for local variable
  xapcmd: favor 'shard' over 'part' in local variables
  t/xcpdb-reshard: use 'shard' term in local variables
  comments: replace "partition" with "shard"

 Documentation/public-inbox-v2-format.pod      |  10 +-
 Documentation/public-inbox-xcpdb.pod          |  11 +-
 MANIFEST                                      |   2 +-
 lib/PublicInbox/Admin.pm                      |   4 +-
 lib/PublicInbox/AdminEdit.pm                  |  12 +-
 lib/PublicInbox/Inbox.pm                      |  18 +--
 lib/PublicInbox/InboxWritable.pm              |   4 +-
 lib/PublicInbox/Search.pm                     |  14 +--
 lib/PublicInbox/SearchIdx.pm                  |  19 +--
 .../{SearchIdxPart.pm => SearchIdxShard.pm}   |  30 ++---
 lib/PublicInbox/V2Writable.pm                 | 109 +++++++++---------
 lib/PublicInbox/WWW.pm                        |  12 +-
 lib/PublicInbox/WwwListing.pm                 |   2 +-
 lib/PublicInbox/WwwStream.pm                  |  12 +-
 lib/PublicInbox/Xapcmd.pm                     |  96 +++++++--------
 t/indexlevels-mirror.t                        |   2 +-
 t/psgi_v2.t                                   |   2 +-
 t/v2writable.t                                |   4 +-
 t/view.t                                      |   2 +-
 t/xcpdb-reshard.t                             |  14 +--
 20 files changed, 188 insertions(+), 191 deletions(-)
 rename lib/PublicInbox/{SearchIdxPart.pm => SearchIdxShard.pm} (78%)

-- 
EW


^ permalink raw reply	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2019-06-15  8:46  7% [PATCH 00/20] v2: use consistent terminology Eric Wong
2019-06-15  8:47  5% ` [PATCH 18/20] xapcmd: favor 'shard' over 'part' in local variables Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).