-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use pause / resume in DistributingDownstream
This eliminates the Queue from the DistributingDownstream. Instead the StreamBuckets are used directly to save the rows. In addition the Broadcasting/Modulo distribution has been decoupled from the request handling.
- Loading branch information
1 parent
b7e8936
commit b808ea8
Showing
20 changed files
with
843 additions
and
773 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 0 additions & 84 deletions
84
...rc/main/java/io/crate/executor/transport/distributed/BroadcastDistributingDownstream.java
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
sql/src/main/java/io/crate/executor/transport/distributed/BroadcastingBucketBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Licensed to Crate.IO GmbH ("Crate") under one or more contributor | ||
* license agreements. See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. Crate licenses | ||
* this file to you under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. You may | ||
* obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* However, if you have executed another commercial license agreement | ||
* with Crate these terms will supersede the license and you may use the | ||
* software solely pursuant to the terms of the relevant commercial agreement. | ||
*/ | ||
|
||
package io.crate.executor.transport.distributed; | ||
|
||
import com.google.common.base.Throwables; | ||
import io.crate.Streamer; | ||
import io.crate.core.collections.Bucket; | ||
import io.crate.core.collections.Row; | ||
import io.crate.executor.transport.StreamBucket; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* PageBuilder that returns N buckets where N is the number of buckets specified in the constructor. | ||
* Internally only one bucket is built - the same instance is returned N number of times. | ||
*/ | ||
public class BroadcastingBucketBuilder implements MultiBucketBuilder { | ||
|
||
private final int numBuckets; | ||
private final StreamBucket.Builder bucketBuilder; | ||
private volatile int size = 0; | ||
|
||
public BroadcastingBucketBuilder(Streamer<?>[] streamers, int numBuckets) { | ||
this.numBuckets = numBuckets; | ||
this.bucketBuilder = new StreamBucket.Builder(streamers); | ||
} | ||
|
||
@Override | ||
public void add(Row row) { | ||
try { | ||
synchronized (this) { | ||
bucketBuilder.add(row); | ||
size++; | ||
} | ||
} catch (IOException e) { | ||
throw Throwables.propagate(e); | ||
} | ||
} | ||
|
||
@Override | ||
public int size() { | ||
return size; | ||
} | ||
|
||
@Override | ||
public synchronized void build(Bucket[] buckets) { | ||
assert buckets.length == numBuckets : "length of the provided array must match numBuckets"; | ||
final Bucket bucket; | ||
try { | ||
bucket = bucketBuilder.build(); | ||
bucketBuilder.reset(); | ||
} catch (IOException e) { | ||
throw Throwables.propagate(e); | ||
} | ||
for (int i = 0; i < numBuckets; i++) { | ||
buckets[i] = bucket; | ||
} | ||
size = 0; | ||
} | ||
} |
Oops, something went wrong.