-
-
Save javier/ec8318968f19648be77f2034d846faec to your computer and use it in GitHub Desktop.
questdb ilp ingestion
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
package io.questdb.samples.ilp_ingestion; | |
import io.questdb.client.Sender; | |
import java.util.Random; | |
public class IlpSender { | |
static final String[] deviceTypes = {"blue", "red", "green", "yellow"}; | |
static final Double min_lat = 19.50139, max_lat = 64.85694, min_lon = -161.75583, max_lon = -68.01197; | |
public static void main(String[] args) { | |
Random random = new Random(); | |
try (Sender sender = Sender.builder() | |
.address("javier-demo-3-d9079585.ilp.b1t9.questdb.com:31541") | |
.enableTls() | |
.enableAuth("admin").authToken("Odt-BUKSpPUKG1nj2iu01O0EV-9jvvAw6Io245gSbp4") | |
.bufferCapacity(batch * 200) | |
.build()) { | |
int max_items=1000000, batch = 1000, delay_ms = 500; | |
for(int i=1;i<=max_items;i++) { | |
sender.table("ilp_demo") | |
.symbol("device_type", deviceTypes[random.nextInt(deviceTypes.length)]) | |
.longColumn("duration_ms", random.nextInt(4000)) | |
.doubleColumn("lat", random.nextDouble() * (max_lat - min_lat)) | |
.doubleColumn("lon", random.nextDouble() * (max_lat - min_lat)) | |
.longColumn("measure1", random.nextInt(Integer.MAX_VALUE)) | |
.longColumn("measure2", random.nextInt(Integer.MAX_VALUE)) | |
.longColumn("speed", random.nextInt(100)) | |
.atNow(); | |
if (i % batch == 0 ) { | |
sender.flush(); | |
Thread.sleep(delay_ms); | |
} | |
} | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.example</groupId> | |
<artifactId>ilp_ingestion</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<name>ilp_ingestion</name> | |
<!-- FIXME change it to the project's website --> | |
<url>http://www.example.com</url> | |
<properties> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<maven.compiler.source>1.7</maven.compiler.source> | |
<maven.compiler.target>1.7</maven.compiler.target> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>4.11</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.questdb</groupId> | |
<artifactId>questdb</artifactId> | |
<version>6.5.3</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> | |
<plugins> | |
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle --> | |
<plugin> | |
<artifactId>maven-clean-plugin</artifactId> | |
<version>3.1.0</version> | |
</plugin> | |
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging --> | |
<plugin> | |
<artifactId>maven-resources-plugin</artifactId> | |
<version>3.0.2</version> | |
</plugin> | |
<plugin> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.8.0</version> | |
</plugin> | |
<plugin> | |
<artifactId>maven-surefire-plugin</artifactId> | |
<version>2.22.1</version> | |
</plugin> | |
<plugin> | |
<artifactId>maven-jar-plugin</artifactId> | |
<version>3.0.2</version> | |
</plugin> | |
<plugin> | |
<artifactId>maven-install-plugin</artifactId> | |
<version>2.5.2</version> | |
</plugin> | |
<plugin> | |
<artifactId>maven-deploy-plugin</artifactId> | |
<version>2.8.2</version> | |
</plugin> | |
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle --> | |
<plugin> | |
<artifactId>maven-site-plugin</artifactId> | |
<version>3.7.1</version> | |
</plugin> | |
<plugin> | |
<artifactId>maven-project-info-reports-plugin</artifactId> | |
<version>3.0.0</version> | |
</plugin> | |
</plugins> | |
</pluginManagement> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<configuration> | |
<source>8</source> | |
<target>8</target> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment