Skip to content

Commit

Permalink
remove some dependences on unstable features
Browse files Browse the repository at this point in the history
  • Loading branch information
alecmocatta committed Jul 5, 2020
1 parent bdd5949 commit d8119f2
Show file tree
Hide file tree
Showing 20 changed files with 164 additions and 134 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pin-project = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_closure = "0.2"
serde_traitobject = { version = "0.2", optional = true }
tokio = { version = "0.2", features = ["rt-threaded", "rt-util"] }
tokio = { version = "0.2", features = ["rt-threaded", "rt-util", "blocking"] }

[dev-dependencies]
either = { version = "1.5", features = ["serde"] }
Expand Down
1 change: 1 addition & 0 deletions amadeus-aws/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ serde_closure = "0.2"
serde = { version = "1.0", features = ["derive"] }
tokio = "0.2"
url = { version = "2.1", features = ["serde"] }
vec-utils = "0.2"

# dependency of rusoto_core/hyper-tls/native-tls; ensure it's vendored to simplify cross-compilation
[target.'cfg(not(any(target_os = "windows", target_os = "macos", target_os = "ios")))'.dependencies]
Expand Down
5 changes: 2 additions & 3 deletions amadeus-aws/src/cloudfront.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use serde_closure::*;
use std::{
convert::identity, io::{self}, time::Duration
};
use vec_utils::VecExt;

