Skip to content

Commit 2b931e7

Browse files
committed
NIFI-14615 - Moved parquet processors and cv under a single nar. Removed unnecessary code.
1 parent c59ee04 commit 2b931e7

File tree

8 files changed

+37
-739
lines changed

8 files changed

+37
-739
lines changed

nifi-assembly/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -954,12 +954,6 @@ language governing permissions and limitations under the License. -->
954954
<version>2.6.0-SNAPSHOT</version>
955955
<type>nar</type>
956956
</dependency>
957-
<dependency>
958-
<groupId>org.apache.nifi</groupId>
959-
<artifactId>nifi-parquet-content-viewer-nar</artifactId>
960-
<version>2.5.0-SNAPSHOT</version>
961-
<type>nar</type>
962-
</dependency>
963957
</dependencies>
964958
</profile>
965959
<profile>

nifi-extension-bundles/nifi-parquet-bundle/nifi-parquet-content-viewer-nar/pom.xml

Lines changed: 0 additions & 43 deletions
This file was deleted.

nifi-extension-bundles/nifi-parquet-bundle/nifi-parquet-content-viewer-nar/src/main/resources/META-INF/LICENSE

Lines changed: 0 additions & 633 deletions
This file was deleted.

nifi-extension-bundles/nifi-parquet-bundle/nifi-parquet-content-viewer-nar/src/main/resources/META-INF/NOTICE

Lines changed: 0 additions & 27 deletions
This file was deleted.

nifi-extension-bundles/nifi-parquet-bundle/nifi-parquet-content-viewer/src/main/java/org/apache/parquet/web/controller/ParquetContentViewerController.java

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@
4545

4646
public class ParquetContentViewerController extends HttpServlet {
4747
private static final Logger logger = LoggerFactory.getLogger(ParquetContentViewerController.class);
48-
private static final long maxBytes = 1024 * 1024 * 2; //10MB
49-
private static final int bufferSize = 8 * 1024; // 8KB
48+
private static final long MAX_CONTENT_SIZE = 1024 * 1024 * 2; // 10MB
49+
private static final int BUFFER_SIZE = 8 * 1024; // 8KB
5050
private static final ObjectMapper objectMapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT);
5151

52+
static {
53+
objectMapper.getFactory().configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
54+
}
55+
5256
@Override
5357
public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
5458
final ContentRequestContext requestContext = new HttpServletContentRequestContext(request);
@@ -75,30 +79,12 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re
7579

7680
response.setStatus(HttpServletResponse.SC_OK);
7781

