code stringlengths 146 466k | prompt stringlengths 54 1.5k |
|---|---|
Of course, here is the Java code you requested:
```java
public static SlidingEventTimeWindows of(Time size, Time slide) {
return new SlidingEventTimeWindows(size.toMilliseconds(), slide.toMilliseconds(), 0);
}
```
Hope this helps! | Create a Java method that does the following: "Create a sliding event time windows with the specified size and slide time.". |
Of course, here is the Java code you requested:
```java
public boolean setCancellerHandle(ScheduledFuture<?> cancellerHandle) {
synchronized (lock) {
if (this.cancellerHandle == null) {
if (!discarded) {
this.cancellerHandle = cancellerHandle;
return true;
} else {
return false;
}
}
... | Create a Java method that does the following: "Sets the handle of the canceller to be used.". |
Of course, here is the Java code you requested:
```java
public TaskAcknowledgeResult acknowledgeTask(
ExecutionAttemptID executionAttemptId,
TaskStateSnapshot operatorSubtaskStates,
CheckpointMetrics metrics) {
synchronized (lock) {
if (discarded) {
return TaskAcknowledgeResult.DISCARDED;
}
f... | Create a Java method that does the following: "Acknowledges a task.". |
Of course, here is the Java code you requested:
```java
public void abort(CheckpointFailureReason reason, Throwable cause) {
try {
CheckpointException exception = new CheckpointException(reason, cause);
onCompletionPromise.completeExceptionally(exception);
reportFailedCheckpoint(exception);
assertAbortSu... | Create a Java method that does the following: "Aborts the checkpoint with the given reason and cause.". |
Of course, here is the Java code you requested:
```java
private void reportFailedCheckpoint(Exception cause) {
// to prevent null-pointers from concurrent modification, copy reference onto stack
final PendingCheckpointStats statsCallback = this.statsCallback;
if (statsCallback != null) {
long failureTimestamp... | Create a Java method that does the following: "Reports a failed checkpoint.". |
Of course, here is the Java code you requested:
```java
public PythonWindowedStream time_window(Time size, Time slide) {
return new PythonWindowedStream<TimeWindow>(this.stream.timeWindow(size, slide));
}
```
Hope this helps! | Create a Java method that does the following: "Create a new time window stream.". |
Of course, here is the Java code you requested:
```java
public PythonSingleOutputStreamOperator reduce(ReduceFunction<PyObject> reducer) throws IOException {
return new PythonSingleOutputStreamOperator(this.stream.reduce(new PythonReduceFunction(reducer)));
}
```
Hope this helps! | Create a Java method that does the following: "Reduce the Python stream.". |
Of course, here is the Java code you requested:
```java
@Override
public void configure(Configuration parameters) {
super.configure(parameters);
if (charsetName == null || !Charset.isSupported(charsetName)) {
throw new RuntimeException("Unsupported charset: " + charsetName);
}
if (charsetName.equalsIgnor... | Create a Java method that does the following: "Override this to set up the configuration.". |
Of course, here is the Java code you requested:
```java
@Override
public StringValue readRecord(StringValue reuse, byte[] bytes, int offset, int numBytes) {
if (this.ascii) {
reuse.setValueAscii(bytes, offset, numBytes);
return reuse;
}
else {
ByteBuffer byteWrapper = this.byteWrapper;
if (bytes != ... | Create a Java method that does the following: "Read a single value from the byte array.". |
Of course, here is the Java code you requested:
```java
static TypeInformation schemaToTypeInfo(TypeDescription schema) {
switch (schema.getCategory()) {
case BOOLEAN:
return BasicTypeInfo.BOOLEAN_TYPE_INFO;
case BYTE:
return BasicTypeInfo.BYTE_TYPE_INFO;
case SHORT:
return BasicTypeInfo.SHORT_T... | Create a Java method that does the following: "Convert a type description to a TypeInformation object.". |
Of course, here is the Java code you requested:
```java
static int fillRows(Row[] rows, TypeDescription schema, VectorizedRowBatch batch, int[] selectedFields) {
int rowsToRead = Math.min((int) batch.count(), rows.length);
List<TypeDescription> fieldTypes = schema.getChildren();
// read each selected field
f... | Create a Java method that does the following: "Fill rows with the rows from the given batch.". |
Of course, here is the Java code you requested:
```java
private static void fillColumnWithRepeatingValue(Object[] vals, int fieldIdx, Object repeatingValue, int childCount) {
if (fieldIdx == -1) {
// set value as an object
Arrays.fill(vals, 0, childCount, repeatingValue);
} else {
// set value as a field... | Create a Java method that does the following: "Fill the column with a repeating value.". |
Of course, here is the Java code you requested:
```java
public static String lpad(String base, int len, String pad) {
if (len < 0 || "".equals(pad)) {
return null;
} else if (len == 0) {
return "";
}
char[] data = new char[len];
char[] baseChars = base.toCharArray();
char[] padChars = pad.toCharArra... | Create a Java method that does the following: "Returns a string of length len with the specified padding string.". |
Of course, here is the Java code you requested:
```java
public static String rpad(String base, int len, String pad) {
if (len < 0 || "".equals(pad)) {
return null;
} else if (len == 0) {
return "";
}
char[] data = new char[len];
char[] baseChars = base.toCharArray();
char[] padChars = pad.toCharArra... | Create a Java method that does the following: "Returns a string that is padded with the specified string.". |
Of course, here is the Java code you requested:
```java
public static String replace(String str, String oldStr, String replacement) {
return str.replace(oldStr, replacement);
}
```
Hope this helps! | Create a Java method that does the following: "replace the old string with replacement". |
Of course, here is the Java code you requested:
```java
public static String splitIndex(String str, String separator, int index) {
if (index < 0) {
return null;
}
String[] values = StringUtils.splitByWholeSeparatorPreserveAllTokens(str, separator);
if (index >= values.length) {
return null;
} else {
... | Create a Java method that does the following: "Splits the given string by the given separator at the given index.". |
Of course, here is the Java code you requested:
```java
public static String splitIndex(String str, int character, int index) {
if (character > 255 || character < 1 || index < 0) {
return null;
}
String[] values = StringUtils.splitPreserveAllTokens(str, (char) character);
if (index >= values.length) {
re... | Create a Java method that does the following: "Splits the string into the specified character and returns the index of the first occurrence of the character.". |
Of course, here is the Java code you requested:
```java
public static String regexpReplace(String str, String regex, String replacement) {
if (regex.isEmpty()) {
return str;
}
try {
// we should use StringBuffer here because Matcher only accept it
StringBuffer sb = new StringBuffer();
Matcher m = REG... | Create a Java method that does the following: "Replace the string with the given regular expression with the given replacement.". |
Of course, here is the Java code you requested:
```java
public static String regexpExtract(String str, String regex, int extractIndex) {
if (extractIndex < 0) {
return null;
}
try {
Matcher m = REGEXP_PATTERN_CACHE.get(regex).matcher(str);
if (m.find()) {
MatchResult mr = m.toMatchResult();
ret... | Create a Java method that does the following: "Extract a string from a regular expression.". |
Of course, here is the Java code you requested:
```java
public static BinaryString keyValue(
BinaryString str, BinaryString pairSeparator, BinaryString kvSeparator, BinaryString keyName) {
if (str == null || str.getSizeInBytes() == 0) {
return null;
}
if (pairSeparator != null && pairSeparator.getSizeInByte... | Create a Java method that does the following: "Returns the key value of the given segment.". |
Of course, here is the Java code you requested:
```java
public static String hash(String algorithm, String str, String charsetName) {
try {
byte[] digest = MessageDigest
.getInstance(algorithm)
.digest(strToBytesWithCharset(str, charsetName));
return EncodingUtils.hex(digest);
} catch (NoSuchAlgorith... | Create a Java method that does the following: "Returns the hex encoded hash of the given string.". |
Of course, here is the Java code you requested:
```java
public static String parseUrl(String urlStr, String partToExtract) {
URL url;
try {
url = URL_CACHE.get(urlStr);
} catch (Exception e) {
LOG.error("Parse URL error: " + urlStr, e);
return null;
}
if ("HOST".equals(partToExtract)) {
return ur... | Create a Java method that does the following: "Parses a URL and returns the URL part of the URL.". |
Of course, here is the Java code you requested:
```java
public static Map<String, String> strToMap(String text, String listDelimiter, String keyValueDelimiter) {
if (StringUtils.isEmpty(text)) {
return EMPTY_MAP;
}
String[] keyValuePairs = text.split(listDelimiter);
Map<String, String> ret = new HashMap<>(... | Create a Java method that does the following: "Convert a string to a map.". |
Of course, here is the Java code you requested:
```java
@Override
public void close() {
synchronized (lock) {
next = null;
wakeupProducer = false;
if (error == null) {
error = new ClosedException();
}
lock.notifyAll();
}
}
```
Hope this helps! | Create a Java method that does the following: "Close the connection.". |
Of course, here is the Java code you requested:
```java
public DeweyNumber increase(int times) {
int[] newDeweyNumber = Arrays.copyOf(deweyNumber, deweyNumber.length);
newDeweyNumber[deweyNumber.length - 1] += times;
return new DeweyNumber(newDeweyNumber);
}
```
Hope this helps! | Create a Java method that does the following: "Increments the number by the given amount.". |
Of course, here is the Java code you requested:
```java
public DeweyNumber addStage() {
int[] newDeweyNumber = Arrays.copyOf(deweyNumber, deweyNumber.length + 1);
return new DeweyNumber(newDeweyNumber);
}
```
Hope this helps! | Create a Java method that does the following: "Add a stage to the dewey number.". |
Of course, here is the Java code you requested:
```java
@Override
public boolean triggerCheckpoint(CheckpointMetaData checkpointMetaData, CheckpointOptions checkpointOptions, boolean advanceToEndOfEventTime) throws Exception {
if (!externallyInducedCheckpoints) {
return super.triggerCheckpoint(checkpointMetaData... | Create a Java method that does the following: "This method is used to trigger a checkpoint.". |
Of course, here is the Java code you requested:
```java
private <M extends MessageHeaders<EmptyRequestBody, P, U>, U extends MessageParameters, P extends ResponseBody> CompletableFuture<P>
sendRequest(M messageHeaders, U messageParameters) {
return sendRequest(messageHeaders, messageParameters, EmptyRequestBody.g... | Create a Java method that does the following: "Sends an empty request to the server.". |
Of course, here is the Java code you requested:
```java
public int getNumOccupiedMemorySegments() {
// either the number of memory segments, or one for spilling
final int numPartitionBuffers = this.partitionBuffers != null ?
this.partitionBuffers.length : this.buildSideWriteBuffer.getNumOccupiedMemorySegments()... | Create a Java method that does the following: "Returns the number of memory segments occupied by this buffer.". |
Of course, here is the Java code you requested:
```java
public int spillPartition(List<MemorySegment> target, IOManager ioAccess, FileIOChannel.ID targetChannel,
LinkedBlockingQueue<MemorySegment> bufferReturnQueue)
throws IOException
{
// sanity checks
if (!isInMemory()) {
throw new RuntimeException("Bug ... | Create a Java method that does the following: "Spill the partition.". |
Of course, here is the Java code you requested:
```java
public void setReadPosition(long pointer) {
final int bufferNum = (int) (pointer >>> this.segmentSizeBits);
final int offset = (int) (pointer & (this.memorySegmentSize - 1));
this.currentBufferNum = bufferNum;
seekInput(this.partitionBuffers[bufferNum]... | Create a Java method that does the following: "Sets the current read position of the input buffer.". |
Of course, here is the Java code you requested:
```java
JobSubmissionResult finalizeExecute() throws ProgramInvocationException {
return client.run(detachedPlan, jarFilesToAttach, classpathsToAttach, userCodeClassLoader, savepointSettings);
}
```
Hope this helps! | Create a Java method that does the following: "Finalize the execution of the job.". |
Of course, here is the Java code you requested:
```java
@PublicEvolving
@Override
public Tuple2<Long, Long> getCurrentState() throws IOException {
if (this.blockBasedInput == null) {
throw new RuntimeException("You must have forgotten to call open() on your input format.");
}
return new Tuple2<>(
this.... | Create a Java method that does the following: "Get the current state of the input stream.". |
Of course, here is the Java code you requested:
```java
public static void bestEffortDiscardAllStateObjects(
Iterable<? extends StateObject> handlesToDiscard) throws Exception {
LambdaUtil.applyToAllWhileSuppressingExceptions(handlesToDiscard, StateObject::discardState);
}
```
Hope this helps! | Create a Java method that does the following: "Discards all state objects that are not handled by the given handlesToDiscard.". |
Of course, here is the Java code you requested:
```java
public static <T> T find(Class<T> factoryClass, Descriptor descriptor, ClassLoader classLoader) {
Preconditions.checkNotNull(descriptor);
Preconditions.checkNotNull(classLoader);
return findInternal(factoryClass, descriptor.toProperties(), Optional.of(class... | Create a Java method that does the following: "Find a factory object for the given class and descriptor.". |
Of course, here is the Java code you requested:
```java
public static <T> T find(Class<T> factoryClass, Map<String, String> propertyMap) {
return findInternal(factoryClass, propertyMap, Optional.empty());
}
```
Hope this helps! | Create a Java method that does the following: "Find a factory class with the given property map.". |
Of course, here is the Java code you requested:
```java
public static <T> T find(Class<T> factoryClass, Map<String, String> propertyMap, ClassLoader classLoader) {
Preconditions.checkNotNull(classLoader);
return findInternal(factoryClass, propertyMap, Optional.of(classLoader));
}
```
Hope this helps! | Create a Java method that does the following: "Find a factory object from a class with a map of properties.". |
Of course, here is the Java code you requested:
```java
public static <T> T findInternal(Class<T> factoryClass, Map<String, String> properties, Optional<ClassLoader> classLoader) {
Preconditions.checkNotNull(factoryClass);
Preconditions.checkNotNull(properties);
List<TableFactory> foundFactories = discoverFact... | Create a Java method that does the following: "Finds a table instance from the given class and properties.". |
Of course, here is the Java code you requested:
```java
private static List<TableFactory> discoverFactories(Optional<ClassLoader> classLoader) {
try {
List<TableFactory> result = new LinkedList<>();
if (classLoader.isPresent()) {
ServiceLoader
.load(TableFactory.class, classLoader.get())
.iterato... | Create a Java method that does the following: "Discover the table factories.". |
Of course, here is the Java code you requested:
```java
private static <T> List<TableFactory> filterByFactoryClass(
Class<T> factoryClass,
Map<String, String> properties,
List<TableFactory> foundFactories) {
List<TableFactory> classFactories = foundFactories.stream()
.filter(p -> factoryClass.isAssignableF... | Create a Java method that does the following: "Filter by factory class". |
Of course, here is the Java code you requested:
```java
private static Map<String, String> normalizeContext(TableFactory factory) {
Map<String, String> requiredContext = factory.requiredContext();
if (requiredContext == null) {
throw new TableException(
String.format("Required context of factory '%s' must n... | Create a Java method that does the following: "Normalizes the context of the given table factory.". |
Of course, here is the Java code you requested:
```java
private static <T> T filterBySupportedProperties(
Class<T> factoryClass,
Map<String, String> properties,
List<TableFactory> foundFactories,
List<TableFactory> classFactories) {
final List<String> plainGivenKeys = new LinkedList<>();
properties.keySet... | Create a Java method that does the following: "Filter by supported properties". |
Of course, here is the Java code you requested:
```java
private static Tuple2<List<String>, List<String>> normalizeSupportedProperties(TableFactory factory) {
List<String> supportedProperties = factory.supportedProperties();
if (supportedProperties == null) {
throw new TableException(
String.format("Support... | Create a Java method that does the following: "Normalizes the supported properties of the given table factory.". |
Of course, here is the Java code you requested:
```java
private static List<String> filterSupportedPropertiesFactorySpecific(
TableFactory factory,
List<String> keys) {
if (factory instanceof TableFormatFactory) {
boolean includeSchema = ((TableFormatFactory) factory).supportsSchemaDerivation();
return ke... | Create a Java method that does the following: "Filter supported properties factory specific.". |
Of course, here is the Java code you requested:
```java
@Override
public void insertOrReplaceRecord(T record) throws IOException {
if (closed) {
return;
}
T match = prober.getMatchFor(record, reuse);
if (match == null) {
prober.insertAfterNoMatch(record);
} else {
prober.updateMatch(record);
}
... | Create a Java method that does the following: "Insert or replace a record.". |
Of course, here is the Java code you requested:
```java
@Override
public void insert(T record) throws IOException {
if (closed) {
return;
}
final int hashCode = MathUtils.jenkinsHash(buildSideComparator.hash(record));
final int bucket = hashCode & numBucketsMask;
final int bucketSegmentIndex = bucket >>... | Create a Java method that does the following: "Inserts the given record into the underlying MemorySegment.". |
Of course, here is the Java code you requested:
```java
public boolean match(String[] requestPathTokens, Map<String, String> params) {
if (tokens.length == requestPathTokens.length) {
for (int i = 0; i < tokens.length; i++) {
String key = tokens[i];
String value = requestPathTokens[i];
if (key.length... | Create a Java method that does the following: "Match the request path with the tokens in requestPathTokens and put the parameters in params". |
Of course, here is the Java code you requested:
```java
@Override
public Tuple2<K, V> deserialize(ConsumerRecord<byte[], byte[]> record) throws Exception {
K key = null;
V value = null;
if (record.key() != null) {
inputDeserializer.setBuffer(record.key());
key = keySerializer.deserialize(inputDeserialize... | Create a Java method that does the following: "Deserialize a Tuple2 of bytes.". |
Of course, here is the Java code you requested:
```java
public static String repeat(final String str, final int repeat) {
// Performance tuned for 2.0 (JDK1.4)
if (str == null) {
return null;
}
if (repeat <= 0) {
return EMPTY;
}
final int inputLength = str.length();
if (repeat == 1 || inputLength ... | Create a Java method that does the following: "Returns a string that is repeated.". |
Of course, here is the Java code you requested:
```java
@Override
public void writeString(int pos, BinaryString input) {
if (input.getSegments() == null) {
String javaObject = input.getJavaObject();
writeBytes(pos, javaObject.getBytes());
} else {
int len = input.getSizeInBytes();
if (len <= 7) {
... | Create a Java method that does the following: "Write a string to the stream.". |
Of course, here is the Java code you requested:
```java
private void grow(int minCapacity) {
int oldCapacity = segment.size();
int newCapacity = oldCapacity + (oldCapacity >> 1);
if (newCapacity - minCapacity < 0) {
newCapacity = minCapacity;
}
segment = MemorySegmentFactory.wrap(Arrays.copyOf(segment.get... | Create a Java method that does the following: "Grows the segment by a given capacity.". |
Of course, here is the Java code you requested:
```java
public void releasePartitions(Collection<ResultPartitionID> partitionIds) {
for (ResultPartitionID partitionId : partitionIds) {
resultPartitionManager.releasePartition(partitionId, null);
}
}
```
Hope this helps! | Create a Java method that does the following: "Release the partitions.". |
Of course, here is the Java code you requested:
```java
public static RestartStrategyConfiguration fixedDelayRestart(int restartAttempts, long delayBetweenAttempts) {
return fixedDelayRestart(restartAttempts, Time.of(delayBetweenAttempts, TimeUnit.MILLISECONDS));
}
```
Hope this helps! | Create a Java method that does the following: "Creates a fixed - delay restart strategy configuration that will retry after a fixed amount of time.". |
Of course, here is the Java code you requested:
```java
public static void main(String[] args) throws Exception {
// Checking input parameters
final ParameterTool params = ParameterTool.fromArgs(args);
// set up input for the stream of integer pairs
// obtain execution environment and set setBufferTimeout t... | Create a Java method that does the following: "Main method to run the Iterate example.". |
Of course, here is the Java code you requested:
```java
void storeInitialHashTable() throws IOException {
if (spilled) {
return; // we create the initialHashTable only once. Later calls are caused by deeper recursion lvls
}
spilled = true;
for (int partIdx = 0; partIdx < initialPartitions.size(); partIdx... | Create a Java method that does the following: "Stores the initial hash table.". |
Of course, here is the Java code you requested:
```java
protected boolean checkNextIndexOffset() {
if (this.currentSortIndexOffset > this.lastIndexEntryOffset) {
MemorySegment returnSegment = nextMemorySegment();
if (returnSegment != null) {
this.currentSortIndexSegment = returnSegment;
this.sortIndex.... | Create a Java method that does the following: "Check if the next index entry is available.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings({ "rawtypes", "unchecked" })
public void collectBuffer(Collector<OUT> c, int bufferSize) throws IOException {
fileBuffer.position(0);
while (fileBuffer.position() < bufferSize) {
c.collect(deserializer.deserialize());
}
}
```
Hope t... | Create a Java method that does the following: "Reads the contents of the file into the given collector.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public void init(
Map<EventId, Lockable<V>> events,
Map<NodeId, Lockable<SharedBufferNode>> entries) throws Exception {
eventsBuffer.putAll(events);
this.entries.putAll(entries);
Map<Long, Integer> maxIds = events.keySet().stream().colle... | Create a Java method that does the following: "Initializes the object with the given data.". |
Of course, here is the Java code you requested:
```java
public boolean isEmpty() throws Exception {
return Iterables.isEmpty(eventsBufferCache.keySet()) && Iterables.isEmpty(eventsBuffer.keys());
}
```
Hope this helps! | Create a Java method that does the following: "Returns true if the cache and buffer are empty.". |
Of course, here is the Java code you requested:
```java
void flushCache() throws Exception {
if (!entryCache.isEmpty()) {
entries.putAll(entryCache);
entryCache.clear();
}
if (!eventsBufferCache.isEmpty()) {
eventsBuffer.putAll(eventsBufferCache);
eventsBufferCache.clear();
}
}
```
Hope this help... | Create a Java method that does the following: "Flushes the cache.". |
Of course, here is the Java code you requested:
```java
public TimeWindow cover(TimeWindow other) {
return new TimeWindow(Math.min(start, other.start), Math.max(end, other.end));
}
```
Hope this helps! | Create a Java method that does the following: "Returns a new time window that contains the specified time window.". |
Of course, here is the Java code you requested:
```java
public static void mergeWindows(Collection<TimeWindow> windows, MergingWindowAssigner.MergeCallback<TimeWindow> c) {
// sort the windows by the start time and then merge overlapping windows
List<TimeWindow> sortedWindows = new ArrayList<>(windows);
Colle... | Create a Java method that does the following: "Merge windows.". |
Of course, here is the Java code you requested:
```java
@Override
public void computeUnclosedBranchStack() {
if (this.openBranches != null) {
return;
}
// we need to track open branches even in the sinks, because they get "closed" when
// we build a single "root" for the data flow plan
addClosedBranches... | Create a Java method that does the following: "Compute the unclosed branch stack.". |
Of course, here is the Java code you requested:
```java
@Override
public void accept(Visitor<OptimizerNode> visitor) {
if (visitor.preVisit(this)) {
if (getPredecessorNode() != null) {
getPredecessorNode().accept(visitor);
} else {
throw new CompilerException();
}
visitor.postVisit(this);
}
}... | Create a Java method that does the following: "Visit this node.". |
Of course, here is the Java code you requested:
```java
public boolean setAndCheckDiscoveredPartition(KafkaTopicPartition partition) {
if (isUndiscoveredPartition(partition)) {
discoveredPartitions.add(partition);
return KafkaTopicPartitionAssigner.assign(partition, numParallelSubtasks) == indexOfThisSubtask;... | Create a Java method that does the following: "Sets the partition to be checked discovered.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("unchecked")
@Override
public Class<SortedMap<K, V>> getTypeClass() {
return (Class<SortedMap<K, V>>) (Class<?>) SortedMap.class;
}
```
Hope this helps! | Create a Java method that does the following: "Get the type class.". |
Of course, here is the Java code you requested:
```java
private <S extends State, V> S createKeyedState(StateDescriptor<S, V> stateDescriptor) throws Exception {
checkNotNull(keyedStateBackend.getKeySerializer(),
"State key serializer has not been configured in the config. " +
"This operation cannot use partit... | Create a Java method that does the following: "Create a keyed state.". |
Of course, here is the Java code you requested:
```java
public static void main(String[] args) throws Exception {
// set up execution environment
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
BatchTableEnvironment tEnv = BatchTableEnvironment.create(env);
DataSet<WC> input = env.... | Create a Java method that does the following: "Main method to run the CRUD test.". |
Of course, here is the Java code you requested:
```java
public boolean addMasterHook(MasterTriggerRestoreHook<?> hook) {
checkNotNull(hook);
final String id = hook.getIdentifier();
checkArgument(!StringUtils.isNullOrWhitespaceOnly(id), "The hook has a null or empty id");
synchronized (lock) {
if (!masterH... | Create a Java method that does the following: "Adds a master hook to be called when the restore hook is triggered.". |
Of course, here is the Java code you requested:
```java
public void shutdown(JobStatus jobStatus) throws Exception {
synchronized (lock) {
if (!shutdown) {
shutdown = true;
LOG.info("Stopping checkpoint coordinator for job {}.", job);
periodicScheduling = false;
triggerRequestQueued = false;
... | Create a Java method that does the following: "Shutdown the coordinator for the given job.". |
Of course, here is the Java code you requested:
```java
public CompletableFuture<CompletedCheckpoint> triggerSynchronousSavepoint(
final long timestamp,
final boolean advanceToEndOfEventTime,
@Nullable final String targetLocation) {
final CheckpointProperties properties = CheckpointProperties.forSyncSavepo... | Create a Java method that does the following: "Triggers a synchronous savepoint.". |
Of course, here is the Java code you requested:
```java
public void receiveDeclineMessage(DeclineCheckpoint message) {
if (shutdown || message == null) {
return;
}
if (!job.equals(message.getJob())) {
throw new IllegalArgumentException("Received DeclineCheckpoint message for job " +
message.getJob() + ... | Create a Java method that does the following: "This method is called when a DeclineCheckpoint message is received from the coordinator.". |
Of course, here is the Java code you requested:
```java
public void failUnacknowledgedPendingCheckpointsFor(ExecutionAttemptID executionAttemptId, Throwable cause) {
synchronized (lock) {
Iterator<PendingCheckpoint> pendingCheckpointIterator = pendingCheckpoints.values().iterator();
while (pendingCheckpointIt... | Create a Java method that does the following: "Fail all pending checkpoints for the given execution attempt id.". |
Of course, here is the Java code you requested:
```java
private void triggerQueuedRequests() {
if (triggerRequestQueued) {
triggerRequestQueued = false;
// trigger the checkpoint from the trigger timer, to finish the work of this thread before
// starting with the next checkpoint
if (periodicScheduling)... | Create a Java method that does the following: "Trigger the queued requests.". |
Of course, here is the Java code you requested:
```java
public boolean restoreSavepoint(
String savepointPointer,
boolean allowNonRestored,
Map<JobVertexID, ExecutionJobVertex> tasks,
ClassLoader userClassLoader) throws Exception {
Preconditions.checkNotNull(savepointPointer, "The savepoint path cannot ... | Create a Java method that does the following: "Restores the state of a savepoint.". |
Of course, here is the Java code you requested:
```java
public JobStatusListener createActivatorDeactivator() {
synchronized (lock) {
if (shutdown) {
throw new IllegalArgumentException("Checkpoint coordinator is shut down");
}
if (jobStatusListener == null) {
jobStatusListener = new CheckpointCoord... | Create a Java method that does the following: "Create a new deactivator for the checkpoint coordinator.". |
Of course, here is the Java code you requested:
```java
private void discardSubtaskState(
final JobID jobId,
final ExecutionAttemptID executionAttemptID,
final long checkpointId,
final TaskStateSnapshot subtaskState) {
if (subtaskState != null) {
executor.execute(new Runnable() {
@Override
pu... | Create a Java method that does the following: "Discards the state object of a subtask.". |
Of course, here is the Java code you requested:
```java
public ResourceSpec merge(ResourceSpec other) {
ResourceSpec target = new ResourceSpec(
Math.max(this.cpuCores, other.cpuCores),
this.heapMemoryInMB + other.heapMemoryInMB,
this.directMemoryInMB + other.directMemoryInMB,
this.nativeMemoryInMB + ... | Create a Java method that does the following: "Merge two ResourceSpecs.". |
Of course, here is the Java code you requested:
```java
public boolean isValid() {
if (this.cpuCores >= 0 && this.heapMemoryInMB >= 0 && this.directMemoryInMB >= 0 &&
this.nativeMemoryInMB >= 0 && this.stateSizeInMB >= 0) {
for (Resource resource : extendedResources.values()) {
if (resource.getValue() < 0... | Create a Java method that does the following: "Returns true if the state of this state is valid.". |
Of course, here is the Java code you requested:
```java
protected String getRPCPortRange(Configuration configuration) {
if (ZooKeeperUtils.isZooKeeperRecoveryMode(configuration)) {
return configuration.getString(HighAvailabilityOptions.HA_JOB_MANAGER_PORT_RANGE);
} else {
return String.valueOf(configuration.... | Create a Java method that does the following: "Get the port range for the job manager.". |
Of course, here is the Java code you requested:
```java
private Configuration generateClusterConfiguration(Configuration configuration) {
final Configuration resultConfiguration = new Configuration(Preconditions.checkNotNull(configuration));
final String webTmpDir = configuration.getString(WebOptions.TMP_DIR);
... | Create a Java method that does the following: "Generates a cluster configuration.". |
Of course, here is the Java code you requested:
```java
private CompletableFuture<Void> closeClusterComponent(ApplicationStatus applicationStatus, @Nullable String diagnostics) {
synchronized (lock) {
if (clusterComponent != null) {
return clusterComponent.deregisterApplicationAndClose(applicationStatus, diag... | Create a Java method that does the following: "Closes the cluster component.". |
Of course, here is the Java code you requested:
```java
public void addUniqueField(FieldSet uniqueFieldSet) {
if (this.uniqueFields == null) {
this.uniqueFields = new HashSet<FieldSet>();
}
this.uniqueFields.add(uniqueFieldSet);
}
```
Hope this helps! | Create a Java method that does the following: "Adds a FieldSet to the set of unique fields.". |
Of course, here is the Java code you requested:
```java
public void addUniqueFields(Set<FieldSet> uniqueFieldSets) {
if (this.uniqueFields == null) {
this.uniqueFields = new HashSet<FieldSet>();
}
this.uniqueFields.addAll(uniqueFieldSets);
}
```
Hope this helps! | Create a Java method that does the following: "Adds the given field sets to the set of unique fields.". |
Of course, here is the Java code you requested:
```java
private List<String> getTagsFromMetricGroup(MetricGroup metricGroup) {
List<String> tags = new ArrayList<>();
for (Map.Entry<String, String> entry: metricGroup.getAllVariables().entrySet()) {
if (!entry.getKey().equals(HOST_VARIABLE)) {
tags.add(getVa... | Create a Java method that does the following: "Get tags from metric group.". |
Of course, here is the Java code you requested:
```java
@Override
void requestSubpartition(int subpartitionIndex) throws IOException, InterruptedException {
boolean retriggerRequest = false;
// The lock is required to request only once in the presence of retriggered requests.
synchronized (requestLock) {
c... | Create a Java method that does the following: "Requests a subpartition of the local input channel.". |
Of course, here is the Java code you requested:
```java
void retriggerSubpartitionRequest(Timer timer, final int subpartitionIndex) {
synchronized (requestLock) {
checkState(subpartitionView == null, "already requested partition");
timer.schedule(new TimerTask() {
@Override
public void run() {
tr... | Create a Java method that does the following: "Retrigger a request for a subpartition.". |
Of course, here is the Java code you requested:
```java
public void seek(long block, long recordInBlock) throws IOException {
List<BlockMetaData> blockMetaData = reader.getRowGroups();
if (block == -1L && recordInBlock == -1L) {
// the split was fully consumed
currentBlock = blockMetaData.size() - 1;
nu... | Create a Java method that does the following: "Seeks to the given block and record in the given block.". |
Of course, here is the Java code you requested:
```java
private boolean readNextRecord() throws IOException {
boolean recordFound = false;
while (!recordFound) {
// no more records left
if (numReadRecords >= numTotalRecords) {
return false;
}
try {
if (numReadRecords == numRecordsUpToCurrentBl... | Create a Java method that does the following: "Reads the next record from the underlying reader.". |
Of course, here is the Java code you requested:
```java
public void shutdown() {
synchronized (globalLock) {
for (Instance i : allInstances) {
i.removeSlotListener();
i.cancelAndReleaseAllSlots();
}
allInstances.clear();
allInstancesByHost.clear();
instancesWithAvailableResources.clear();
t... | Create a Java method that does the following: "Shutdown all the instances.". |
Of course, here is the Java code you requested:
```java
protected SimpleSlot getFreeSlotForTask(ExecutionVertex vertex,
Iterable<TaskManagerLocation> requestedLocations,
boolean localOnly) {
// we need potentially to loop multiple times, because there may be false positives
// in the set-with... | Create a Java method that does the following: "This method returns the free slot for a task.". |
Of course, here is the Java code you requested:
```java
protected SimpleSlot getNewSlotForSharingGroup(ExecutionVertex vertex,
Iterable<TaskManagerLocation> requestedLocations,
SlotSharingGroupAssignment groupAssignment,
CoLocationConstraint constraint,
boolean local... | Create a Java method that does the following: "This method is used to allocate a new slot for a sharing group.". |
Of course, here is the Java code you requested:
```java
private Pair<Instance, Locality> findInstance(Iterable<TaskManagerLocation> requestedLocations, boolean localOnly) {
// drain the queue of newly available instances
while (this.newlyAvailableInstances.size() > 0) {
Instance queuedInstance = this.newlyAv... | Create a Java method that does the following: "Find the instance with the given locations.". |
Of course, here is the Java code you requested:
```java
@VisibleForTesting
@Nullable
public Instance getInstance(ResourceID resourceId) {
for (Instance instance : allInstances) {
if (Objects.equals(resourceId, instance.getTaskManagerID())) {
return instance;
}
}
return null;
}
```
Hope this helps! | Create a Java method that does the following: "Gets the instance with the given resource id.". |
Of course, here is the Java code you requested:
```java
public String format(Description description) {
for (BlockElement blockElement : description.getBlocks()) {
blockElement.format(this);
}
return finalizeFormatting();
}
```
Hope this helps! | Create a Java method that does the following: "Format the given description.". |
Of course, here is the Java code you requested:
```java
public O returns(TypeHint<OUT> typeHint) {
requireNonNull(typeHint, "TypeHint must not be null");
try {
return returns(TypeInformation.of(typeHint));
}
catch (InvalidTypesException e) {
throw new InvalidTypesException("Cannot infer the type informa... | Create a Java method that does the following: "Returns the value of the method that is the type of the given type hint.". |
Of course, here is the Java code you requested:
```java
@Override
@SuppressWarnings("unchecked")
public Tuple7<T0, T1, T2, T3, T4, T5, T6> copy() {
return new Tuple7<>(this.f0,
this.f1,
this.f2,
this.f3,
this.f4,
this.f5,
this.f6);
}
```
Hope this helps! | Create a Java method that does the following: "Returns a copy of this tuple.". |
Of course, here is the Java code you requested:
```java
public static <T0, T1, T2, T3, T4, T5, T6> Tuple7<T0, T1, T2, T3, T4, T5, T6> of(T0 value0, T1 value1, T2 value2, T3 value3, T4 value4, T5 value5, T6 value6) {
return new Tuple7<>(value0,
value1,
value2,
value3,
value4,
value5,
value6);
}
```... | Create a Java method that does the following: "Construct a tuple 7 with the specified values.". |
Of course, here is the Java code you requested:
```java
public ChannelHandler[] getClientChannelHandlers() {
NetworkClientHandler networkClientHandler =
creditBasedEnabled ? new CreditBasedPartitionRequestClientHandler() :
new PartitionRequestClientHandler();
return new ChannelHandler[] {
messageEncoder,... | Create a Java method that does the following: "Returns an array of ChannelHandlers that can be used to handle the request.". |
Of course, here is the Java code you requested:
```java
public static void main(String[] args) {
if (args.length < 1) {
CliOptionsParser.printHelpClient();
return;
}
switch (args[0]) {
case MODE_EMBEDDED:
// remove mode
final String[] modeArgs = Arrays.copyOfRange(args, 1, args.length);
fi... | Create a Java method that does the following: "Main method for the command line tool.". |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.