You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/10/14 06:30:01 UTC
[GitHub] [camel] orpiske opened a new pull request #6270: CAMEL-17078: support file resume at offset
orpiske opened a new pull request #6270:
URL: https://github.com/apache/camel/pull/6270
This should improve support for reading very large files, since it can
allow uses to implement a strategy for resuming reading at a certain
offset.
<!-- Uncomment and fill this section if your PR is not trivial
- [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it). Trivial changes like typos do not require a JIRA issue. Your pull request should address just this issue, without pulling in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line and body.
- [ ] If you're unsure, you can format the pull request title like `[CAMEL-XXX] Fixes bug in camel-file component`, where you replace `CAMEL-XXX` with the appropriate JIRA issue.
- [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [ ] Run `mvn clean install -Psourcecheck` in your module with source check enabled to make sure basic checks pass and there are no checkstyle violations. A more thorough check will be performed on your pull request automatically.
Below are the contribution guidelines:
https://github.com/apache/camel/blob/main/CONTRIBUTING.md
-->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] orpiske commented on a change in pull request #6270: CAMEL-17078: support file resume at offset
Posted by GitBox <gi...@apache.org>.
orpiske commented on a change in pull request #6270:
URL: https://github.com/apache/camel/pull/6270#discussion_r728679183
##########
File path: core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
##########
@@ -116,11 +118,22 @@ public static BufferedWriter buffered(Writer writer) {
}
public static String toString(Reader reader) throws IOException {
- return toString(buffered(reader));
+ return toString(reader, INITIAL_OFFSET);
+ }
+
+ public static String toString(Reader reader, long offset) throws IOException {
+ return toString(buffered(reader), offset);
}
public static String toString(BufferedReader reader) throws IOException {
+ return toString(reader, INITIAL_OFFSET);
+ }
+
+ public static String toString(BufferedReader reader, long offset) throws IOException {
StringBuilder sb = new StringBuilder(1024);
+
+ reader.skip(offset);
Review comment:
In theory it's is fine, since the reader states that `n` must be equal or greater than 0. For 0 it should be no-op. I wanted to avoid the overhead or checking the offset twice as it's probably checked on reader anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] orpiske merged pull request #6270: CAMEL-17078: support file resume at offset
Posted by GitBox <gi...@apache.org>.
orpiske merged pull request #6270:
URL: https://github.com/apache/camel/pull/6270
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] orpiske commented on a change in pull request #6270: CAMEL-17078: support file resume at offset
Posted by GitBox <gi...@apache.org>.
orpiske commented on a change in pull request #6270:
URL: https://github.com/apache/camel/pull/6270#discussion_r728683315
##########
File path: core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
##########
@@ -116,11 +118,22 @@ public static BufferedWriter buffered(Writer writer) {
}
public static String toString(Reader reader) throws IOException {
- return toString(buffered(reader));
+ return toString(reader, INITIAL_OFFSET);
+ }
+
+ public static String toString(Reader reader, long offset) throws IOException {
+ return toString(buffered(reader), offset);
}
public static String toString(BufferedReader reader) throws IOException {
+ return toString(reader, INITIAL_OFFSET);
+ }
+
+ public static String toString(BufferedReader reader, long offset) throws IOException {
StringBuilder sb = new StringBuilder(1024);
+
+ reader.skip(offset);
Review comment:
Sorry, I meant that `reader.skip(0)` should be fine as per Reader API. I can include the check, for this, though.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] orpiske commented on a change in pull request #6270: CAMEL-17078: support file resume at offset
Posted by GitBox <gi...@apache.org>.
orpiske commented on a change in pull request #6270:
URL: https://github.com/apache/camel/pull/6270#discussion_r728679183
##########
File path: core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
##########
@@ -116,11 +118,22 @@ public static BufferedWriter buffered(Writer writer) {
}
public static String toString(Reader reader) throws IOException {
- return toString(buffered(reader));
+ return toString(reader, INITIAL_OFFSET);
+ }
+
+ public static String toString(Reader reader, long offset) throws IOException {
+ return toString(buffered(reader), offset);
}
public static String toString(BufferedReader reader) throws IOException {
+ return toString(reader, INITIAL_OFFSET);
+ }
+
+ public static String toString(BufferedReader reader, long offset) throws IOException {
StringBuilder sb = new StringBuilder(1024);
+
+ reader.skip(offset);
Review comment:
In theory it's is, since the reader states that `n` must be equal or greater than 0. For 0 it should be no-op. I wanted to avoid the overhead or checking the offset twice as it's probably checked on reader anyway.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] orpiske commented on a change in pull request #6270: CAMEL-17078: support file resume at offset
Posted by GitBox <gi...@apache.org>.
orpiske commented on a change in pull request #6270:
URL: https://github.com/apache/camel/pull/6270#discussion_r728678260
##########
File path: core/camel-api/src/main/java/org/apache/camel/Resumable.java
##########
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel;
+
+public interface Resumable<T> {
Review comment:
Thanks, I missed that one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel] davsclaus commented on a change in pull request #6270: CAMEL-17078: support file resume at offset
Posted by GitBox <gi...@apache.org>.
davsclaus commented on a change in pull request #6270:
URL: https://github.com/apache/camel/pull/6270#discussion_r728675973
##########
File path: core/camel-api/src/main/java/org/apache/camel/Resumable.java
##########
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel;
+
+public interface Resumable<T> {
Review comment:
Add javadoc to this API.
##########
File path: core/camel-util/src/main/java/org/apache/camel/util/IOHelper.java
##########
@@ -116,11 +118,22 @@ public static BufferedWriter buffered(Writer writer) {
}
public static String toString(Reader reader) throws IOException {
- return toString(buffered(reader));
+ return toString(reader, INITIAL_OFFSET);
+ }
+
+ public static String toString(Reader reader, long offset) throws IOException {
+ return toString(buffered(reader), offset);
}
public static String toString(BufferedReader reader) throws IOException {
+ return toString(reader, INITIAL_OFFSET);
+ }
+
+ public static String toString(BufferedReader reader, long offset) throws IOException {
StringBuilder sb = new StringBuilder(1024);
+
+ reader.skip(offset);
Review comment:
I wonder if its safer to only skip if offset > 0
##########
File path: components/camel-file/src/main/java/org/apache/camel/component/file/GenericFileConverter.java
##########
@@ -183,13 +185,17 @@ public static Reader genericFileToReader(GenericFile<?> file, Exchange exchange)
// and use the charset if the file was explicit configured with a
// charset
String charset = file.getCharset();
+ Reader reader;
if (charset != null) {
LOG.debug("Read file {} with charset {}", f, file.getCharset());
- return IOHelper.toReader(f, charset);
+ reader = IOHelper.toReader(f, charset);
} else {
LOG.debug("Read file {} (no charset)", f);
- return IOHelper.toReader(f, ExchangeHelper.getCharsetName(exchange));
+ reader = IOHelper.toReader(f, ExchangeHelper.getCharsetName(exchange));
}
+
+ reader.skip(file.getLastOffset());
Review comment:
I wonder if its safer to only skip if offset > 0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org