78-
final boolean formatted = Boolean.parseBoolean(request.getParameter("formatted"));
79-
if (!formatted) {
80-
final InputStream contentStream = downloadableContent.getContent();
81-
contentStream.transferTo(response.getOutputStream());
82-
return;
83-
}
84-
85-
// allow the user to drive the data type but fall back to the content type if necessary
86-
String displayName = request.getParameter("mimeTypeDisplayName");
87-
if (displayName == null) {
88-
displayName = downloadableContent.getType();
89-
}
90-
91-
if (displayName == null || !(displayName.equals("parquet") || displayName.equals("application/vnd.apache.parquet"))) {
92-
response.sendError(HttpURLConnection.HTTP_BAD_REQUEST, "Unknown content type");
93-
return;
94-
}
95-
9682
try {
9783
//Convert InputStream to a seekable InputStream
9884
byte[] data = getInputStreamBytes(downloadableContent.getContent());
9985

10086
if (data.length == 0) {
101-
response.getOutputStream().write("Content size is too large to display.".getBytes());
87+
response.sendError(HttpURLConnection.HTTP_INTERNAL_ERROR, "Content size is too large to display.");
10288
return;
10389
}
10490

@@ -114,8 +100,8 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re
114100

115101
//Format and write out each record
116102
GenericRecord record;
117-
objectMapper.getFactory().configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
118103
boolean firstRecord = true;
104+
response.getOutputStream().write("[\n".getBytes());
119105
while ((record = reader.read()) != null) {
120106
if (firstRecord) {
121107
firstRecord = false;
@@ -125,6 +111,7 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re
125111

126112
objectMapper.writerWithDefaultPrettyPrinter().writeValue(response.getOutputStream(), objectMapper.readTree(record.toString()));
127113
}
114+
response.getOutputStream().write("\n]".getBytes());
128115
} catch (final Throwable t) {
129116
logger.warn("Unable to format FlowFile content", t);
130117
response.sendError(HttpURLConnection.HTTP_INTERNAL_ERROR, "Unable to format FlowFile content");
@@ -133,11 +120,11 @@ public void doGet(final HttpServletRequest request, final HttpServletResponse re
133120

134121
private byte[] getInputStreamBytes(final InputStream inputStream) throws IOException {
135122
ByteArrayOutputStream baos = new ByteArrayOutputStream();
136-
byte[] buffer = new byte[bufferSize];
123+
byte[] buffer = new byte[BUFFER_SIZE];
137124
long totalRead = 0;
138125

139-
while (totalRead < maxBytes) {
140-
int bytesRead = inputStream.read(buffer, 0, bufferSize);
126+
while (totalRead < MAX_CONTENT_SIZE) {
127+
int bytesRead = inputStream.read(buffer, 0, BUFFER_SIZE);
141128
if (bytesRead == -1) {
142129
break;
143130
}
@@ -146,7 +133,7 @@ private byte[] getInputStreamBytes(final InputStream inputStream) throws IOExcep
146133
}
147134

148135
// Return empty array if inputStream has more data beyond maxBytes
149-
if (totalRead >= maxBytes && inputStream.read() != -1) {
136+
if (totalRead >= MAX_CONTENT_SIZE && inputStream.read() != -1) {
150137
return new byte[0];
151138
}
152139

nifi-extension-bundles/nifi-parquet-bundle/nifi-parquet-content-viewer/src/main/resources/META-INF/NOTICE

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
nifi-web-docs
2-
Copyright 2014-2024 The Apache Software Foundation
2+
Copyright 2014-2025 The Apache Software Foundation
33

44
This product includes software developed at
55
The Apache Software Foundation (http://www.apache.org/).
@@ -24,4 +24,19 @@ The following binary components are provided under the Apache Software License v
2424
Copyright 2014 The Apache Software Foundation
2525

2626
This product includes software developed at
27-
The Apache Software Foundation (http://www.apache.org/).
27+
The Apache Software Foundation (http://www.apache.org/).
28+
29+
(ASLv2) Apache Commons IO
30+
The following NOTICE information applies:
31+
Apache Commons IO
32+
Copyright 2002-2016 The Apache Software Foundation
33+
34+
Other open source components:
35+
36+
(CDDL 1.1) (GPL2 w/ CPE) Jakarta Servlet API
37+
(CDDL 1.1) (GPL2 w/ CPE) jersey-common (org.glassfish.jersey.core:jersey-common:jar:3.1.10 - https://jersey.github.io/)
38+
39+
## FastDoubleParser
40+
jackson-core bundles a shaded copy of FastDoubleParser <https://github.com/wrandelshofer/FastDoubleParser>.
41+
That code is available under an MIT license <https://github.com/wrandelshofer/FastDoubleParser/blob/main/LICENSE>
42+
under the following copyright.

nifi-extension-bundles/nifi-parquet-bundle/nifi-parquet-nar/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,11 @@
3737
<version>2.6.0-SNAPSHOT</version>
3838
<type>nar</type>
3939
</dependency>
40+
<dependency>
41+
<groupId>org.apache.nifi</groupId>
42+
<artifactId>nifi-parquet-content-viewer</artifactId>
43+
<version>2.6.0-SNAPSHOT</version>
44+
<type>war</type>
45+
</dependency>
4046
</dependencies>
4147
</project>

nifi-extension-bundles/nifi-parquet-bundle/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626

2727
<modules>
2828
<module>nifi-parquet-processors</module>
29-
<module>nifi-parquet-nar</module>
3029
<module>nifi-parquet-content-viewer</module>
31-
<module>nifi-parquet-content-viewer-nar</module>
3230
<module>nifi-parquet-shared</module>
31+
<module>nifi-parquet-nar</module>
3332
</modules>
3433
<properties>
3534
<parquet.version>1.15.2</parquet.version>

0 commit comments

Comments
 (0)