{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Glue.Types.BinaryColumnStatisticsData where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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.
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'
      { $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 :: Lens' BinaryColumnStatisticsData Natural
binaryColumnStatisticsData_maximumLength = 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 :: Lens' BinaryColumnStatisticsData Double
binaryColumnStatisticsData_averageLength = 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 :: Lens' BinaryColumnStatisticsData Natural
binaryColumnStatisticsData_numberOfNulls = 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 Data.FromJSON BinaryColumnStatisticsData where
  parseJSON :: Value -> Parser BinaryColumnStatisticsData
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"BinaryColumnStatisticsData"
      ( \Object
x ->
          Natural -> Double -> Natural -> BinaryColumnStatisticsData
BinaryColumnStatisticsData'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MaximumLength")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AverageLength")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"NumberOfNulls")
      )

instance Prelude.Hashable BinaryColumnStatisticsData where
  hashWithSalt :: Int -> BinaryColumnStatisticsData -> Int
hashWithSalt Int
_salt BinaryColumnStatisticsData' {Double
Natural
numberOfNulls :: Natural
averageLength :: Double
maximumLength :: Natural
$sel:numberOfNulls:BinaryColumnStatisticsData' :: BinaryColumnStatisticsData -> Natural
$sel:averageLength:BinaryColumnStatisticsData' :: BinaryColumnStatisticsData -> Double
$sel:maximumLength:BinaryColumnStatisticsData' :: BinaryColumnStatisticsData -> Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
maximumLength
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
averageLength
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
numberOfNulls

instance Prelude.NFData BinaryColumnStatisticsData where
  rnf :: BinaryColumnStatisticsData -> ()
rnf BinaryColumnStatisticsData' {Double
Natural
numberOfNulls :: Natural
averageLength :: Double
maximumLength :: Natural
$sel:numberOfNulls:BinaryColumnStatisticsData' :: BinaryColumnStatisticsData -> Natural
$sel:averageLength:BinaryColumnStatisticsData' :: BinaryColumnStatisticsData -> Double
$sel:maximumLength:BinaryColumnStatisticsData' :: BinaryColumnStatisticsData -> Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Natural
maximumLength
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
averageLength
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
numberOfNulls

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"MaximumLength" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
maximumLength),
            forall a. a -> Maybe a
Prelude.Just (Key
"AverageLength" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
averageLength),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"NumberOfNulls" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
numberOfNulls)
          ]
      )