Skip to content

Commit

Permalink
Updating dynamic example on the readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
robinbernon committed Mar 30, 2021
1 parent edd002f commit 75c4a17
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,27 @@ This is typed, so faster, and it goes an analytics step further also, prints top
```rust
use amadeus::prelude::*;
use std::error::Error;
use amadeus::helpers::{FilterNullsAndDoubleUnwrap, GetFieldFromValue};
use amadeus::amadeus_parquet::get_row_predicate;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let pool = ThreadPool::new(None, None)?;

let column_name = "uri".to_string();

let rows = Parquet::new(ParquetDirectory::new(S3Directory::new_with(
AwsRegion::UsEast1,
"us-east-1.data-analytics",
"cflogworkshop/optimized/cf-accesslogs/",
AwsCredentials::Anonymous,
)), None)
)), get_row_predicate(vec![column_name.clone()]))
.await?;

let top_pages = rows
.par_stream()
.map(|row: Result<Value, _>| {
let row = row.ok()?.into_group().ok()?;
row.get("uri")?.clone().into_url().ok()
})
.filter(|row| row.is_some())
.map(Option::unwrap)
.get_field_from_value::<Option<String>>(column_name.clone())
.filter_nulls_and_double_unwrap()
.most_frequent(&pool, 100, 0.99, 0.002)
.await;

Expand Down

0 comments on commit 75c4a17

Please sign in to comment.