{-# 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.StringColumnStatisticsData
-- 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.StringColumnStatisticsData 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 character sequence data values.
--
-- /See:/ 'newStringColumnStatisticsData' smart constructor.
data StringColumnStatisticsData = StringColumnStatisticsData'
  { -- | The size of the longest string in the column.
    StringColumnStatisticsData -> Natural
maximumLength :: Prelude.Natural,
    -- | The average string length in the column.
    StringColumnStatisticsData -> Double
averageLength :: Prelude.Double,
    -- | The number of null values in the column.
    StringColumnStatisticsData -> Natural
numberOfNulls :: Prelude.Natural,
    -- | The number of distinct values in a column.
    StringColumnStatisticsData -> Natural
numberOfDistinctValues :: Prelude.Natural
  }
  deriving (StringColumnStatisticsData -> StringColumnStatisticsData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StringColumnStatisticsData -> StringColumnStatisticsData -> Bool
$c/= :: StringColumnStatisticsData -> StringColumnStatisticsData -> Bool
== :: StringColumnStatisticsData -> StringColumnStatisticsData -> Bool
$c== :: StringColumnStatisticsData -> StringColumnStatisticsData -> Bool
Prelude.Eq, ReadPrec [StringColumnStatisticsData]
ReadPrec StringColumnStatisticsData
Int -> ReadS StringColumnStatisticsData
ReadS [StringColumnStatisticsData]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StringColumnStatisticsData]
$creadListPrec :: ReadPrec [StringColumnStatisticsData]
readPrec :: ReadPrec StringColumnStatisticsData
$creadPrec :: ReadPrec StringColumnStatisticsData
readList :: ReadS [StringColumnStatisticsData]
$creadList :: ReadS [StringColumnStatisticsData]
readsPrec :: Int -> ReadS StringColumnStatisticsData
$creadsPrec :: Int -> ReadS StringColumnStatisticsData
Prelude.Read, Int -> StringColumnStatisticsData -> ShowS
[StringColumnStatisticsData] -> ShowS
StringColumnStatisticsData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StringColumnStatisticsData] -> ShowS
$cshowList :: [StringColumnStatisticsData] -> ShowS
show :: StringColumnStatisticsData -> String
$cshow :: StringColumnStatisticsData -> String
showsPrec :: Int -> StringColumnStatisticsData -> ShowS
$cshowsPrec :: Int -> StringColumnStatisticsData -> ShowS
Prelude.Show, forall x.
Rep StringColumnStatisticsData x -> StringColumnStatisticsData
forall x.
StringColumnStatisticsData -> Rep StringColumnStatisticsData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StringColumnStatisticsData x -> StringColumnStatisticsData
$cfrom :: forall x.
StringColumnStatisticsData -> Rep StringColumnStatisticsData x
Prelude.Generic)

-- |
-- Create a value of 'StringColumnStatisticsData' 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', 'stringColumnStatisticsData_maximumLength' - The size of the longest string in the column.
--
-- 'averageLength', 'stringColumnStatisticsData_averageLength' - The average string length in the column.
--
-- 'numberOfNulls', 'stringColumnStatisticsData_numberOfNulls' - The number of null values in the column.
--
-- 'numberOfDistinctValues', 'stringColumnStatisticsData_numberOfDistinctValues' - The number of distinct values in a column.
newStringColumnStatisticsData ::
  -- | 'maximumLength'
  Prelude.Natural ->
  -- | 'averageLength'
  Prelude.Double ->
  -- | 'numberOfNulls'
  Prelude.Natural ->
  -- | 'numberOfDistinctValues'
  Prelude.Natural ->
  StringColumnStatisticsData
newStringColumnStatisticsData :: Natural
-> Double -> Natural -> Natural -> StringColumnStatisticsData
newStringColumnStatisticsData
  Natural
pMaximumLength_
  Double
pAverageLength_
  Natural
pNumberOfNulls_
  Natural
