-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NIO CountBytes example #975
NIO CountBytes example #975
Conversation
Let me start with general comments:
This is not true. This error comes from the way you loop and compute long total = 0;
int readCalls = 0;
for (int read = 1; read > 0; ) {
readCalls ++;
read = chan.read(buf);
buf.flip();
total += read; // On the last call you read -1 and sum it to total size, thus the mismatch
} In general the for loop seems a bit strange to me, I would have used something like (not tested): while (chan.read(buf) > 0) {
readCalls++;
total += buf.position();
buf.flip();
}
readCalls++; // We must count the last call
What does this mean? Is it slower at reading the size metadata or at downloading the file? Can you share some numbers? |
@@ -0,0 +1,82 @@ | |||
package com.google.cloud.examples.nio; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Thank you! Indeed it's obvious now.
Downloading the file. Here's what I see:
We can see that gsutil takes 1/4th of the time. The way it prints it suggests that it did 4 parallel downloads (each of 1/4th the size). |
Added licence text, plus some esthetic changes.
/** | ||
* CountBytes will read through the whole file given as input. | ||
* | ||
* <p>It's meant for testing that NIO doesn't read too slowly. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Are we OK to merge? |
@jean-philippe-martin just merged. As usual: thanks! |
You are welcome! |
…googleapis#975) - [ ] Regenerate this pull request now. feat: add saved_query.proto to aiplatform v1 feat: add saved_query_id to InputDataConfig in aiplatform v1 training_pipeline.proto PiperOrigin-RevId: 456872211 Source-Link: googleapis/googleapis@88f3973 Source-Link: https://github.com/googleapis/googleapis-gen/commit/daf8d1cb20fadabdd8914581da1ceeef048a34f7 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGFmOGQxY2IyMGZhZGFiZGQ4OTE0NTgxZGExY2VlZWYwNDhhMzRmNyJ9 feat: add ListSavedQueries rpc to aiplatform v1beta1 dataset_service.proto feat: add saved_query.proto to aiplatform v1beta1 feat: add saved_query_id to InputDataConfig in aiplatform v1beta1 training_pipeline.proto PiperOrigin-RevId: 456872207 Source-Link: googleapis/googleapis@aeb384a Source-Link: https://github.com/googleapis/googleapis-gen/commit/c5c8894abbfcd1f6b9d38d9e9fd70a18f15cf0cc Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzVjODg5NGFiYmZjZDFmNmI5ZDM4ZDllOWZkNzBhMThmMTVjZjBjYyJ9
🤖 I have created a release *beep* *boop* --- ## [3.0.0](googleapis/java-aiplatform@v2.9.8...v3.0.0) (2022-07-01) ### ⚠ BREAKING CHANGES * added packaging options for C#, Ruby, and PHP ### Features * add BatchImportModelEvaluationSlices API in aiplatform v1 model_service.proto ([googleapis#972](googleapis/java-aiplatform#972)) ([7f45b24](googleapis/java-aiplatform@7f45b24)) * add BatchImportModelEvaluationSlices API in aiplatform v1beta1 model_service.proto ([7f45b24](googleapis/java-aiplatform@7f45b24)) * add display_name and metadata to ModelEvaluation in aiplatform model_evaluation.proto ([a2a404f](googleapis/java-aiplatform@a2a404f)) * add ListSavedQueries rpc to aiplatform v1 dataset_service.proto ([googleapis#975](googleapis/java-aiplatform#975)) ([ab9ba69](googleapis/java-aiplatform@ab9ba69)) * add ListSavedQueries rpc to aiplatform v1beta1 dataset_service.proto ([ab9ba69](googleapis/java-aiplatform@ab9ba69)) * add model_monitoring_config to BatchPredictionJob in aiplatform v1beta1 batch_prediction_job.proto ([googleapis#892](googleapis/java-aiplatform#892)) ([a2a404f](googleapis/java-aiplatform@a2a404f)) * add model_version_id to BatchPredictionJob in aiplatform v1 batch_prediction_job.proto ([7f45b24](googleapis/java-aiplatform@7f45b24)) * add model_version_id to DeployedModel in aiplatform v1 endpoint.proto ([7f45b24](googleapis/java-aiplatform@7f45b24)) * add model_version_id to PredictResponse in aiplatform v1 prediction_service.proto ([7f45b24](googleapis/java-aiplatform@7f45b24)) * add saved_query_id to InputDataConfig in aiplatform v1 training_pipeline.proto ([ab9ba69](googleapis/java-aiplatform@ab9ba69)) * add saved_query_id to InputDataConfig in aiplatform v1beta1 training_pipeline.proto ([ab9ba69](googleapis/java-aiplatform@ab9ba69)) * add saved_query.proto to aiplatform v1 ([ab9ba69](googleapis/java-aiplatform@ab9ba69)) * add saved_query.proto to aiplatform v1beta1 ([ab9ba69](googleapis/java-aiplatform@ab9ba69)) * add template_metadata to PipelineJob in aiplatform v1beta1 pipeline_job.proto ([a2a404f](googleapis/java-aiplatform@a2a404f)) * **samples:** add create-featurestore sample ([googleapis#948](googleapis/java-aiplatform#948)) ([ffc4b87](googleapis/java-aiplatform@ffc4b87)) ### Bug Fixes * added packaging options for C#, Ruby, and PHP ([a2a404f](googleapis/java-aiplatform@a2a404f)) * update gapic-generator-java with mock service generation fixes ([googleapis#979](googleapis/java-aiplatform#979)) ([e5f3ca5](googleapis/java-aiplatform@e5f3ca5)) ### Dependencies * update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([googleapis#973](googleapis/java-aiplatform#973)) ([56ad705](googleapis/java-aiplatform@56ad705)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
…975) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-core](https://togithub.com/googleapis/java-core) | `2.8.5` -> `2.8.7` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.7/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.7/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.7/compatibility-slim/2.8.5)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:google-cloud-core/2.8.7/confidence-slim/2.8.5)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>googleapis/java-core</summary> ### [`v2.8.7`](https://togithub.com/googleapis/java-core/blob/HEAD/CHANGELOG.md#​287-httpsgithubcomgoogleapisjava-corecomparev286v287-2022-08-03) [Compare Source](https://togithub.com/googleapis/java-core/compare/v2.8.6...v2.8.7) ##### Dependencies - update dependency com.google.auth:google-auth-library-bom to v1.9.0 ([#​894](https://togithub.com/googleapis/java-core/issues/894)) ([82aaa16](https://togithub.com/googleapis/java-core/commit/82aaa16cd9813984a0c92d944eb1ad956759a8e5)) - update dependency io.grpc:grpc-bom to v1.48.1 ([#​891](https://togithub.com/googleapis/java-core/issues/891)) ([0b0f9b8](https://togithub.com/googleapis/java-core/commit/0b0f9b89757b801e8334c764644d7b66032d36d1)) ### [`v2.8.6`](https://togithub.com/googleapis/java-core/blob/HEAD/CHANGELOG.md#​286-httpsgithubcomgoogleapisjava-corecomparev285v286-2022-08-02) [Compare Source](https://togithub.com/googleapis/java-core/compare/v2.8.5...v2.8.6) ##### Dependencies - update dependency com.google.api:gax-bom to v2.18.7 ([#​890](https://togithub.com/googleapis/java-core/issues/890)) ([c67bed5](https://togithub.com/googleapis/java-core/commit/c67bed5281b458e78780cdd918235b5d073917c7)) - update dependency com.google.code.gson:gson to v2.9.1 ([#​888](https://togithub.com/googleapis/java-core/issues/888)) ([7b799c6](https://togithub.com/googleapis/java-core/commit/7b799c66f4aaf057242e9a231b920e49a7c964e9)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-dialogflow). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xNDEuMCIsInVwZGF0ZWRJblZlciI6IjMyLjE0MS4wIn0=-->
🤖 I have created a release *beep* *boop* --- ## [4.7.5](googleapis/java-dialogflow@v4.7.4...v4.7.5) (2022-08-03) ### Dependencies * update dependency com.google.cloud:google-cloud-core to v2.8.5 ([#972](googleapis/java-dialogflow#972)) ([640883a](googleapis/java-dialogflow@640883a)) * update dependency com.google.cloud:google-cloud-core to v2.8.7 ([#975](googleapis/java-dialogflow#975)) ([c035726](googleapis/java-dialogflow@c035726)) * update dependency com.google.cloud:google-cloud-shared-dependencies to v3 ([#969](googleapis/java-dialogflow#969)) ([45de673](googleapis/java-dialogflow@45de673)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 468735472 Source-Link: googleapis/googleapis@cfa1b37 Source-Link: https://github.com/googleapis/googleapis-gen/commit/09b7666656510f5b00b893f003a0ba5766f9e250 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDliNzY2NjY1NjUxMGY1YjAwYjg5M2YwMDNhMGJhNTc2NmY5ZTI1MCJ9
…1.1 (#975) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:libraries-bom](https://cloud.google.com/java/docs/bom) ([source](https://togithub.com/googleapis/java-cloud-bom)) | `26.1.0` -> `26.1.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.1/compatibility-slim/26.1.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.1/confidence-slim/26.1.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-dlp). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xODQuMiIsInVwZGF0ZWRJblZlciI6IjMyLjE4NC4yIn0=-->
* fix: update DeIdentificationTest * temp test * updating tests * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore(deps): update dependency com.google.cloud:libraries-bom to v26.1.1 (#975) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:libraries-bom](https://cloud.google.com/java/docs/bom) ([source](https://togithub.com/googleapis/java-cloud-bom)) | `26.1.0` -> `26.1.1` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.1/compatibility-slim/26.1.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.1/confidence-slim/26.1.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-dlp). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4xODQuMiIsInVwZGF0ZWRJblZlciI6IjMyLjE4NC4yIn0=--> * fix tests Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: WhiteSource Renovate <[email protected]>
…1575) (#975) Source-Link: googleapis/synthtool@2e9ac19 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-java:latest@sha256:8175681a918181d306d9c370d3262f16b4c724cc73d74111b7d42fc985ca7f93
…1.3 (googleapis#975) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:libraries-bom](https://cloud.google.com/java/docs/bom) ([source](https://togithub.com/googleapis/java-cloud-bom)) | `26.1.2` -> `26.1.3` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.3/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.3/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.3/compatibility-slim/26.1.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.3/confidence-slim/26.1.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-containeranalysis). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMTkuMSIsInVwZGF0ZWRJblZlciI6IjMyLjIxOS4xIn0=-->
…1.3 (googleapis#975) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:libraries-bom](https://cloud.google.com/java/docs/bom) ([source](https://togithub.com/googleapis/java-cloud-bom)) | `26.1.2` -> `26.1.3` | [![age](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.3/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.3/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.3/compatibility-slim/26.1.2)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/maven/com.google.cloud:libraries-bom/26.1.3/confidence-slim/26.1.2)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-speech). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMTkuMSIsInVwZGF0ZWRJblZlciI6IjMyLjIxOS4xIn0=-->
🤖 I have created a release *beep* *boop* --- ### Updating meta-information for bleeding-edge SNAPSHOT release. --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
A CountBytes examples that reads through the provided file (using NIO), counting the bytes.
It also reports elapsed time, allowing for a simple form of benchmarking.
Amusingly, it currently says that the file sizes are off by one: it sees one fewer bytes than Files.size() reports. This is also noticeably slower than gsutil (perhaps because it's single-threaded?).
Sample output: