-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[euphoria-flink] #260 Flink - broadcast hash join
- Loading branch information
1 parent
88f365f
commit 94c28d4
Showing
8 changed files
with
494 additions
and
54 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
121 changes: 121 additions & 0 deletions
121
euphoria-core/src/main/java/cz/seznam/euphoria/core/executor/util/MultiValueContext.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,121 @@ | ||
/* | ||
* Copyright 2016-2018 Seznam.cz, a.s. | ||
* | ||
* Licensed 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. | ||
*/ | ||
package cz.seznam.euphoria.core.executor.util; | ||
|
||
import cz.seznam.euphoria.core.annotation.audience.Audience; | ||
import cz.seznam.euphoria.core.client.accumulators.Counter; | ||
import cz.seznam.euphoria.core.client.accumulators.Histogram; | ||
import cz.seznam.euphoria.core.client.accumulators.Timer; | ||
import cz.seznam.euphoria.core.client.dataset.windowing.Window; | ||
import cz.seznam.euphoria.core.client.io.Collector; | ||
import cz.seznam.euphoria.core.client.io.Context; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Audience(Audience.Type.EXECUTOR) | ||
public class MultiValueContext<T> implements Context, Collector<T> { | ||
|
||
private final List<T> elements = new ArrayList<>(1); | ||
@Nullable | ||
final Context wrap; | ||
|
||
public MultiValueContext() { | ||
this(null); | ||
} | ||
|
||
public MultiValueContext(Context wrap) { | ||
this.wrap = wrap; | ||
} | ||
|
||
/** | ||
* Replace the stored value with given one. | ||
* | ||
* @param elem the element to store | ||
*/ | ||
@Override | ||
public void collect(T elem) { | ||
elements.add(elem); | ||
} | ||
|
||
@Override | ||
public Context asContext() { | ||
return this; | ||
} | ||
|
||
/** | ||
* Retrieve window associated with the stored element. | ||
*/ | ||
@Override | ||
public Window<?> getWindow() throws UnsupportedOperationException { | ||
if (wrap == null) { | ||
throw new UnsupportedOperationException( | ||
"The window is unknown in this context"); | ||
} | ||
return wrap.getWindow(); | ||
} | ||
|
||
@Override | ||
public Counter getCounter(String name) { | ||
if (wrap == null) { | ||
throw new UnsupportedOperationException( | ||
"Accumulators not supported in this context"); | ||
} | ||
return wrap.getCounter(name); | ||
} | ||
|
||
@Override | ||
public Histogram getHistogram(String name) { | ||
if (wrap == null) { | ||
throw new UnsupportedOperationException( | ||
"Accumulators not supported in this context"); | ||
} | ||
return wrap.getHistogram(name); | ||
|
||
} | ||
|
||
@Override | ||
public Timer getTimer(String name) { | ||
if (wrap == null) { | ||
throw new UnsupportedOperationException( | ||
"Accumulators not supported in this context"); | ||
} | ||
return wrap.getTimer(name); | ||
|
||
} | ||
|
||
/** | ||
* Retrieve and reset the stored elements. | ||
* | ||
* @return the stored value | ||
*/ | ||
public List<T> getAndResetValue() { | ||
List<T> copiedElements = new ArrayList<>(elements); | ||
elements.clear(); | ||
return copiedElements; | ||
} | ||
|
||
/** | ||
* Retrieve value of this context. | ||
* | ||
* @return value | ||
*/ | ||
public List<T> get() { | ||
return elements; | ||
} | ||
} | ||
|
47 changes: 47 additions & 0 deletions
47
euphoria-core/src/main/java/cz/seznam/euphoria/core/executor/util/Translation.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,47 @@ | ||
package cz.seznam.euphoria.core.executor.util;/* | ||
* Copyright 2016-2018 Seznam.cz, a.s. | ||
* | ||
* Licensed 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. | ||
*/ | ||
|
||
import cz.seznam.euphoria.core.client.functional.UnaryPredicate; | ||
import cz.seznam.euphoria.core.client.operator.Operator; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
public class Translation<T, O extends Operator<?, ?>> { | ||
final T translator; | ||
final UnaryPredicate<O> accept; | ||
|
||
private Translation( | ||
T translator, UnaryPredicate<O> accept) { | ||
this.translator = Objects.requireNonNull(translator); | ||
this.accept = accept; | ||
} | ||
|
||
static <T, O extends Operator<?, ?>> void add( | ||
Map<Class, List<Translation>> idx, | ||
Class<O> type, T translator) { | ||
add(idx, type, translator, null); | ||
} | ||
|
||
static <T, O extends Operator<?, ?>> void add( | ||
Map<Class, List<Translation>> idx, | ||
Class<O> type, T translator, UnaryPredicate<O> accept) { | ||
idx.putIfAbsent(type, new ArrayList<>()); | ||
idx.get(type).add(new Translation<>(translator, accept)); | ||
} | ||
} |
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
Oops, something went wrong.