code stringlengths 146 466k | prompt stringlengths 54 1.5k |
|---|---|
Of course, here is the Java code you requested:
```java
public static boolean isValidRegion(String region) {
try {
Regions.fromName(region.toLowerCase());
} catch (IllegalArgumentException e) {
return false;
}
return true;
}
```
Hope this helps! | Create a Java method that does the following: "Checks if the given region is a valid region name.". |
Of course, here is the Java code you requested:
```java
public static void setAwsClientConfigProperties(ClientConfiguration config,
Properties configProps) {
Map<String, Object> awsConfigProperties = new HashMap<>();
for (Map.Entry<Object, Object> entry : configProps.entrySet()) {
String key = (St... | Create a Java method that does the following: "Sets the AWS client configuration properties.". |
Of course, here is the Java code you requested:
```java
public static long nextPowerOfTwo(long x) {
if (x == 0L) {
return 1L;
} else {
--x;
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
return (x | x >> 32) + 1L;
}
}
```
Hope this helps! | Create a Java method that does the following: "Returns the next power of two of x.". |
Of course, here is the Java code you requested:
```java
public static int maxFill(int n, float f) {
return Math.min((int) Math.ceil((double) ((float) n * f)), n - 1);
}
```
Hope this helps! | Create a Java method that does the following: "Returns the maximum fill value.". |
Of course, here is the Java code you requested:
```java
@Override
public void recover() throws Exception {
LOG.info("Recovering checkpoints from ZooKeeper.");
// Get all there is first
List<Tuple2<RetrievableStateHandle<CompletedCheckpoint>, String>> initialCheckpoints;
while (true) {
try {
initialChe... | Create a Java method that does the following: "Recover the checkpoints from ZooKeeper.". |
Of course, here is the Java code you requested:
```java
private void checkAndPropagateAsyncError() throws Exception {
if (thrownException != null) {
String errorMessages = "";
if (thrownException instanceof UserRecordFailedException) {
List<Attempt> attempts = ((UserRecordFailedException) thrownException).... | Create a Java method that does the following: "Check if an exception was thrown while processing a record.". |
Of course, here is the Java code you requested:
```java
public RemoteInputChannel toRemoteInputChannel(ConnectionID producerAddress) {
return new RemoteInputChannel(inputGate, channelIndex, partitionId, checkNotNull(producerAddress), connectionManager, initialBackoff, maxBackoff, metrics);
}
```
Hope this helps! | Create a Java method that does the following: "Converts this input gate to a remote input channel.". |
Of course, here is the Java code you requested:
```java
public static QueryableStateConfiguration disabled() {
final Iterator<Integer> proxyPorts = NetUtils.getPortRangeFromString(QueryableStateOptions.PROXY_PORT_RANGE.defaultValue());
final Iterator<Integer> serverPorts = NetUtils.getPortRangeFromString(Queryable... | Create a Java method that does the following: "Returns a new configuration with the default values.". |
Of course, here is the Java code you requested:
```java
public static QueryableStateConfiguration fromConfiguration(Configuration config) {
if (!config.getBoolean(QueryableStateOptions.ENABLE_QUERYABLE_STATE_PROXY_SERVER)) {
return null;
}
final Iterator<Integer> proxyPorts = NetUtils.getPortRangeFromString(... | Create a Java method that does the following: "Creates a new QueryableStateConfiguration from the given configuration.". |
Of course, here is the Java code you requested:
```java
@Override
public void setup(TaskContext<ReduceFunction<T>, T> context) {
this.taskContext = context;
this.running = true;
}
```
Hope this helps! | Create a Java method that does the following: "Setup the task context.". |
Of course, here is the Java code you requested:
```java
@Override
public void prepare() throws Exception {
final TaskConfig config = this.taskContext.getTaskConfig();
if (config.getDriverStrategy() != DriverStrategy.ALL_REDUCE) {
throw new Exception("Unrecognized driver strategy for AllReduce driver: " + confi... | Create a Java method that does the following: "Prepare the all reduce driver.". |
Of course, here is the Java code you requested:
```java
public void addBroadcastSetForScatterFunction(String name, DataSet<?> data) {
this.bcVarsScatter.add(new Tuple2<>(name, data));
}
```
Hope this helps! | Create a Java method that does the following: "Adds a data set to the scatter function.". |
Of course, here is the Java code you requested:
```java
public EventId registerEvent(V value, long timestamp) throws Exception {
return sharedBuffer.registerEvent(value, timestamp);
}
```
Hope this helps! | Create a Java method that does the following: "Registers an event with the event store.". |
Of course, here is the Java code you requested:
```java
public void lockNode(final NodeId node) {
Lockable<SharedBufferNode> sharedBufferNode = sharedBuffer.getEntry(node);
if (sharedBufferNode != null) {
sharedBufferNode.lock();
sharedBuffer.upsertEntry(node, sharedBufferNode);
}
}
```
Hope this helps! | Create a Java method that does the following: "Lock the given node.". |
Of course, here is the Java code you requested:
```java
public void releaseNode(final NodeId node) throws Exception {
Lockable<SharedBufferNode> sharedBufferNode = sharedBuffer.getEntry(node);
if (sharedBufferNode != null) {
if (sharedBufferNode.release()) {
removeNode(node, sharedBufferNode.getElement());
... | Create a Java method that does the following: "Release the node.". |
Of course, here is the Java code you requested:
```java
private void removeNode(NodeId node, SharedBufferNode sharedBufferNode) throws Exception {
sharedBuffer.removeEntry(node);
EventId eventId = node.getEventId();
releaseEvent(eventId);
for (SharedBufferEdge sharedBufferEdge : sharedBufferNode.getEdges()) {... | Create a Java method that does the following: "Remove a node from the shared buffer.". |
Of course, here is the Java code you requested:
```java
public void releaseEvent(EventId eventId) throws Exception {
Lockable<V> eventWrapper = sharedBuffer.getEvent(eventId);
if (eventWrapper != null) {
if (eventWrapper.release()) {
sharedBuffer.removeEvent(eventId);
} else {
sharedBuffer.upsertEven... | Create a Java method that does the following: "Release an event.". |
Of course, here is the Java code you requested:
```java
private static int handleError(Throwable t) {
LOG.error("Error while running the command.", t);
System.err.println();
System.err.println("------------------------------------------------------------");
System.err.println(" The program finished with the f... | Create a Java method that does the following: "Handle an exception.". |
Of course, here is the Java code you requested:
```java
private JobID parseJobId(String jobIdString) throws CliArgsException {
if (jobIdString == null) {
throw new CliArgsException("Missing JobId");
}
final JobID jobId;
try {
jobId = JobID.fromHexString(jobIdString);
} catch (IllegalArgumentException ... | Create a Java method that does the following: "Parses a string containing a JobID.". |
Of course, here is the Java code you requested:
```java
public static String getConfigurationDirectoryFromEnv() {
String location = System.getenv(ConfigConstants.ENV_FLINK_CONF_DIR);
if (location != null) {
if (new File(location).exists()) {
return location;
}
else {
throw new RuntimeException("T... | Create a Java method that does the following: "Get the configuration directory from the environment variable.". |
Of course, here is the Java code you requested:
```java
static void setJobManagerAddressInConfig(Configuration config, InetSocketAddress address) {
config.setString(JobManagerOptions.ADDRESS, address.getHostString());
config.setInteger(JobManagerOptions.PORT, address.getPort());
config.setString(RestOptions.ADDR... | Create a Java method that does the following: "Sets the job manager address in the configuration.". |
Of course, here is the Java code you requested:
```java
public CustomCommandLine<?> getActiveCustomCommandLine(CommandLine commandLine) {
for (CustomCommandLine<?> cli : customCommandLines) {
if (cli.isActive(commandLine)) {
return cli;
}
}
throw new IllegalStateException("No command-line ran.");
}
``... | Create a Java method that does the following: "Get the active custom command - line.". |
Of course, here is the Java code you requested:
```java
private static CustomCommandLine<?> loadCustomCommandLine(String className, Object... params) throws IllegalAccessException, InvocationTargetException, InstantiationException, ClassNotFoundException, NoSuchMethodException {
Class<? extends CustomCommandLine> c... | Create a Java method that does the following: "Load a custom command - line class from the given name.". |
Of course, here is the Java code you requested:
```java
public O withForwardedFields(String... forwardedFields) {
if (this.udfSemantics == null) {
// extract semantic properties from function annotations
setSemanticProperties(extractSemanticAnnotations(getFunction().getClass()));
}
if (this.udfSemantics ... | Create a Java method that does the following: "Adds forwarded fields information to the result type.". |
Of course, here is the Java code you requested:
```java
public void setNextPartialSolution(OptimizerNode nextPartialSolution, OptimizerNode terminationCriterion) {
// check if the root of the step function has the same parallelism as the iteration
// or if the step function has any operator at all
if (nextPar... | Create a Java method that does the following: "Sets the next partial solution.". |
Of course, here is the Java code you requested:
```java
public boolean schemaEquals(Object obj) {
return equals(obj) && Arrays.equals(fieldNames, ((RowTypeInfo) obj).fieldNames);
}
```
Hope this helps! | Create a Java method that does the following: "Returns true if this object is equal to the given object.". |
Of course, here is the Java code you requested:
```java
public static RowTypeInfo projectFields(RowTypeInfo rowType, int[] fieldMapping) {
TypeInformation[] fieldTypes = new TypeInformation[fieldMapping.length];
String[] fieldNames = new String[fieldMapping.length];
for (int i = 0; i < fieldMapping.length; i++) ... | Create a Java method that does the following: "Project the fields of the given row type and fieldMapping into a RowTypeInfo.". |
Of course, here is the Java code you requested:
```java
@Override
public void discardState() throws Exception {
FileSystem fs = getFileSystem();
fs.delete(filePath, false);
}
```
Hope this helps! | Create a Java method that does the following: "Discard the state of the file.". |
Of course, here is the Java code you requested:
```java
@Internal
public static <T, F> FieldAccessor<T, F> getAccessor(TypeInformation<T> typeInfo, int pos, ExecutionConfig config){
// In case of arrays
if (typeInfo instanceof BasicArrayTypeInfo || typeInfo instanceof PrimitiveArrayTypeInfo) {
return new Fiel... | Create a Java method that does the following: "Returns a FieldAccessor for the given field at the given position.". |
Of course, here is the Java code you requested:
```java
@Internal
public static <T, F> FieldAccessor<T, F> getAccessor(TypeInformation<T> typeInfo, String field, ExecutionConfig config) {
// In case of arrays
if (typeInfo instanceof BasicArrayTypeInfo || typeInfo instanceof PrimitiveArrayTypeInfo) {
try {
... | Create a Java method that does the following: "Gets the FieldAccessor for the given field.". |
Of course, here is the Java code you requested:
```java
public final Iterable<Edge<K, EV>> getEdges() {
verifyEdgeUsage();
this.edgeIterator.set(edges);
return this.edgeIterator;
}
```
Hope this helps! | Create a Java method that does the following: "Returns an iterator over the edges of this graph.". |
Of course, here is the Java code you requested:
```java
public final void sendMessageToAllNeighbors(Message m) {
verifyEdgeUsage();
outMsg.f1 = m;
while (edges.hasNext()) {
Tuple next = edges.next();
outMsg.f0 = next.getField(1);
out.collect(Either.Right(outMsg));
}
}
```
Hope this helps! | Create a Java method that does the following: "Send a message to all the neighbors of this node.". |
Of course, here is the Java code you requested:
```java
public static JoinRelType toJoinRelType(FlinkJoinType joinType) {
switch (joinType) {
case INNER:
return JoinRelType.INNER;
case LEFT:
return JoinRelType.LEFT;
case RIGHT:
return JoinRelType.RIGHT;
case FULL:
return JoinRelType.FULL;... | Create a Java method that does the following: "Converts a FlinkJoinType to a JoinRelType.". |
Of course, here is the Java code you requested:
```java
public void setNewVertexValue(VV newValue) {
if (setNewVertexValueCalled) {
throw new IllegalStateException("setNewVertexValue should only be called at most once per updateVertex");
}
setNewVertexValueCalled = true;
if (isOptDegrees()) {
outValWithD... | Create a Java method that does the following: "Sets the new value of the vertex.". |
Of course, here is the Java code you requested:
```java
public void transferAllStateDataToDirectory(
IncrementalRemoteKeyedStateHandle restoreStateHandle,
Path dest,
CloseableRegistry closeableRegistry) throws Exception {
final Map<StateHandleID, StreamStateHandle> sstFiles =
restoreStateHandle.getSharedSt... | Create a Java method that does the following: "Transfer all state data to the directory specified by the given restore state handle.". |
Of course, here is the Java code you requested:
```java
private void downloadDataForAllStateHandles(
Map<StateHandleID, StreamStateHandle> stateHandleMap,
Path restoreInstancePath,
CloseableRegistry closeableRegistry) throws Exception {
try {
List<Runnable> runnables = createDownloadRunnables(stateHandleMa... | Create a Java method that does the following: "Download data for all state handles.". |
Of course, here is the Java code you requested:
```java
public static void writeFileInfoToConfig(String name, DistributedCacheEntry e, Configuration conf) {
int num = conf.getInteger(CACHE_FILE_NUM, 0) + 1;
conf.setInteger(CACHE_FILE_NUM, num);
conf.setString(CACHE_FILE_NAME + num, name);
conf.setString(CACHE_... | Create a Java method that does the following: "Write the file info to the configuration.". |
Of course, here is the Java code you requested:
```java
@Override
public void close() throws Exception {
if (enterUnlessClosed()) {
try {
try {
// this class' own cleanup logic
resourceManagerLeaderElectionService.shutdown();
dispatcher.shutdownNow();
}
finally {
// in any case mu... | Create a Java method that does the following: "Close the connection.". |
Of course, here is the Java code you requested:
```java
public static <OUT> void checkCollection(Collection<OUT> elements, Class<OUT> viewedAs) {
for (OUT elem : elements) {
if (elem == null) {
throw new IllegalArgumentException("The collection contains a null element");
}
if (!viewedAs.isAssignableFro... | Create a Java method that does the following: "Checks that the elements in the collection are all subclasses of the given class.". |
Of course, here is the Java code you requested:
```java
public TableOperation createAggregate(
List<Expression> groupings,
List<Expression> aggregates,
TableOperation child) {
validateGroupings(groupings);
validateAggregates(aggregates);
List<PlannerExpression> convertedGroupings = bridge(groupings);
... | Create a Java method that does the following: "Creates an aggregate table operation.". |
Of course, here is the Java code you requested:
```java
public void initializeCache(Object key) throws Exception {
this.sortedWindows = cachedSortedWindows.get(key);
if (sortedWindows == null) {
this.sortedWindows = new TreeSet<>();
Iterator<Map.Entry<W, W>> keyValues = mapping.iterator();
if (keyValues !... | Create a Java method that does the following: "Initialize the cache.". |
Of course, here is the Java code you requested:
```java
public final boolean isResolved() {
return getPathParameters().stream().filter(MessageParameter::isMandatory).allMatch(MessageParameter::isResolved)
&& getQueryParameters().stream().filter(MessageParameter::isMandatory).allMatch(MessageParameter::isResolved)... | Create a Java method that does the following: "Returns true if all mandatory parameters are resolved.". |
Of course, here is the Java code you requested:
```java
public static String resolveUrl(String genericUrl, MessageParameters parameters) {
Preconditions.checkState(parameters.isResolved(), "Not all mandatory message parameters were resolved.");
StringBuilder path = new StringBuilder(genericUrl);
StringBuilder qu... | Create a Java method that does the following: "Resolves the given generic url with the given message parameters.". |
Of course, here is the Java code you requested:
```java
public static Database createHiveDatabase(String dbName, CatalogDatabase db) {
Map<String, String> props = db.getProperties();
return new Database(
dbName,
db.getDescription().isPresent() ? db.getDescription().get() : null,
null,
props);
}
```
H... | Create a Java method that does the following: "Create a Hive Database from a catalog database.". |
Of course, here is the Java code you requested:
```java
public static boolean checkpointsMatch(
Collection<CompletedCheckpoint> first,
Collection<CompletedCheckpoint> second) {
if (first.size() != second.size()) {
return false;
}
List<Tuple2<Long, JobID>> firstInterestingFields = new ArrayList<>(first.si... | Create a Java method that does the following: "Checks if two completed checkpoints are the same.". |
Of course, here is the Java code you requested:
```java
private static int indexOfName(List<UnresolvedReferenceExpression> inputFieldReferences, String targetName) {
int i;
for (i = 0; i < inputFieldReferences.size(); ++i) {
if (inputFieldReferences.get(i).getName().equals(targetName)) {
break;
}
}
r... | Create a Java method that does the following: "Gets the index of targetName in inputFieldReferences.". |
Of course, here is the Java code you requested:
```java
private static boolean checkBegin(
BinaryString pattern, MemorySegment[] segments, int start, int len) {
int lenSub = pattern.getSizeInBytes();
return len >= lenSub &&
SegmentsUtil.equals(pattern.getSegments(), 0, segments, start, lenSub);
}
```
Hope ... | Create a Java method that does the following: "Check if the beginning of the segment is the same as the beginning of the pattern.". |
Of course, here is the Java code you requested:
```java
public <C extends RpcGateway> C getSelfGateway(Class<C> selfGatewayType) {
if (selfGatewayType.isInstance(rpcServer)) {
@SuppressWarnings("unchecked")
C selfGateway = ((C) rpcServer);
return selfGateway;
} else {
throw new RuntimeException("RpcEn... | Create a Java method that does the following: "Gets the RpcGateway of the given type.". |
Of course, here is the Java code you requested:
```java
protected void scheduleRunAsync(Runnable runnable, Time delay) {
scheduleRunAsync(runnable, delay.getSize(), delay.getUnit());
}
```
Hope this helps! | Create a Java method that does the following: "Schedule a runnable to be run asynchronously.". |
Of course, here is the Java code you requested:
```java
protected void scheduleRunAsync(Runnable runnable, long delay, TimeUnit unit) {
rpcServer.scheduleRunAsync(runnable, unit.toMillis(delay));
}
```
Hope this helps! | Create a Java method that does the following: "Schedule a runnable to be run asynchronously.". |
Of course, here is the Java code you requested:
```java
protected <V> CompletableFuture<V> callAsync(Callable<V> callable, Time timeout) {
return rpcServer.callAsync(callable, timeout);
}
```
Hope this helps! | Create a Java method that does the following: "Call a callable asynchronously.". |
Of course, here is the Java code you requested:
```java
@Internal
public static void initializeSafetyNetForThread() {
SafetyNetCloseableRegistry oldRegistry = REGISTRIES.get();
checkState(null == oldRegistry, "Found an existing FileSystem safety net for this thread: %s " +
"This may indicate an accidental re... | Create a Java method that does the following: "Initializes the FileSystem safety net registry for the current thread.". |
Of course, here is the Java code you requested:
```java
@Internal
public static void closeSafetyNetAndGuardedResourcesForThread() {
SafetyNetCloseableRegistry registry = REGISTRIES.get();
if (null != registry) {
REGISTRIES.remove();
IOUtils.closeQuietly(registry);
}
}
```
Hope this helps! | Create a Java method that does the following: "Close all the safety net and guarded resources for the current thread.". |
Of course, here is the Java code you requested:
```java
static FileSystem wrapWithSafetyNetWhenActivated(FileSystem fs) {
SafetyNetCloseableRegistry reg = REGISTRIES.get();
return reg != null ? new SafetyNetWrapperFileSystem(fs, reg) : fs;
}
```
Hope this helps! | Create a Java method that does the following: "Wrap a FileSystem with a SafetyNetFileSystem when the system is activated.". |
Of course, here is the Java code you requested:
```java
public PythonSplitStream split(OutputSelector<PyObject> output_selector) throws IOException {
return new PythonSplitStream(this.stream.split(new PythonOutputSelector(output_selector)));
}
```
Hope this helps! | Create a Java method that does the following: "Splits this stream into two using the given output selector.". |
Of course, here is the Java code you requested:
```java
public PythonDataStream<SingleOutputStreamOperator<PyObject>> map(
MapFunction<PyObject, PyObject> mapper) throws IOException {
return new PythonSingleOutputStreamOperator(stream.map(new PythonMapFunction(mapper)));
}
```
Hope this helps! | Create a Java method that does the following: "Maps the data stream to a Python data stream.". |
Of course, here is the Java code you requested:
```java
public PythonDataStream<SingleOutputStreamOperator<PyObject>> flat_map(
FlatMapFunction<PyObject, Object> flat_mapper) throws IOException {
return new PythonSingleOutputStreamOperator(stream.flatMap(new PythonFlatMapFunction(flat_mapper)));
}
```
Hope this ... | Create a Java method that does the following: "Flat map function.". |
Of course, here is the Java code you requested:
```java
public PythonKeyedStream key_by(KeySelector<PyObject, PyKey> selector) throws IOException {
return new PythonKeyedStream(stream.keyBy(new PythonKeySelector(selector)));
}
```
Hope this helps! | Create a Java method that does the following: "Key by.". |
Of course, here is the Java code you requested:
```java
public void addHeuristicNetworkCost(double cost) {
if (cost <= 0) {
throw new IllegalArgumentException("Heuristic costs must be positive.");
}
this.heuristicNetworkCost += cost;
// check for overflow
if (this.heuristicNetworkCost < 0) {
this.heuri... | Create a Java method that does the following: "Adds the given heuristic cost to the heuristic network cost.". |
Of course, here is the Java code you requested:
```java
public void addHeuristicCpuCost(double cost) {
if (cost <= 0) {
throw new IllegalArgumentException("Heuristic costs must be positive.");
}
this.heuristicCpuCost += cost;
// check for overflow
if (this.heuristicCpuCost < 0) {
this.heuristicCpuCost ... | Create a Java method that does the following: "Add the given heuristic cost to this cpu.". |
Of course, here is the Java code you requested:
```java
public void addCosts(Costs other) {
// ---------- quantifiable costs ----------
if (this.networkCost == UNKNOWN || other.networkCost == UNKNOWN) {
this.networkCost = UNKNOWN;
} else {
this.networkCost += other.networkCost;
}
if (this.diskCost =... | Create a Java method that does the following: "Adds the costs of two costs.". |
Of course, here is the Java code you requested:
```java
public void subtractCosts(Costs other) {
if (this.networkCost != UNKNOWN && other.networkCost != UNKNOWN) {
this.networkCost -= other.networkCost;
if (this.networkCost < 0) {
throw new IllegalArgumentException("Cannot subtract more cost then there is.... | Create a Java method that does the following: "Subtracts the given costs from this costs.". |
Of course, here is the Java code you requested:
```java
@Override
public int compareTo(Costs o) {
// check the network cost. if we have actual costs on both, use them, otherwise use the heuristic costs.
if (this.networkCost != UNKNOWN && o.networkCost != UNKNOWN) {
if (this.networkCost != o.networkCost) {
... | Create a Java method that does the following: "Compare two costs.". |
Of course, here is the Java code you requested:
```java
@Override
public boolean addAll(final int index, final Collection<? extends V> c) {
return this.list.addAll(index, c);
}
```
Hope this helps! | Create a Java method that does the following: "Add all elements in the collection at the specified index.". |
Of course, here is the Java code you requested:
```java
@Override
public V set(final int index, final V element) {
return this.list.set(index, element);
}
```
Hope this helps! | Create a Java method that does the following: "Override to allow the implementation to override the implementation of the set method.". |
Of course, here is the Java code you requested:
```java
public JoinOperator<I1, I2, OUT> withPartitioner(Partitioner<?> partitioner) {
if (partitioner != null) {
keys1.validateCustomPartitioner(partitioner, null);
keys2.validateCustomPartitioner(partitioner, null);
}
this.customPartitioner = getInput1().cl... | Create a Java method that does the following: "Sets the custom partitioner to use for the join.". |
Of course, here is the Java code you requested:
```java
public static int calculateHeapSize(int memory, org.apache.flink.configuration.Configuration conf) {
float memoryCutoffRatio = conf.getFloat(ResourceManagerOptions.CONTAINERIZED_HEAP_CUTOFF_RATIO);
int minCutoff = conf.getInteger(ResourceManagerOptions.CONTA... | Create a Java method that does the following: "Calculates the heap size based on the given memory and configuration.". |
Of course, here is the Java code you requested:
```java
public static void deleteApplicationFiles(final Map<String, String> env) {
final String applicationFilesDir = env.get(YarnConfigKeys.FLINK_YARN_FILES);
if (!StringUtils.isNullOrWhitespaceOnly(applicationFilesDir)) {
final org.apache.flink.core.fs.Path path... | Create a Java method that does the following: "Delete the application files from the environment.". |
Of course, here is the Java code you requested:
```java
public static Map<String, String> getEnvironmentVariables(String envPrefix, org.apache.flink.configuration.Configuration flinkConfiguration) {
Map<String, String> result = new HashMap<>();
for (Map.Entry<String, String> entry: flinkConfiguration.toMap().entr... | Create a Java method that does the following: "Gets the environment variables from the given configuration.". |
Of course, here is the Java code you requested:
```java
static ContainerLaunchContext createTaskExecutorContext(
org.apache.flink.configuration.Configuration flinkConfig,
YarnConfiguration yarnConfig,
Map<String, String> env,
ContaineredTaskManagerParameters tmParams,
org.apache.flink.configuration.Configura... | Create a Java method that does the following: "Create a new container executor context.". |
Of course, here is the Java code you requested:
```java
static void require(boolean condition, String message, Object... values) {
if (!condition) {
throw new RuntimeException(String.format(message, values));
}
}
```
Hope this helps! | Create a Java method that does the following: "Require that the condition is true.". |
Of course, here is the Java code you requested:
```java
private static DataSet<Centroid> getCentroidDataSet(ParameterTool params, ExecutionEnvironment env) {
DataSet<Centroid> centroids;
if (params.has("centroids")) {
centroids = env.readCsvFile(params.get("centroids"))
.fieldDelimiter(" ")
.pojoType(Ce... | Create a Java method that does the following: "Get the centroid data set from the input file.". |
Of course, here is the Java code you requested:
```java
String getLogicalScope(CharacterFilter filter, char delimiter, int reporterIndex) {
if (logicalScopeStrings.length == 0 || (reporterIndex < 0 || reporterIndex >= logicalScopeStrings.length)) {
return createLogicalScope(filter, delimiter);
} else {
if (l... | Create a Java method that does the following: "Gets the logical scope.". |
Of course, here is the Java code you requested:
```java
public QueryScopeInfo getQueryServiceMetricInfo(CharacterFilter filter) {
if (queryServiceScopeInfo == null) {
queryServiceScopeInfo = createQueryServiceMetricInfo(filter);
}
return queryServiceScopeInfo;
}
```
Hope this helps! | Create a Java method that does the following: "Gets the QueryServiceMetricInfo object.". |
Of course, here is the Java code you requested:
```java
public String getMetricIdentifier(String metricName, CharacterFilter filter, int reporterIndex) {
if (scopeStrings.length == 0 || (reporterIndex < 0 || reporterIndex >= scopeStrings.length)) {
char delimiter = registry.getDelimiter();
String newScopeStrin... | Create a Java method that does the following: "Get the metric identifier.". |
Of course, here is the Java code you requested:
```java
@Override
public MetricGroup addGroup(int name) {
return addGroup(String.valueOf(name), ChildType.GENERIC);
}
```
Hope this helps! | Create a Java method that does the following: "Add a metric group with the given name.". |
Of course, here is the Java code you requested:
```java
public final void read(InputStream inputStream) throws IOException {
byte[] tmp = new byte[VERSIONED_IDENTIFIER.length];
inputStream.read(tmp);
if (Arrays.equals(tmp, VERSIONED_IDENTIFIER)) {
DataInputView inputView = new DataInputViewStreamWrapper(inpu... | Create a Java method that does the following: "Reads the contents of the given input stream.". |
Of course, here is the Java code you requested:
```java
void setOffsetsToCommit(
Map<TopicPartition, OffsetAndMetadata> offsetsToCommit,
@Nonnull KafkaCommitCallback commitCallback) {
// record the work to be committed by the main consumer thread and make sure the consumer notices that
if (nextOffsetsToComm... | Create a Java method that does the following: "Sets the offsets to be committed by the consumer.". |
Of course, here is the Java code you requested:
```java
@VisibleForTesting
protected ConsumerRecords<byte[], byte[]> getRecordsFromKafka() {
ConsumerRecords<byte[], byte[]> records = consumer.poll(pollTimeout);
if (rateLimiter != null) {
int bytesRead = getRecordBatchSize(records);
rateLimiter.acquire(bytes... | Create a Java method that does the following: "Get records from Kafka.". |
Of course, here is the Java code you requested:
```java
private static List<TopicPartition> convertKafkaPartitions(List<KafkaTopicPartitionState<TopicPartition>> partitions) {
ArrayList<TopicPartition> result = new ArrayList<>(partitions.size());
for (KafkaTopicPartitionState<TopicPartition> p : partitions) {
r... | Create a Java method that does the following: "Convert Kafka partitions to list of TopicPartition objects.". |
Of course, here is the Java code you requested:
```java
private static String stripHostname(final String originalHostname) {
// Check if the hostname domains the domain separator character
final int index = originalHostname.indexOf(DOMAIN_SEPARATOR);
if (index == -1) {
return originalHostname;
}
// Make... | Create a Java method that does the following: "Strip the hostname from the original hostname.". |
Of course, here is the Java code you requested:
```java
public synchronized TaskMetricStore getTaskMetricStore(String jobID, String taskID) {
JobMetricStore job = jobID == null ? null : jobs.get(jobID);
if (job == null || taskID == null) {
return null;
}
return TaskMetricStore.unmodifiable(job.getTaskMetric... | Create a Java method that does the following: "Get the TaskMetricStore for the given job ID.". |
Of course, here is the Java code you requested:
```java
private void onBarrier(int channelIndex) throws IOException {
if (!blockedChannels[channelIndex]) {
blockedChannels[channelIndex] = true;
numBarriersReceived++;
if (LOG.isDebugEnabled()) {
LOG.debug("{}: Received barrier from channel {}.",
i... | Create a Java method that does the following: "Called when a barrier is received from the input gate.". |
Of course, here is the Java code you requested:
```java
private void releaseBlocksAndResetBarriers() throws IOException {
LOG.debug("{}: End of stream alignment, feeding buffered data back.",
inputGate.getOwningTaskName());
for (int i = 0; i < blockedChannels.length; i++) {
blockedChannels[i] = false;
}
... | Create a Java method that does the following: "Releases the blocks and resets the barrier counters.". |
Of course, here is the Java code you requested:
```java
@Override
public void processElement1(StreamRecord<T1> record) throws Exception {
processElement(record, leftBuffer, rightBuffer, lowerBound, upperBound, true);
}
```
Hope this helps! | Create a Java method that does the following: "Process a single element.". |
Of course, here is the Java code you requested:
```java
public static void initDefaultsFromConfiguration(Configuration configuration) {
final boolean overwrite = configuration.getBoolean(CoreOptions.FILESYTEM_DEFAULT_OVERRIDE);
DEFAULT_WRITE_MODE = overwrite ? WriteMode.OVERWRITE : WriteMode.NO_OVERWRITE;
f... | Create a Java method that does the following: "Initialize the defaults from the configuration.". |
Of course, here is the Java code you requested:
```java
@Override
public void initializeGlobal(int parallelism) throws IOException {
final Path path = getOutputFilePath();
final FileSystem fs = path.getFileSystem();
// only distributed file systems can be initialized at start-up time.
if (fs.isDistributedF... | Create a Java method that does the following: "Initialize the global output file system.". |
Of course, here is the Java code you requested:
```java
public static ByteBuffer toSerializedEvent(AbstractEvent event) throws IOException {
final Class<?> eventClass = event.getClass();
if (eventClass == EndOfPartitionEvent.class) {
return ByteBuffer.wrap(new byte[] { 0, 0, 0, END_OF_PARTITION_EVENT });
}
... | Create a Java method that does the following: "Serialize an event to a ByteBuffer.". |
Of course, here is the Java code you requested:
```java
public static Buffer toBuffer(AbstractEvent event) throws IOException {
final ByteBuffer serializedEvent = EventSerializer.toSerializedEvent(event);
MemorySegment data = MemorySegmentFactory.wrap(serializedEvent.array());
final Buffer buffer = new Network... | Create a Java method that does the following: "Converts an event to a buffer.". |
Of course, here is the Java code you requested:
```java
public static String stringifyException(final Throwable e) {
if (e == null) {
return STRINGIFIED_NULL_EXCEPTION;
}
try {
StringWriter stm = new StringWriter();
PrintWriter wrt = new PrintWriter(stm);
e.printStackTrace(wrt);
wrt.close();
r... | Create a Java method that does the following: "Returns a String representation of the given exception.". |
Of course, here is the Java code you requested:
```java
public static <T extends Throwable> T firstOrSuppressed(T newException, @Nullable T previous) {
checkNotNull(newException, "newException");
if (previous == null) {
return newException;
} else {
previous.addSuppressed(newException);
return previous... | Create a Java method that does the following: "Add a new exception to the first exception or suppressed exception.". |
Of course, here is the Java code you requested:
```java
public static void rethrowException(Throwable t, String parentMessage) throws Exception {
if (t instanceof Error) {
throw (Error) t;
}
else if (t instanceof Exception) {
throw (Exception) t;
}
else {
throw new Exception(parentMessage, t);
}
... | Create a Java method that does the following: "Re - throws an exception.". |
Of course, here is the Java code you requested:
```java
public static void rethrowException(Throwable t) throws Exception {
if (t instanceof Error) {
throw (Error) t;
}
else if (t instanceof Exception) {
throw (Exception) t;
}
else {
throw new Exception(t.getMessage(), t);
}
}
```
Hope this help... | Create a Java method that does the following: "rethrowException This method is used to throw an exception.". |
Of course, here is the Java code you requested:
```java
public static void rethrowIOException(Throwable t) throws IOException {
if (t instanceof IOException) {
throw (IOException) t;
}
else if (t instanceof RuntimeException) {
throw (RuntimeException) t;
}
else if (t instanceof Error) {
throw (Error... | Create a Java method that does the following: "Re - throws an IOException.". |
Of course, here is the Java code you requested:
```java
public static <T extends Throwable> Optional<T> findThrowable(Throwable throwable, Class<T> searchType) {
if (throwable == null || searchType == null) {
return Optional.empty();
}
Throwable t = throwable;
while (t != null) {
if (searchType.isAssign... | Create a Java method that does the following: "Find a Throwable that is assignable from the given type.". |
Of course, here is the Java code you requested:
```java
public static Optional<Throwable> findThrowable(Throwable throwable, Predicate<Throwable> predicate) {
if (throwable == null || predicate == null) {
return Optional.empty();
}
Throwable t = throwable;
while (t != null) {
if (predicate.test(t)) {
... | Create a Java method that does the following: "Find a Throwable that satisfies the given predicate.". |
Of course, here is the Java code you requested:
```java
public static Throwable stripException(Throwable throwableToStrip, Class<? extends Throwable> typeToStrip) {
while (typeToStrip.isAssignableFrom(throwableToStrip.getClass()) && throwableToStrip.getCause() != null) {
throwableToStrip = throwableToStrip.getCau... | Create a Java method that does the following: "Strip an exception from a Throwable.". |
Of course, here is the Java code you requested:
```java
public static void suppressExceptions(RunnableWithException action) {
try {
action.run();
}
catch (InterruptedException e) {
// restore interrupted state
Thread.currentThread().interrupt();
}
catch (Throwable t) {
if (isJvmFatalError(t)) {
... | Create a Java method that does the following: "Suppresses exceptions in the JVM.". |
Of course, here is the Java code you requested:
```java
private static S3Recoverable castToS3Recoverable(CommitRecoverable recoverable) {
if (recoverable instanceof S3Recoverable) {
return (S3Recoverable) recoverable;
}
throw new IllegalArgumentException(
"S3 File System cannot recover recoverable for oth... | Create a Java method that does the following: "Casts a commit recoverable to an S3Recoverable object.". |
Of course, here is the Java code you requested:
```java
public static S3RecoverableWriter writer(
final FileSystem fs,
final FunctionWithException<File, RefCountedFile, IOException> tempFileCreator,
final S3AccessHelper s3AccessHelper,
final Executor uploadThreadPool,
final long userDefinedMinPartSize,
... | Create a Java method that does the following: "Create a new S3RecoverableWriter.". |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.