{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Glue.Types.DoubleColumnStatisticsData
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Glue.Types.DoubleColumnStatisticsData where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Defines column statistics supported for floating-point number data
-- columns.
--
-- /See:/ 'newDoubleColumnStatisticsData' smart constructor.
data DoubleColumnStatisticsData = DoubleColumnStatisticsData'
  { -- | The highest value in the column.
    DoubleColumnStatisticsData -> Maybe Double
maximumValue :: Prelude.Maybe Prelude.Double,
    -- | The lowest value in the column.
    DoubleColumnStatisticsData -> Maybe Double
minimumValue :: Prelude.Maybe Prelude.Double,
    -- | The number of null values in the column.
    DoubleColumnStatisticsData -> Natural
numberOfNulls :: Prelude.Natural,
    -- | The number of distinct values in a column.
    DoubleColumnStatisticsData -> Natural
numberOfDistinctValues :: Prelude.Natural
  }
  deriving (DoubleColumnStatisticsData -> DoubleColumnStatisticsData -> Bool
(DoubleColumnStatisticsData -> DoubleColumnStatisticsData -> Bool)
-> (DoubleColumnStatisticsData
    -> DoubleColumnStatisticsData -> Bool)
-> Eq DoubleColumnStatisticsData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DoubleColumnStatisticsData -> DoubleColumnStatisticsData -> Bool
$c/= :: DoubleColumnStatisticsData -> DoubleColumnStatisticsData -> Bool
== :: DoubleColumnStatisticsData -> DoubleColumnStatisticsData -> Bool
$c== :: DoubleColumnStatisticsData -> DoubleColumnStatisticsData -> Bool
Prelude.Eq, ReadPrec [DoubleColumnStatisticsData]
ReadPrec DoubleColumnStatisticsData
Int -> ReadS DoubleColumnStatisticsData
ReadS [DoubleColumnStatisticsData]
(Int -> ReadS DoubleColumnStatisticsData)
-> ReadS [DoubleColumnStatisticsData]
-> ReadPrec DoubleColumnStatisticsData
-> ReadPrec [DoubleColumnStatisticsData]
-> Read DoubleColumnStatisticsData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DoubleColumnStatisticsData]
$creadListPrec :: ReadPrec [DoubleColumnStatisticsData]
readPrec :: ReadPrec DoubleColumnStatisticsData
$creadPrec :: ReadPrec DoubleColumnStatisticsData
readList :: ReadS [DoubleColumnStatisticsData]
$creadList :: ReadS [DoubleColumnStatisticsData]
readsPrec :: Int -> ReadS DoubleColumnStatisticsData
$creadsPrec :: Int -> ReadS DoubleColumnStatisticsData
Prelude.Read, Int -> DoubleColumnStatisticsData -> ShowS
[DoubleColumnStatisticsData] -> ShowS
DoubleColumnStatisticsData -> String
(Int -> DoubleColumnStatisticsData -> ShowS)
-> (DoubleColumnStatisticsData -> String)
-> ([DoubleColumnStatisticsData] -> ShowS)
-> Show DoubleColumnStatisticsData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DoubleColumnStatisticsData] -> ShowS
$cshowList :: [DoubleColumnStatisticsData] -> ShowS
show :: DoubleColumnStatisticsData -> String
$cshow :: DoubleColumnStatisticsData -> String
showsPrec :: Int -> DoubleColumnStatisticsData -> ShowS
$cshowsPrec :: Int -> DoubleColumnStatisticsData -> ShowS
Prelude.Show, (forall x.
 DoubleColumnStatisticsData -> Rep DoubleColumnStatisticsData x)
-> (forall x.
    Rep DoubleColumnStatisticsData x -> DoubleColumnStatisticsData)
-> Generic DoubleColumnStatisticsData
forall x.
Rep DoubleColumnStatisticsData x -> DoubleColumnStatisticsData
forall x.
DoubleColumnStatisticsData -> Rep DoubleColumnStatisticsData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DoubleColumnStatisticsData x -> DoubleColumnStatisticsData
$cfrom :: forall x.
DoubleColumnStatisticsData -> Rep DoubleColumnStatisticsData x
Prelude.Generic)