use amadeus_core::{
into_par_stream::IntoDistributedStream, par_stream::DistributedStream, util::{DistParStream, ResultExpandIter}, Source
Expand Down Expand Up @@ -39,9 +40,7 @@ impl Cloudfront {

let objects = list(&client, &bucket, &prefix)
.await?
.into_iter()
.map(|object: Object| object.key.unwrap())
.collect();
.map(|object: Object| object.key.unwrap());

Ok(Self {
region,
Expand Down
17 changes: 0 additions & 17 deletions amadeus-derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
// 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.

#![doc(html_root_url = "https://docs.rs/amadeus-derive/0.2.5")]
#![recursion_limit = "400"]
#![allow(clippy::useless_let_if_seq)]
Expand Down
2 changes: 1 addition & 1 deletion amadeus-parquet/src/internal/file/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ mod tests {
let mut def_levels = Some(vec![0; batch_size]);
let mut rep_levels = None::<Vec<i16>>;

for col_reader in readers.into_iter() {
for col_reader in readers {
match col_reader {
r @ ColumnReader::Int64ColumnReader(..) => {
let mut data_collected = Vec::with_capacity(num_rows);
Expand Down
42 changes: 0 additions & 42 deletions amadeus-parquet/src/internal/mod.rs
Original file line number Diff line number Diff line change
@@ -1,45 +1,3 @@
// 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.

//! An Apache Parquet implementation in Rust.
//!
//! **[Crates.io](https://crates.io/crates/amadeus-parquet) │ [Repo](https://github.com/constellation-rs/amadeus)**

// #![doc(html_root_url = "https://docs.rs/amadeus-parquet/0.1.0")]
// #![feature(
// specialization,
// type_alias_impl_trait,
// bufreader_seek_relative,
// read_initializer
// )]
#![warn(
// missing_copy_implementations,
// missing_debug_implementations,
// missing_docs,
// trivial_casts,
// trivial_numeric_casts,
unused_import_braces,
unused_qualifications,
unused_results,
// clippy::pedantic
)]
// from https://github.com/rust-unofficial/patterns/blob/master/anti_patterns/deny-warnings.md
#![allow(dead_code, clippy::all)]

#[macro_use]
pub mod errors;
pub mod basic;
Expand Down
2 changes: 1 addition & 1 deletion amadeus-parquet/src/internal/record/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl Reader for ValueReader {
}
ValueReader::ByteArray(ref mut reader) => reader
.read(def_level, rep_level)
.map(|vec| Value::List(vec.into_iter().map(Value::from).collect())),
.map(|vec| Value::List(vec.map(Value::from))),
ValueReader::Bson(ref mut reader) => reader.read(def_level, rep_level).map(Value::Bson),
ValueReader::String(ref mut reader) => {
reader.read(def_level, rep_level).map(Value::String)
Expand Down
16 changes: 15 additions & 1 deletion amadeus-parquet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@
#![feature(specialization)]
#![feature(type_alias_impl_trait)]
#![cfg_attr(test, feature(test))]
#![allow(incomplete_features)]
#![warn(
// missing_copy_implementations,
// missing_debug_implementations,
// missing_docs,
// trivial_casts,
// trivial_numeric_casts,
unused_import_braces,
unused_qualifications,
unused_results,
// unreachable_pub,
// clippy::pedantic
)]
// from https://github.com/rust-unofficial/patterns/blob/master/anti_patterns/deny-warnings.md
#![allow(dead_code, incomplete_features, clippy::all)]

#[cfg(test)]
extern crate test;

Expand Down
1 change: 1 addition & 0 deletions amadeus-serde/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ serde_bytes = "0.11"
serde_closure = "0.2"
serde_json = "1.0"
sum = { version = "0.1", features = ["serde"] }
vec-utils = "0.2"
5 changes: 3 additions & 2 deletions amadeus-serde/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use serde::{
use std::{
collections::HashMap, fmt, hash::{BuildHasher, Hash}, str, sync::Arc
};
use vec_utils::VecExt;

use amadeus_types::{
Bson, Data, Date, DateTime, DateTimeWithoutTimezone, DateWithoutTimezone, Decimal, Enum, Group, IpAddr, Json, List, SchemaIncomplete, Time, TimeWithoutTimezone, Timezone, Url, Value, ValueRequired, Webpage
Expand Down Expand Up @@ -171,7 +172,7 @@ where
S: Serializer,
{
let mut serializer = serializer.serialize_seq(Some(self.len()))?;
for item in self.clone().into_iter() {
for item in self.clone() {
serializer.serialize_element(&SerdeSerialize(&item))?;
}
serializer.end()
Expand Down Expand Up @@ -488,7 +489,7 @@ macro_rules! array {
D: Deserializer<'de>,
{
let self_: [SerdeDeserialize<T>; $i] = serde::Deserialize::deserialize(deserializer)?;
let self_: Box<Self> = std::array::IntoIter::new(self_).map(|a|a.0).collect::<Vec<T>>().into_boxed_slice().try_into().unwrap();
let self_: Box<Self> = <Vec<SerdeDeserialize<T>>>::from(self_).map(|a|a.0).into_boxed_slice().try_into().unwrap();
Ok(*self_)
}
}
Expand Down
1 change: 0 additions & 1 deletion amadeus-serde/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![doc(html_root_url = "https://docs.rs/amadeus-serde/0.2.5")]
#![feature(array_value_iter)]
#![feature(specialization)]
#![feature(type_alias_impl_trait)]
#![allow(incomplete_features)]
Expand Down
1 change: 1 addition & 0 deletions amadeus-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ once_cell = "1.0"
ordered-float = "1.0"
serde = { version = "1.0", features = ["derive"] }
url = { version = "2.1", features = ["serde"] }
vec-utils = "0.2"
8 changes: 4 additions & 4 deletions amadeus-types/src/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
cmp::Ordering, fmt::{self, Debug}, ops::Index, slice::SliceIndex, str, sync::Arc
};

use super::{AmadeusOrd, Downcast, DowncastError, DowncastFrom, Value};
use super::{util::IteratorExt, AmadeusOrd, Downcast, DowncastError, DowncastFrom, Value};

/// Corresponds to Parquet groups of named fields.
///
Expand Down Expand Up @@ -74,7 +74,7 @@ impl<'de> Deserialize<'de> for Group {
// impl From<Group> for internal::record::types::Group {
// fn from(group: Group) -> Self {
// let field_names = group.field_names();
// Self::new(group.into_fields().into_iter().map(Into::into).collect(), field_names)
// Self::new(group.into_fields().map(Into::into), field_names)
// }
// }
impl<I> Index<I> for Group
Expand Down Expand Up @@ -106,14 +106,14 @@ impl AmadeusOrd for Group {
.iter()
.map(|(name, _index)| name)
.zip(&self.fields)
.cmp_by(
.cmp_by_(
b.iter().map(|(name, _index)| name).zip(&other.fields),
|a, b| a.amadeus_cmp(&b),
),
(None, None) => self
.fields
.iter()
.cmp_by(&other.fields, AmadeusOrd::amadeus_cmp),
.cmp_by_(&other.fields, AmadeusOrd::amadeus_cmp),
(Some(_), None) => Ordering::Less,
(None, Some(_)) => Ordering::Greater,
}
Expand Down
3 changes: 1 addition & 2 deletions amadeus-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![doc(html_root_url = "https://docs.rs/amadeus-types/0.2.5")]
#![feature(iter_order_by)]
#![feature(min_specialization)]

//! Implementations of Rust types that correspond to Parquet logical types.
//! [`Record`](super::Record) is implemented for each of them.
Expand Down Expand Up @@ -58,6 +56,7 @@ mod http;
mod list;
mod ord;
mod time;
mod util;
mod value;
mod value_required;

Expand Down
26 changes: 21 additions & 5 deletions amadeus-types/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{
cmp::Ordering, fmt::{self, Debug}, hash::{Hash, Hasher}, iter::FromIterator, mem::ManuallyDrop, ops::{Deref, DerefMut}, panic::{RefUnwindSafe, UnwindSafe}
};

use super::{AmadeusOrd, Data};
use super::{util::IteratorExt, AmadeusOrd, Data};
use amadeus_core::{
par_sink::{ExtendReducer, FromDistributedStream, FromParallelStream, PushReducer}, pool::ProcessSend
};
Expand Down Expand Up @@ -49,6 +49,22 @@ impl<T: Data> List<T> {
// pub fn iter(&self) -> <&Self as IntoIterator>::IntoIter {
// self.into_iter()
// }
#[inline(always)]
pub fn map<F, U: Data>(self, f: F) -> List<U>
where
F: FnMut(T) -> U,
{
// TODO
self.into_iter().map(f).collect()
}
#[inline(always)]
pub fn try_map<F, U: Data, E>(self, f: F) -> Result<List<U>, E>
where
F: FnMut(T) -> Result<U, E>,
{
// TODO
self.into_iter().map(f).collect()
}
}
impl<T: Data> Default for List<T> {
#[inline(always)]
Expand Down Expand Up @@ -126,7 +142,7 @@ where
fn eq(&self, other: &List<U>) -> bool {
self.clone()
.into_iter()
.eq_by(other.clone().into_iter(), |a, b| a.eq(&b))
.eq_by_(other.clone().into_iter(), |a, b| a.eq(&b))
}
}
impl<T: Data> Eq for List<T> where T: Eq {}
Expand All @@ -138,7 +154,7 @@ where
fn partial_cmp(&self, other: &List<U>) -> Option<Ordering> {
self.clone()
.into_iter()
.partial_cmp_by(other.clone().into_iter(), |a, b| a.partial_cmp(&b))
.partial_cmp_by_(other.clone().into_iter(), |a, b| a.partial_cmp(&b))
}
}
impl<T: Data> Ord for List<T>
Expand All @@ -149,7 +165,7 @@ where
fn cmp(&self, other: &Self) -> Ordering {
self.clone()
.into_iter()
.cmp_by(other.clone().into_iter(), |a, b| a.cmp(&b))
.cmp_by_(other.clone().into_iter(), |a, b| a.cmp(&b))
}
}
impl<T: Data> AmadeusOrd for List<T>
Expand All @@ -160,7 +176,7 @@ where
fn amadeus_cmp(&self, other: &Self) -> Ordering {
self.clone()
.into_iter()
.cmp_by(other.clone().into_iter(), |a, b| a.amadeus_cmp(&b))
.cmp_by_(other.clone().into_iter(), |a, b| a.amadeus_cmp(&b))
}
}
impl<T: Data> Hash for List<T>
Expand Down
94 changes: 94 additions & 0 deletions amadeus-types/src/util.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// from https://github.com/rust-lang/rust/blob/0cd7ff7ddfb75a38dca81ad3e76b1e984129e939/src/libcore/iter/traits/iterator.rs

use std::cmp::Ordering;

pub(crate) trait IteratorExt: Iterator {
fn cmp_by_<I, F>(mut self, other: I, mut cmp: F) -> Ordering
where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, I::Item) -> Ordering,
{
let mut other = other.into_iter();

loop {
let x = match self.next() {
None => {
if other.next().is_none() {
return Ordering::Equal;
} else {
return Ordering::Less;
}
}
Some(val) => val,
};

let y = match other.next() {
None => return Ordering::Greater,
Some(val) => val,
};

match cmp(x, y) {
Ordering::Equal => (),
non_eq => return non_eq,
}
}
}
fn partial_cmp_by_<I, F>(mut self, other: I, mut partial_cmp: F) -> Option<Ordering>
where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, I::Item) -> Option<Ordering>,
{
let mut other = other.into_iter();

loop {
let x = match self.next() {
None => {
if other.next().is_none() {
return Some(Ordering::Equal);
} else {
return Some(Ordering::Less);
}
}
Some(val) => val,
};

let y = match other.next() {
None => return Some(Ordering::Greater),
Some(val) => val,
};

match partial_cmp(x, y) {
Some(Ordering::Equal) => (),
non_eq => return non_eq,
}
}
}
fn eq_by_<I, F>(mut self, other: I, mut eq: F) -> bool
where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, I::Item) -> bool,
{
let mut other = other.into_iter();

loop {
let x = match self.next() {
None => return other.next().is_none(),
Some(val) => val,
};

let y = match other.next() {
None => return false,
Some(val) => val,
};

if !eq(x, y) {
return false;
}
}
}
}

impl<I: ?Sized> IteratorExt for I where I: Iterator {}
Loading

0 comments on commit d8119f2

Please sign in to comment.