{-# 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.BinaryColumnStatisticsData
-- 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.BinaryColumnStatisticsData where

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

-- | Defines column statistics supported for bit sequence data values.
--
-- /See:/ 'newBinaryColumnStatisticsData' smart constructor.
data BinaryColumnStatisticsData = BinaryColumnStatisticsData'
  { -- | The size of the longest bit sequence in the column.
    BinaryColumnStatisticsData -> Natural
maximumLength :: Prelude.Natural,
    -- | The average bit sequence length in the column.
    BinaryColumnStatisticsData -> Double
averageLength :: Prelude.Double,
    -- | The number of null values in the column.
    BinaryColumnStatisticsData -> Natural
numberOfNulls :: Prelude.Natural
  }
  deriving (BinaryColumnStatisticsData -> BinaryColumnStatisticsData -> Bool
(BinaryColumnStatisticsData -> BinaryColumnStatisticsData -> Bool)
-> (BinaryColumnStatisticsData
    -> BinaryColumnStatisticsData -> Bool)
-> Eq BinaryColumnStatisticsData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BinaryColumnStatisticsData -> BinaryColumnStatisticsData -> Bool
$c/= :: BinaryColumnStatisticsData -> BinaryColumnStatisticsData -> Bool
== :: BinaryColumnStatisticsData -> BinaryColumnStatisticsData -> Bool
$c== :: BinaryColumnStatisticsData -> BinaryColumnStatisticsData -> Bool
Prelude.Eq, ReadPrec [BinaryColumnStatisticsData]
ReadPrec BinaryColumnStatisticsData
Int -> ReadS BinaryColumnStatisticsData
ReadS [BinaryColumnStatisticsData]
(Int -> ReadS BinaryColumnStatisticsData)
-> ReadS [BinaryColumnStatisticsData]
-> ReadPrec BinaryColumnStatisticsData
-> ReadPrec [BinaryColumnStatisticsData]
-> Read BinaryColumnStatisticsData
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BinaryColumnStatisticsData]
$creadListPrec :: ReadPrec [BinaryColumnStatisticsData]
readPrec :: ReadPrec BinaryColumnStatisticsData
$creadPrec :: ReadPrec BinaryColumnStatisticsData
readList :: ReadS [BinaryColumnStatisticsData]
$creadList :: ReadS [BinaryColumnStatisticsData]
readsPrec :: Int -> ReadS BinaryColumnStatisticsData
$creadsPrec :: Int -> ReadS BinaryColumnStatisticsData
Prelude.Read, Int -> BinaryColumnStatisticsData -> ShowS
[BinaryColumnStatisticsData] -> ShowS
BinaryColumnStatisticsData -> String
(Int -> BinaryColumnStatisticsData -> ShowS)
-> (BinaryColumnStatisticsData -> String)
-> ([BinaryColumnStatisticsData] -> ShowS)
-> Show BinaryColumnStatisticsData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BinaryColumnStatisticsData] -> ShowS
$cshowList :: [BinaryColumnStatisticsData] -> ShowS
show :: BinaryColumnStatisticsData -> String
$cshow :: BinaryColumnStatisticsData -> String
showsPrec :: Int -> BinaryColumnStatisticsData -> ShowS
$cshowsPrec :: Int -> BinaryColumnStatisticsData -> ShowS
Prelude.Show, (forall x.
 BinaryColumnStatisticsData -> Rep BinaryColumnStatisticsData x)
-> (forall x.
    Rep BinaryColumnStatisticsData x -> BinaryColumnStatisticsData)
-> Generic BinaryColumnStatisticsData
forall x.
Rep BinaryColumnStatisticsData x -> BinaryColumnStatisticsData
forall x.
BinaryColumnStatisticsData -> Rep BinaryColumnStatisticsData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BinaryColumnStatisticsData x -> BinaryColumnStatisticsData
$cfrom :: forall x.
BinaryColumnStatisticsData -> Rep BinaryColumnStatisticsData x
Prelude.Generic)

-- |
-- Create a value of 'BinaryColumnStatisticsData' 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:
--
-- 'maximumLength', 'binaryColumnStatisticsData_maximumLength' - The size of the longest bit sequence in the column.
--
-- 'averageLength', 'binaryColumnStatisticsData_averageLength' - The average bit sequence length in the column.
--
-- 'numberOfNulls', 'binaryColumnStatisticsData_numberOfNulls' - The number of null values in the column.
newBinaryColumnStatisticsData ::
  -- | 'maximumLength'
  Prelude.Natural ->
  -- | 'averageLength'
  Prelude.Double ->
  -- | 'numberOfNulls'
  Prelude.Natural ->
  BinaryColumnStatisticsData
newBinaryColumnStatisticsData :: Natural -> Double -> Natural -> BinaryColumnStatisticsData
newBinaryColumnStatisticsData
  Natural
