View docker-compose.yml
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
--- | |
version: '2' | |
services: | |
zookeeper: | |
image: confluentinc/cp-zookeeper:5.3.1 | |
hostname: zookeeper | |
container_name: zookeeper | |
ports: | |
- "2181:2181" |
View Streaming_Machine_Learning_with_Kafka_and_TensorFlow.py
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
import numpy as np | |
import tensorflow as tf | |
import tensorflow_io.kafka as kafka_io | |
# 1. Consume streaming data with Kafka and TensorFlow I/O | |
def func_x(x): | |
# Decode image to (28, 28) | |
x = tf.io.decode_raw(x, out_type=tf.uint8) | |
x = tf.reshape(x, [28, 28]) | |
# Convert to float32 for tf.keras |
View increased-partitions.sql
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
CREATE STREAM products ...; | |
CREATE STREAM products_repartitioned | |
WITH (PARTITIONS=30) AS | |
SELECT * FROM products | |
EMIT CHANGES; |
View aggregation.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
// Continuously aggregating a KStream into a KTable. | |
KStream<String, String> locationUpdatesStream = ...; | |
KTable<String, Long> locationsPerUser | |
= locationUpdatesStream | |
.groupBy((k, v) -> v.username) | |
.count(); |
View aggregation.sql
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
-- Continuously aggregating a stream into a table with a ksqlDB push query. | |
CREATE STREAM locationUpdatesStream ...; | |
CREATE TABLE locationsPerUser AS | |
SELECT username, COUNT(*) | |
FROM locationUpdatesStream | |
GROUP BY username | |
EMIT CHANGES; |
View topic-as-table.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
// Create KTable from Kafka topic. | |
KTable<String, String> table = builder.table("input-topic", Consumed.with(Serdes.String(), Serdes.String())); |
View topic-as-table.sql
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
-- Create ksqlDB table from Kafka topic. | |
CREATE TABLE myTable (username VARCHAR, location VARCHAR) | |
WITH (KAFKA_TOPIC='input-topic', KEY='username', VALUE_FORMAT='...'); |
View topic-as-stream.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
// Create KStream from Kafka topic. | |
StreamsBuilder builder = new StreamsBuilder(); | |
KStream<String, String> stream = | |
builder.stream("input-topic", Consumed.with(Serdes.String(), Serdes.String())); |
View topic-as-stream.sql
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
-- Create ksqlDB stream from Kafka topic. | |
CREATE STREAM myStream (username VARCHAR, location VARCHAR) | |
WITH (KAFKA_TOPIC='input-topic', VALUE_FORMAT='...'); |
View gist:5cc32f336179d2b37dfafcabfc220f7e
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
“task”: { | |
“type”: “.TaskRole, | |
“initialDelayMs”: 20000, | |
“taskSpecs”: { | |
"bench0": { | |
"class": "org.apache.kafka.trogdor.workload.ProduceBenchSpec", | |
"startMs": 0, | |
"durationMs": 720000, | |
"producerNode": "node0", | |
"bootstrapServers": "%{bootstrapServers}", |
NewerOlder