-- |
-- Create a value of 'DoubleColumnStatisticsData' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'maximumValue', 'doubleColumnStatisticsData_maximumValue' - The highest value in the column.
--
-- 'minimumValue', 'doubleColumnStatisticsData_minimumValue' - The lowest value in the column.
--
-- 'numberOfNulls', 'doubleColumnStatisticsData_numberOfNulls' - The number of null values in the column.
--
-- 'numberOfDistinctValues', 'doubleColumnStatisticsData_numberOfDistinctValues' - The number of distinct values in a column.
newDoubleColumnStatisticsData ::
  -- | 'numberOfNulls'
  Prelude.Natural ->
  -- | 'numberOfDistinctValues'
  Prelude.Natural ->
  DoubleColumnStatisticsData
newDoubleColumnStatisticsData :: Natural -> Natural -> DoubleColumnStatisticsData
newDoubleColumnStatisticsData
  Natural
pNumberOfNulls_
  Natural
pNumberOfDistinctValues_ =
    DoubleColumnStatisticsData' :: Maybe Double
-> Maybe Double -> Natural -> Natural -> DoubleColumnStatisticsData
DoubleColumnStatisticsData'
      { $sel:maximumValue:DoubleColumnStatisticsData' :: Maybe Double
maximumValue =
          Maybe Double
forall a. Maybe a
Prelude.Nothing,
        $sel:minimumValue:DoubleColumnStatisticsData' :: Maybe Double
minimumValue = Maybe Double
forall a. Maybe a
Prelude.Nothing,
        $sel:numberOfNulls:DoubleColumnStatisticsData' :: Natural
numberOfNulls = Natural
pNumberOfNulls_,
        $sel:numberOfDistinctValues:DoubleColumnStatisticsData' :: Natural
numberOfDistinctValues =
          Natural
pNumberOfDistinctValues_
      }

-- | The highest value in the column.
doubleColumnStatisticsData_maximumValue :: Lens.Lens' DoubleColumnStatisticsData (Prelude.Maybe Prelude.Double)
doubleColumnStatisticsData_maximumValue :: (Maybe Double -> f (Maybe Double))
-> DoubleColumnStatisticsData -> f DoubleColumnStatisticsData
doubleColumnStatisticsData_maximumValue = (DoubleColumnStatisticsData -> Maybe Double)
-> (DoubleColumnStatisticsData
    -> Maybe Double -> DoubleColumnStatisticsData)
-> Lens
     DoubleColumnStatisticsData
     DoubleColumnStatisticsData
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DoubleColumnStatisticsData' {Maybe Double
maximumValue :: Maybe Double
$sel:maximumValue:DoubleColumnStatisticsData' :: DoubleColumnStatisticsData -> Maybe Double
maximumValue} -> Maybe Double
maximumValue) (\s :: DoubleColumnStatisticsData
s@DoubleColumnStatisticsData' {} Maybe Double
a -> DoubleColumnStatisticsData
s {$sel:maximumValue:DoubleColumnStatisticsData' :: Maybe Double
maximumValue = Maybe Double
a} :: DoubleColumnStatisticsData)

-- | The lowest value in the column.
doubleColumnStatisticsData_minimumValue :: Lens.Lens' DoubleColumnStatisticsData (Prelude.Maybe Prelude.Double)
doubleColumnStatisticsData_minimumValue :: (Maybe Double -> f (Maybe Double))
-> DoubleColumnStatisticsData -> f DoubleColumnStatisticsData
doubleColumnStatisticsData_minimumValue = (DoubleColumnStatisticsData -> Maybe Double)
-> (DoubleColumnStatisticsData
    -> Maybe Double -> DoubleColumnStatisticsData)
-> Lens
     DoubleColumnStatisticsData
     DoubleColumnStatisticsData
     (Maybe Double)
     (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DoubleColumnStatisticsData' {Maybe Double
minimumValue :: Maybe Double
$sel:minimumValue:DoubleColumnStatisticsData' :: DoubleColumnStatisticsData -> Maybe Double
minimumValue} -> Maybe Double
minimumValue) (\s :: DoubleColumnStatisticsData
s@DoubleColumnStatisticsData' {} Maybe Double
a -> DoubleColumnStatisticsData
s {$sel:minimumValue:DoubleColumnStatisticsData' :: Maybe Double
minimumValue = Maybe Double
a} :: DoubleColumnStatisticsData)

-- | The number of null values in the column.
doubleColumnStatisticsData_numberOfNulls :: Lens.Lens' DoubleColumnStatisticsData Prelude.Natural
doubleColumnStatisticsData_numberOfNulls :: (Natural -> f Natural)
-> DoubleColumnStatisticsData -> f DoubleColumnStatisticsData
doubleColumnStatisticsData_numberOfNulls = (DoubleColumnStatisticsData -> Natural)
-> (DoubleColumnStatisticsData
    -> Natural -> DoubleColumnStatisticsData)