pMaximumLength_
  Double
pAverageLength_
  Natural
pNumberOfNulls_ =
    BinaryColumnStatisticsData' :: Natural -> Double -> Natural -> BinaryColumnStatisticsData
BinaryColumnStatisticsData'
      { $sel:maximumLength:BinaryColumnStatisticsData' :: Natural
maximumLength =
          Natural
pMaximumLength_,
        $sel:averageLength:BinaryColumnStatisticsData' :: Double
averageLength = Double
pAverageLength_,
        $sel:numberOfNulls:BinaryColumnStatisticsData' :: Natural
numberOfNulls = Natural
pNumberOfNulls_
      }

-- | The size of the longest bit sequence in the column.
binaryColumnStatisticsData_maximumLength :: Lens.Lens' BinaryColumnStatisticsData Prelude.Natural
binaryColumnStatisticsData_maximumLength :: (Natural -> f Natural)
-> BinaryColumnStatisticsData -> f BinaryColumnStatisticsData
binaryColumnStatisticsData_maximumLength = (BinaryColumnStatisticsData -> Natural)
-> (BinaryColumnStatisticsData
    -> Natural -> BinaryColumnStatisticsData)
-> Lens
     BinaryColumnStatisticsData
     BinaryColumnStatisticsData
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BinaryColumnStatisticsData' {Natural
maximumLength :: Natural
$sel:maximumLength:BinaryColumnStatisticsData' :: BinaryColumnStatisticsData -> Natural
maximumLength} -> Natural
maximumLength) (\s :: BinaryColumnStatisticsData
s@BinaryColumnStatisticsData' {} Natural
a -> BinaryColumnStatisticsData
s {$sel:maximumLength:BinaryColumnStatisticsData' :: Natural
maximumLength = Natural
a} :: BinaryColumnStatisticsData)

-- | The average bit sequence length in the column.
binaryColumnStatisticsData_averageLength :: Lens.Lens' BinaryColumnStatisticsData Prelude.Double
binaryColumnStatisticsData_averageLength :: (Double -> f Double)
-> BinaryColumnStatisticsData -> f BinaryColumnStatisticsData
binaryColumnStatisticsData_averageLength = (BinaryColumnStatisticsData -> Double)
-> (BinaryColumnStatisticsData
    -> Double -> BinaryColumnStatisticsData)
-> Lens
     BinaryColumnStatisticsData BinaryColumnStatisticsData Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BinaryColumnStatisticsData' {Double
averageLength :: Double
$sel:averageLength:BinaryColumnStatisticsData' :: BinaryColumnStatisticsData -> Double
averageLength} -> Double
averageLength) (\s :: BinaryColumnStatisticsData
s@BinaryColumnStatisticsData' {} Double
a -> BinaryColumnStatisticsData
s {$sel:averageLength:BinaryColumnStatisticsData' :: Double
averageLength = Double
a} :: BinaryColumnStatisticsData)

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

instance Core.FromJSON BinaryColumnStatisticsData where
  parseJSON :: Value -> Parser BinaryColumnStatisticsData
parseJSON =
    String
-> (Object -> Parser BinaryColumnStatisticsData)
-> Value
-> Parser BinaryColumnStatisticsData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BinaryColumnStatisticsData"
      ( \Object
x ->
          Natural -> Double -> Natural -> BinaryColumnStatisticsData
BinaryColumnStatisticsData'
            (Natural -> Double -> Natural -> BinaryColumnStatisticsData)
-> Parser Natural
-> Parser (Double -> Natural -> BinaryColumnStatisticsData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaximumLength")
            Parser (Double -> Natural -> BinaryColumnStatisticsData)
-> Parser Double -> Parser (Natural -> BinaryColumnStatisticsData)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AverageLength")
            Parser (Natural -> BinaryColumnStatisticsData)
-> Parser Natural -> Parser BinaryColumnStatisticsData
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")
      )

instance Prelude.Hashable BinaryColumnStatisticsData

instance Prelude.NFData BinaryColumnStatisticsData

instance Core.ToJSON BinaryColumnStatisticsData where
  toJSON :: BinaryColumnStatisticsData -> Value
toJSON BinaryColumnStatisticsData' {Double
Natural
numberOfNulls :: Natural
averageLength :: Double
maximumLength :: Natural
$sel:numberOfNulls:BinaryColumnStatisticsData' :: BinaryColumnStatisticsData -> Natural
$sel:averageLength:BinaryColumnStatisticsData' :: BinaryColumnStatisticsData -> Double
$sel:maximumLength:BinaryColumnStatisticsData' :: BinaryColumnStatisticsData -> Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"MaximumLength" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
maximumLength),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AverageLength" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
averageLength),
            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)
          ]
      )