-
Notifications
You must be signed in to change notification settings - Fork 552
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 557a6f5
Showing
21 changed files
with
798 additions
and
722 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.
83 changes: 83 additions & 0 deletions
83
sql/src/main/java/io/crate/executor/transport/distributed/BroadcastingPageBuilder.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,83 @@ | ||
/* | ||
* 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; | ||
import java.util.ArrayList; | ||
|
||
/** | ||
* 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 BroadcastingPageBuilder implements PageBuilder { | ||
|
||
private final int numBuckets; | ||
private final StreamBucket.Builder bucketBuilder; | ||
private final ArrayList<Bucket> builtBuckets; | ||
private volatile int size = 0; | ||
|
||
public BroadcastingPageBuilder(Streamer<?>[] streamers, int numBuckets) { | ||
this.numBuckets = numBuckets; | ||
this.bucketBuilder = new StreamBucket.Builder(streamers); | ||
this.builtBuckets = new ArrayList<>(numBuckets); | ||
} | ||
|
||
@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 Iterable<Bucket> buildBuckets() { | ||
final Bucket bucket; | ||
try { | ||
bucket = bucketBuilder.build(); | ||
bucketBuilder.reset(); | ||
} catch (IOException e) { | ||
throw Throwables.propagate(e); | ||
} | ||
builtBuckets.clear(); | ||
for (int i = 0; i < numBuckets; i++) { | ||
builtBuckets.add(bucket); | ||
} | ||
size = 0; | ||
return builtBuckets; | ||
} | ||
} |
Oops, something went wrong.