Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions data-prepper-plugins/format-detection/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

plugins {
id 'java'
}

dependencies {
implementation 'org.apache.tika:tika-core:2.9.2'
implementation 'org.xerial.snappy:snappy-java:1.1.10.8'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testImplementation 'org.assertj:assertj-core:3.25.3'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

test {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.dataprepper.plugins.formatdetection;

/**
* Confidence level of a format detection result.
*/
public enum Confidence {
HIGH,
MEDIUM,
LOW
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.dataprepper.plugins.formatdetection;

/**
* Compression types detectable from magic bytes.
*/
public enum DetectedCompression {
GZIP,
ZSTD,
SNAPPY,
NONE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.dataprepper.plugins.formatdetection;

/**
* Data formats that can be detected from S3 object bytes.
*/
public enum DetectedFormat {
PARQUET,
AVRO,
ORC,
PDF,
IMAGE,
JSON,
NDJSON,
XML,
CSV,
TSV,
TEXT,
UNKNOWN
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.dataprepper.plugins.formatdetection;

/**
* Result of detecting the format and compression of a data sample.
*/
public class FormatDetectionResult {
private final DetectedCompression compression;
private final DetectedFormat format;
private final Confidence confidence;

public FormatDetectionResult(final DetectedCompression compression,
final DetectedFormat format,
final Confidence confidence) {
this.compression = compression;
this.format = format;
this.confidence = confidence;
}

public DetectedCompression getCompression() {
return compression;
}

public DetectedFormat getFormat() {
return format;
}

public Confidence getConfidence() {
return confidence;
}

@Override
public String toString() {
return "FormatDetectionResult{compression=" + compression +
", format=" + format +
", confidence=" + confidence + "}";
}
}
Loading
Loading