pNumberOfDistinctValues_ =
    StringColumnStatisticsData'
      { $sel:maximumLength:StringColumnStatisticsData' :: Natural
maximumLength =
          Natural
pMaximumLength_,
        $sel:averageLength:StringColumnStatisticsData' :: Double
averageLength = Double
pAverageLength_,
        $sel:numberOfNulls:StringColumnStatisticsData' :: Natural
numberOfNulls = Natural
pNumberOfNulls_,
        $sel:numberOfDistinctValues:StringColumnStatisticsData' :: Natural
numberOfDistinctValues =
          Natural
pNumberOfDistinctValues_
      }

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

-- | The average string length in the column.
stringColumnStatisticsData_averageLength :: Lens.Lens' StringColumnStatisticsData Prelude.Double
stringColumnStatisticsData_averageLength :: Lens' StringColumnStatisticsData Double
stringColumnStatisticsData_averageLength = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StringColumnStatisticsData' {Double
averageLength :: Double
$sel:averageLength:StringColumnStatisticsData' :: StringColumnStatisticsData -> Double
averageLength} -> Double
averageLength) (\s :: StringColumnStatisticsData
s@StringColumnStatisticsData' {} Double
a -> StringColumnStatisticsData
s {$sel:averageLength:StringColumnStatisticsData' :: Double
averageLength = Double
a} :: StringColumnStatisticsData)

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

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

instance Data.FromJSON StringColumnStatisticsData where
  parseJSON :: Value -> Parser StringColumnStatisticsData
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StringColumnStatisticsData"
      ( \Object
x ->
          Natural
-> Double -> Natural -> Natural -> StringColumnStatisticsData
StringColumnStatisticsData'
            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")
            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
"NumberOfDistinctValues")
      )

instance Prelude.Hashable StringColumnStatisticsData where
  hashWithSalt :: Int -> StringColumnStatisticsData -> Int
hashWithSalt Int
_salt StringColumnStatisticsData' {Double
Natural
numberOfDistinctValues :: Natural
numberOfNulls :: Natural
averageLength :: Double
maximumLength :: Natural
$sel:numberOfDistinctValues:StringColumnStatisticsData' :: StringColumnStatisticsData -> Natural
$sel:numberOfNulls:StringColumnStatisticsData' :: StringColumnStatisticsData -> Natural
$sel:averageLength:StringColumnStatisticsData' :: StringColumnStatisticsData -> Double
$sel:maximumLength:StringColumnStatisticsData' :: StringColumnStatisticsData -> 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
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
numberOfDistinctValues

instance Prelude.NFData StringColumnStatisticsData where
  rnf :: StringColumnStatisticsData -> ()
rnf StringColumnStatisticsData' {Double
Natural
numberOfDistinctValues :: Natural
numberOfNulls :: Natural
averageLength :: Double
maximumLength :: Natural
$sel:numberOfDistinctValues:StringColumnStatisticsData' :: StringColumnStatisticsData -> Natural
$sel:numberOfNulls:StringColumnStatisticsData' :: StringColumnStatisticsData -> Natural
$sel:averageLength:StringColumnStatisticsData' :: StringColumnStatisticsData -> Double
$sel:maximumLength:StringColumnStatisticsData' :: StringColumnStatisticsData -> 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
numberOfDistinctValues

instance Data.ToJSON StringColumnStatisticsData where
  toJSON :: StringColumnStatisticsData -> Value
toJSON StringColumnStatisticsData' {Double
Natural
numberOfDistinctValues :: Natural
numberOfNulls :: Natural
averageLength :: Double
maximumLength :: Natural
$sel:numberOfDistinctValues:StringColumnStatisticsData' :: StringColumnStatisticsData -> Natural
$sel:numberOfNulls:StringColumnStatisticsData' :: StringColumnStatisticsData -> Natural
$sel:averageLength:StringColumnStatisticsData' :: StringColumnStatisticsData -> Double
$sel:maximumLength:StringColumnStatisticsData' :: StringColumnStatisticsData -> 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),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"NumberOfDistinctValues"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
numberOfDistinctValues
              )
          ]
      )