-> Lens
     DoubleColumnStatisticsData
     DoubleColumnStatisticsData
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DoubleColumnStatisticsData' {Natural
numberOfNulls :: Natural
$sel:numberOfNulls:DoubleColumnStatisticsData' :: DoubleColumnStatisticsData -> Natural
numberOfNulls} -> Natural
numberOfNulls) (\s :: DoubleColumnStatisticsData
s@DoubleColumnStatisticsData' {} Natural
a -> DoubleColumnStatisticsData
s {$sel:numberOfNulls:DoubleColumnStatisticsData' :: Natural
numberOfNulls = Natural
a} :: DoubleColumnStatisticsData)

-- | The number of distinct values in a column.
doubleColumnStatisticsData_numberOfDistinctValues :: Lens.Lens' DoubleColumnStatisticsData Prelude.Natural
doubleColumnStatisticsData_numberOfDistinctValues :: (Natural -> f Natural)
-> DoubleColumnStatisticsData -> f DoubleColumnStatisticsData
doubleColumnStatisticsData_numberOfDistinctValues = (DoubleColumnStatisticsData -> Natural)
-> (DoubleColumnStatisticsData
    -> Natural -> DoubleColumnStatisticsData)
-> Lens
     DoubleColumnStatisticsData
     DoubleColumnStatisticsData
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DoubleColumnStatisticsData' {Natural
numberOfDistinctValues :: Natural
$sel:numberOfDistinctValues:DoubleColumnStatisticsData' :: DoubleColumnStatisticsData -> Natural
numberOfDistinctValues} -> Natural
numberOfDistinctValues) (\s :: DoubleColumnStatisticsData
s@DoubleColumnStatisticsData' {} Natural
a -> DoubleColumnStatisticsData
s {$sel:numberOfDistinctValues:DoubleColumnStatisticsData' :: Natural
numberOfDistinctValues = Natural
a} :: DoubleColumnStatisticsData)

instance Core.FromJSON DoubleColumnStatisticsData where
  parseJSON :: Value -> Parser DoubleColumnStatisticsData
parseJSON =
    String
-> (Object -> Parser DoubleColumnStatisticsData)
-> Value
-> Parser DoubleColumnStatisticsData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DoubleColumnStatisticsData"
      ( \Object
x ->
          Maybe Double
-> Maybe Double -> Natural -> Natural -> DoubleColumnStatisticsData
DoubleColumnStatisticsData'
            (Maybe Double
 -> Maybe Double
 -> Natural
 -> Natural
 -> DoubleColumnStatisticsData)
-> Parser (Maybe Double)
-> Parser
     (Maybe Double -> Natural -> Natural -> DoubleColumnStatisticsData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaximumValue")
            Parser
  (Maybe Double -> Natural -> Natural -> DoubleColumnStatisticsData)
-> Parser (Maybe Double)
-> Parser (Natural -> Natural -> DoubleColumnStatisticsData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MinimumValue")
            Parser (Natural -> Natural -> DoubleColumnStatisticsData)
-> Parser Natural -> Parser (Natural -> DoubleColumnStatisticsData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"NumberOfNulls")
            Parser (Natural -> DoubleColumnStatisticsData)
-> Parser Natural -> Parser DoubleColumnStatisticsData
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"NumberOfDistinctValues")
      )

instance Prelude.Hashable DoubleColumnStatisticsData

instance Prelude.NFData DoubleColumnStatisticsData

instance Core.ToJSON DoubleColumnStatisticsData where
  toJSON :: DoubleColumnStatisticsData -> Value
toJSON DoubleColumnStatisticsData' {Natural
Maybe Double
numberOfDistinctValues :: Natural
numberOfNulls :: Natural
minimumValue :: Maybe Double
maximumValue :: Maybe Double
$sel:numberOfDistinctValues:DoubleColumnStatisticsData' :: DoubleColumnStatisticsData -> Natural
$sel:numberOfNulls:DoubleColumnStatisticsData' :: DoubleColumnStatisticsData -> Natural
$sel:minimumValue:DoubleColumnStatisticsData' :: DoubleColumnStatisticsData -> Maybe Double
$sel:maximumValue:DoubleColumnStatisticsData' :: DoubleColumnStatisticsData -> Maybe Double
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MaximumValue" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
maximumValue,
            (Text
"MinimumValue" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
minimumValue,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"NumberOfNulls" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
numberOfNulls),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"NumberOfDistinctValues"
                  Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
numberOfDistinctValues
              )
          ]
      )