Commits

Kirill Simonov committed f76d91f

Refactoring functions.

Somewhat reduced proliferation of signatures by using the same signature
for an abstract polymorphic function and its most common concrete
instance.

Comments (0)

Files changed (4)

src/htsql/tr/fn/bind.py

                         SortDirectionSig, LimitSig, SortSig, NullSig, TrueSig,
                         FalseSig, CastSig, DateSig, EqualSig, AmongSig,
                         TotallyEqualSig, AndSig, OrSig, NotSig, CompareSig,
-                        AddSig, NumericAddSig, ConcatenateSig,
-                        DateIncrementSig, SubtractSig, NumericSubtractSig,
-                        DateDecrementSig, DateDifferenceSig, MultiplySig,
-                        NumericMultiplySig, DivideSig, NumericDivideSig,
-                        IsNullSig, NullIfSig, IfNullSig, IfSig, SwitchSig,
-                        KeepPolaritySig, ReversePolaritySig,
-                        NumericKeepPolaritySig, NumericReversePolaritySig,
-                        RoundSig, RoundToSig, LengthSig, StringLengthSig,
-                        ContainsSig, StringContainsSig, ExistsSig, EverySig,
+                        AddSig, ConcatenateSig, DateIncrementSig,
+                        SubtractSig, DateDecrementSig, DateDifferenceSig,
+                        MultiplySig, DivideSig, IsNullSig, NullIfSig,
+                        IfNullSig, IfSig, SwitchSig, KeepPolaritySig,
+                        ReversePolaritySig, RoundSig, RoundToSig, LengthSig,
+                        ContainsSig, ExistsSig, EverySig,
                         UnarySig, CountSig, MinSig, MaxSig, SumSig, AvgSig)
 import sys
 
 class CorrelateIntegerAdd(Correlate):
 
     correlates(AddSig, (IntegerDomain, IntegerDomain))
-    signature = NumericAddSig
+    signature = AddSig
     domains = [IntegerDomain(), IntegerDomain()]
     codomain = IntegerDomain()
 
     correlates(AddSig, (IntegerDomain, DecimalDomain),
                        (DecimalDomain, IntegerDomain),
                        (DecimalDomain, DecimalDomain))
-    signature = NumericAddSig
+    signature = AddSig
     domains = [DecimalDomain(), DecimalDomain()]
     codomain = DecimalDomain()
 
                        (FloatDomain, IntegerDomain),
                        (FloatDomain, DecimalDomain),
                        (FloatDomain, FloatDomain))
-    signature = NumericAddSig
+    signature = AddSig
     domains = [FloatDomain(), FloatDomain()]
     codomain = FloatDomain()
 
 class CorrelateIntegerSubtract(Correlate):
 
     correlates(SubtractSig, (IntegerDomain, IntegerDomain))
-    signature = NumericSubtractSig
+    signature = SubtractSig
     domains = [IntegerDomain(), IntegerDomain()]
     codomain = IntegerDomain()
 
     correlates(SubtractSig, (IntegerDomain, DecimalDomain),
                             (DecimalDomain, IntegerDomain),
                             (DecimalDomain, DecimalDomain))
-    signature = NumericSubtractSig
+    signature = SubtractSig
     domains = [DecimalDomain(), DecimalDomain()]
     codomain = DecimalDomain()
 
                             (FloatDomain, IntegerDomain),
                             (FloatDomain, DecimalDomain),
                             (FloatDomain, FloatDomain))
-    signature = NumericSubtractSig
+    signature = SubtractSig
     domains = [FloatDomain(), FloatDomain()]
     codomain = FloatDomain()
 
 class CorrelateIntegerMultiply(Correlate):
 
     correlates(MultiplySig, (IntegerDomain, IntegerDomain))
