-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`find ./ -type f -print0 | xargs -0 dos2unix --`
- Loading branch information
Showing
26 changed files
with
3,256 additions
and
3,256 deletions.
There are no files selected for viewing
52 changes: 26 additions & 26 deletions
52
parallel-consumer-core/src/main/java/io/confluent/csid/utils/JavaUtils.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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
package io.confluent.csid.utils; | ||
|
||
/*- | ||
* Copyright (C) 2020-2021 Confluent, Inc. | ||
*/ | ||
|
||
import io.confluent.parallelconsumer.internal.InternalRuntimeError; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public class JavaUtils { | ||
public static <T> Optional<T> getLast(final List<T> commitHistory) { | ||
if (commitHistory.isEmpty()) return Optional.empty(); | ||
return Optional.of(commitHistory.get(commitHistory.size() - 1)); | ||
} | ||
|
||
public static <T> Optional<T> getOnlyOne(final Map<String, T> stringMapMap) { | ||
if (stringMapMap.isEmpty()) return Optional.empty(); | ||
Collection<T> values = stringMapMap.values(); | ||
if (values.size() > 1) throw new InternalRuntimeError("More than one element"); | ||
return Optional.of(values.iterator().next()); | ||
} | ||
} | ||
package io.confluent.csid.utils; | ||
|
||
/*- | ||
* Copyright (C) 2020-2021 Confluent, Inc. | ||
*/ | ||
|
||
import io.confluent.parallelconsumer.internal.InternalRuntimeError; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public class JavaUtils { | ||
public static <T> Optional<T> getLast(final List<T> commitHistory) { | ||
if (commitHistory.isEmpty()) return Optional.empty(); | ||
return Optional.of(commitHistory.get(commitHistory.size() - 1)); | ||
} | ||
|
||
public static <T> Optional<T> getOnlyOne(final Map<String, T> stringMapMap) { | ||
if (stringMapMap.isEmpty()) return Optional.empty(); | ||
Collection<T> values = stringMapMap.values(); | ||
if (values.size() > 1) throw new InternalRuntimeError("More than one element"); | ||
return Optional.of(values.iterator().next()); | ||
} | ||
} |
56 changes: 28 additions & 28 deletions
56
...umer-core/src/main/java/io/confluent/parallelconsumer/JStreamParallelStreamProcessor.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 |
---|---|---|
@@ -1,28 +1,28 @@ | ||
package io.confluent.parallelconsumer; | ||
|
||
/*- | ||
* Copyright (C) 2020-2021 Confluent, Inc. | ||
*/ | ||
import io.confluent.parallelconsumer.internal.DrainingCloseable; | ||
import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
import org.apache.kafka.clients.producer.ProducerRecord; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
import java.util.stream.Stream; | ||
|
||
public interface JStreamParallelStreamProcessor<K, V> extends DrainingCloseable { | ||
|
||
static <KK, VV> JStreamParallelStreamProcessor<KK, VV> createJStreamEosStreamProcessor(ParallelConsumerOptions options) { | ||
return new JStreamParallelEoSStreamProcessor<>(options); | ||
} | ||
|
||
/** | ||
* Like {@link ParallelEoSStreamProcessor#pollAndProduceMany} but instead of callbacks, streams the results instead, | ||
* after the produce result is ack'd by Kafka. | ||
* | ||
* @return a stream of results of applying the function to the polled records | ||
*/ | ||
Stream<ParallelStreamProcessor.ConsumeProduceResult<K, V, K, V>> pollProduceAndStream(Function<ConsumerRecord<K, V>, | ||
List<ProducerRecord<K, V>>> userFunction); | ||
} | ||
package io.confluent.parallelconsumer; | ||
|
||
/*- | ||
* Copyright (C) 2020-2021 Confluent, Inc. | ||
*/ | ||
import io.confluent.parallelconsumer.internal.DrainingCloseable; | ||
import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
import org.apache.kafka.clients.producer.ProducerRecord; | ||
|
||
import java.util.List; | ||
import java.util.function.Function; | ||
import java.util.stream.Stream; | ||
|
||
public interface JStreamParallelStreamProcessor<K, V> extends DrainingCloseable { | ||
|
||
static <KK, VV> JStreamParallelStreamProcessor<KK, VV> createJStreamEosStreamProcessor(ParallelConsumerOptions options) { | ||
return new JStreamParallelEoSStreamProcessor<>(options); | ||
} | ||
|
||
/** | ||
* Like {@link ParallelEoSStreamProcessor#pollAndProduceMany} but instead of callbacks, streams the results instead, | ||
* after the produce result is ack'd by Kafka. | ||
* | ||
* @return a stream of results of applying the function to the polled records | ||
*/ | ||
Stream<ParallelStreamProcessor.ConsumeProduceResult<K, V, K, V>> pollProduceAndStream(Function<ConsumerRecord<K, V>, | ||
List<ProducerRecord<K, V>>> userFunction); | ||
} |
Oops, something went wrong.