Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
* Fixed bug in `has(T,Traversal)` where results were not being returned.
* Fixed bug in `select(Traversal)` where side-effects were getting lost if accessed from the child traversal.
* Fixed authorization bug when using `WsAndHttpChannelizerHandler` with keep-alive enabled.
* Improved sampling distribution for global scope `sample()` operations.

[[release-3-4-7]]
=== TinkerPop 3.4.7 (Release Date: June 1, 2020)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,21 @@ public void barrierConsumer(final TraverserSet<S> traverserSet) {
int runningAmountToSample = 0;
while (runningAmountToSample < this.amountToSample) {
boolean reSample = false;
double runningWeight = 0.0d;
double runningTotalWeight = totalWeight;
for (final Traverser.Admin<S> s : traverserSet) {
long sampleBulk = sampledSet.contains(s) ? sampledSet.get(s).bulk() : 0;
if (sampleBulk < s.bulk()) {
final double currentWeight = ((ProjectedTraverser<S, Number>) s).getProjections().get(0).doubleValue();
for (int i = 0; i < (s.bulk() - sampleBulk); i++) {
runningWeight = runningWeight + currentWeight;
if (RANDOM.nextDouble() <= ((runningWeight / totalWeight))) {
if (RANDOM.nextDouble() <= ((currentWeight / runningTotalWeight))) {
final Traverser.Admin<S> split = s.split();
split.setBulk(1L);
sampledSet.add(split);
runningAmountToSample++;
totalWeight = totalWeight - currentWeight;
reSample = true;
break;
}
runningTotalWeight = runningTotalWeight - currentWeight;
}
if (reSample || (runningAmountToSample >= this.amountToSample))
break;
Expand Down Expand Up @@ -139,4 +138,4 @@ public void setTraversal(final Traversal.Admin<?, ?> parentTraversal) {
public int hashCode() {
return super.hashCode() ^ this.amountToSample ^ this.probabilityTraversal.hashCode();
}
}
}