-    signature = NumericMultiplySig
+    signature = MultiplySig
     domains = [IntegerDomain(), IntegerDomain()]
     codomain = IntegerDomain()
 
     correlates(MultiplySig, (IntegerDomain, DecimalDomain),
                             (DecimalDomain, IntegerDomain),
                             (DecimalDomain, DecimalDomain))
-    signature = NumericMultiplySig
+    signature = MultiplySig
     domains = [DecimalDomain(), DecimalDomain()]
     codomain = DecimalDomain()
 
                             (FloatDomain, IntegerDomain),
                             (FloatDomain, DecimalDomain),
                             (FloatDomain, FloatDomain))
-    signature = NumericMultiplySig
+    signature = MultiplySig
     domains = [FloatDomain(), FloatDomain()]
     codomain = FloatDomain()
 
                           (IntegerDomain, DecimalDomain),
                           (DecimalDomain, IntegerDomain),
                           (DecimalDomain, DecimalDomain))
-    signature = NumericDivideSig
+    signature = DivideSig
     domains = [DecimalDomain(), DecimalDomain()]
     codomain = DecimalDomain()
 
                           (FloatDomain, IntegerDomain),
                           (FloatDomain, DecimalDomain),
                           (FloatDomain, FloatDomain))
-    signature = NumericDivideSig
+    signature = DivideSig
     domains = [FloatDomain(), FloatDomain()]
     codomain = FloatDomain()
 
 class CorrelateIntegerKeepPolarity(Correlate):
 
     correlates(KeepPolaritySig, IntegerDomain)
-    signature = NumericKeepPolaritySig
+    signature = KeepPolaritySig
     domains = [IntegerDomain()]
     codomain = IntegerDomain()
 
 class CorrelateDecimalKeepPolarity(Correlate):
 
     correlates(KeepPolaritySig, DecimalDomain)
-    signature = NumericKeepPolaritySig
+    signature = KeepPolaritySig
     domains = [DecimalDomain()]
     codomain = DecimalDomain()
 
 class CorrelateFloatKeepPolarity(Correlate):
 
     correlates(KeepPolaritySig, FloatDomain)
-    signature = NumericKeepPolaritySig
+    signature = KeepPolaritySig
     domains = [FloatDomain()]
     codomain = FloatDomain()
 
 class CorrelateIntegerReversePolarity(Correlate):
 
     correlates(ReversePolaritySig, IntegerDomain)
-    signature = NumericReversePolaritySig
+    signature = ReversePolaritySig
     domains = [IntegerDomain()]
     codomain = IntegerDomain()
 
 class CorrelateDecimalReversePolarity(Correlate):
 
     correlates(ReversePolaritySig, DecimalDomain)
-    signature = NumericReversePolaritySig
+    signature = ReversePolaritySig
     domains = [DecimalDomain()]
     codomain = DecimalDomain()
 
 class CorrelateFloatReversePolarity(Correlate):
 
     correlates(ReversePolaritySig, FloatDomain)
-    signature = NumericReversePolaritySig
+    signature = ReversePolaritySig
     domains = [FloatDomain()]
     codomain = FloatDomain()
 
 
     correlates(LengthSig, StringDomain,
                           UntypedDomain)
-    signature = StringLengthSig
+    signature = LengthSig
     domains = [StringDomain()]
     codomain = IntegerDomain()
 
                             (StringDomain, UntypedDomain),
                             (UntypedDomain, StringDomain),
                             (UntypedDomain, UntypedDomain))
-    signature = StringContainsSig
+    signature = ContainsSig
     domains = [StringDomain(), StringDomain()]
     codomain = BooleanDomain()
 

src/htsql/tr/fn/dump.py

 
 from ...adapter import adapts
 from ..dump import DumpBySignature
-from .signature import (NumericAddSig, ConcatenateSig, DateIncrementSig,
-                        NumericSubtractSig, DateDecrementSig,
-                        DateDifferenceSig, NumericMultiplySig,
-                        NumericDivideSig, IfSig, SwitchSig,
-                        AmongSig, CompareSig, NumericReversePolaritySig,
-                        RoundSig, RoundToSig, StringLengthSig,
+from .signature import (AddSig, ConcatenateSig, DateIncrementSig,
+                        SubtractSig, DateDecrementSig, DateDifferenceSig,
+                        MultiplySig, DivideSig, IfSig, SwitchSig,
+                        AmongSig, CompareSig, ReversePolaritySig,
+                        RoundSig, RoundToSig, LengthSig,
                         WrapExistsSig, TakeCountSig, TakeMinSig, TakeMaxSig,
                         TakeSumSig, TakeAvgSig)
 
         self.state.format(self.template, self.arguments, self.signature)
 
 
-class DumpNumericAdd(DumpFunction):
+class DumpAdd(DumpFunction):
 
-    adapts(NumericAddSig)
+    adapts(AddSig)
     template = "({lop} + {rop})"
 
 
-class DumpNumericSubtract(DumpFunction):
+class DumpSubtract(DumpFunction):
 
-    adapts(NumericSubtractSig)
+    adapts(SubtractSig)
     template = "({lop} - {rop})"
 
 
-class DumpNumericMultiply(DumpFunction):
+class DumpMultiply(DumpFunction):
 
-    adapts(NumericMultiplySig)
+    adapts(MultiplySig)
     template = "({lop} * {rop})"
 
 
-class DumpNumericDivide(DumpFunction):
+class DumpDivide(DumpFunction):
 
-    adapts(NumericDivideSig)
+    adapts(DivideSig)
     template = "({lop} / {rop})"
 
 
 
 class DumpReversePolarity(DumpFunction):
 
-    adapts(NumericReversePolaritySig)
+    adapts(ReversePolaritySig)
     template = "(- {op})"
 
 
     template = "ROUND({op}, {precision})"
 
 
-class DumpStringLength(DumpFunction):
+class DumpLength(DumpFunction):
 
-    adapts(StringLengthSig)
+    adapts(LengthSig)
     template = "CHARACTER_LENGTH({op})"
 
 

src/htsql/tr/fn/reduce.py

 from ..frame import (IsNullPhrase, NullIfPhrase, IfNullPhrase,
                      LiteralPhrase, FormulaPhrase)
 from .signature import (IsNullSig, NullIfSig, IfNullSig,
-                        NumericKeepPolaritySig, ConcatenateSig)
+                        KeepPolaritySig, ConcatenateSig)
 
 
 class ReduceIsNull(ReduceBySignature):
 
 class ReduceKeepPolaritySig(ReduceBySignature):
 
-    adapts(NumericKeepPolaritySig)
+    adapts(KeepPolaritySig)
 
     def __call__(self):
         return self.state.reduce(self.phrase.op)

src/htsql/tr/fn/signature.py

     pass
 
 
-class NumericAddSig(AddSig):
-    pass
-
-
 class ConcatenateSig(AddSig):
     pass
 
     pass
 
 
-class NumericSubtractSig(SubtractSig):
-    pass
-
-
 class DateDecrementSig(SubtractSig):
     pass
 
     pass
 
 
-class NumericMultiplySig(MultiplySig):
-    pass
-
-
 class DivideSig(BinarySig):
     pass
 
 
-class NumericDivideSig(DivideSig):
-    pass
-
-
 class KeepPolaritySig(UnarySig):
     pass
 
     pass
 
 
-class NumericKeepPolaritySig(KeepPolaritySig):
-    pass
-
-
-class NumericReversePolaritySig(ReversePolaritySig):
-    pass
-
-
 class RoundSig(UnarySig):
     pass
 
     pass
 
 
-class StringLengthSig(LengthSig):
-    pass
-
-
 class ContainsSig(BinarySig, PolarSig):
     pass
 
 
-class StringContainsSig(ContainsSig):
-    pass
-
-
 class QuantifySig(PolarSig):
 
     slots = [
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.