Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Commit

Permalink
Merge branch 'develop' into gh-595-gafferpy
Browse files Browse the repository at this point in the history
  • Loading branch information
GCHQ-83497 committed Apr 16, 2019
2 parents 28121f8 + 5d0a3cd commit d90e128
Show file tree
Hide file tree
Showing 35 changed files with 441 additions and 182 deletions.
2 changes: 1 addition & 1 deletion NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gaffer tools is built using maven. This process will automatically pull in depen
projects below.


Gaffer (uk.gov.gchq.gaffer:gaffer2:1.8.0):
Gaffer (uk.gov.gchq.gaffer:gaffer2:1.9.0):

- Apache License, Version 2.0

Expand Down
2 changes: 1 addition & 1 deletion mini-accumulo-cluster/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>uk.gov.gchq.gaffer</groupId>
<artifactId>gaffer-tools</artifactId>
<version>1.8.0</version>
<version>1.9.1-SNAPSHOT</version>
</parent>

<artifactId>mini-accumulo-cluster</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>uk.gov.gchq.gaffer</groupId>
<artifactId>performance-testing</artifactId>
<version>1.8.0</version>
<version>1.9.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion performance-testing/performance-testing-aws/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>uk.gov.gchq.gaffer</groupId>
<artifactId>performance-testing</artifactId>
<version>1.8.0</version>
<version>1.9.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion performance-testing/performance-testing-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>uk.gov.gchq.gaffer</groupId>
<artifactId>performance-testing</artifactId>
<version>1.8.0</version>
<version>1.9.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion performance-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>uk.gov.gchq.gaffer</groupId>
<artifactId>gaffer-tools</artifactId>
<version>1.8.0</version>
<version>1.9.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<parent>
<groupId>uk.gov.gchq.gaffer</groupId>
<artifactId>gaffer2</artifactId>
<version>1.8.0</version>
<version>1.9.0</version>
</parent>

<artifactId>gaffer-tools</artifactId>
<version>1.8.0</version>
<version>1.9.1-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
Expand All @@ -39,7 +39,7 @@
</modules>

<properties>
<gaffer.version>1.8.0</gaffer.version>
<gaffer.version>1.9.0</gaffer.version>
<scm.url>
https://github.com/gchq/gaffer-tools
</scm.url>
Expand Down
2 changes: 1 addition & 1 deletion python-shell/src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.8.0"
__version__ = "1.9.0"

__title__ = "gafferpy"
__description__ = "Gaffer Python Shell"
Expand Down
2 changes: 1 addition & 1 deletion python-shell/src/gafferpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.8.0"
__version__ = "1.9.0"

__title__ = "gafferpy"
__description__ = "Gaffer Python Shell"
Expand Down
12 changes: 0 additions & 12 deletions python-shell/src/gafferpy/gaffer_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,8 @@ class MatchKey:
LEFT = 'LEFT'
RIGHT = 'RIGHT'

class ResultsWanted:
KEY_ONLY = 'KEY_ONLY'
RELATED_ONLY = 'RELATED_ONLY'
BOTH = 'BOTH'

class MergeType:
NONE = 'NONE'
RELATED_ONLY = 'RELATED_ONLY'
BOTH = 'BOTH'

class JoinType:
FULL = 'FULL'
FULL_INNER = 'FULL_INNER'
FULL_OUTER = 'FULL_OUTER'
OUTER = 'OUTER'
INNER = 'INNER'

Expand Down
47 changes: 46 additions & 1 deletion python-shell/src/gafferpy/gaffer_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ def __init__(self):
def to_json(self):
return super().to_json()

class DictionaryLookup(AbstractFunction):
CLASS = 'uk.gov.gchq.koryphe.impl.function.DictionaryLookup'

def __init__(self, dictionary):
super().__init__(_class_name=self.CLASS)
self.dictionary = dictionary

def to_json(self):
function_json = super().to_json()
function_json["dictionary"] = self.dictionary

return function_json

class ExtractValue(AbstractFunction):
CLASS = 'uk.gov.gchq.koryphe.impl.function.ExtractValue'
Expand Down Expand Up @@ -769,7 +781,25 @@ def to_json(self):

return predicate_json


class MaskTimestampSetByTimeRange(AbstractFunction):
CLASS = "uk.gov.gchq.gaffer.time.function.MaskTimestampSetByTimeRange"

def __init__(self, start_time=None, end_time=None, time_unit=None):
super().__init__(_class_name=self.CLASS)
self.start_time = start_time
self.end_time = end_time
self.time_unit = time_unit

def to_json(self):
function_json = super().to_json()
function_json['startTime'] = self.start_time
function_json['endTime'] = self.end_time

if (self.time_unit is not None):
function_json["timeUnit"] = self.time_unit

return function_json

class ToList(AbstractFunction):
CLASS = 'uk.gov.gchq.koryphe.impl.function.ToList'

Expand Down Expand Up @@ -800,6 +830,21 @@ def __init__(self):
def to_json(self):
return super().to_json()

class CreateObject(AbstractFunction):
CLASS = "uk.gov.gchq.koryphe.impl.function.CreateObject"

def __init__(self, object_class=None):
super().__init__(self.CLASS)

self.object_class = object_class

def to_json(self):
function_json = super().to_json()

if self.object_class is not None:
function_json['objectClass'] = self.object_class

return function_json


def function_context_converter(obj):
Expand Down
74 changes: 37 additions & 37 deletions python-shell/src/gafferpy/gaffer_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,37 +597,30 @@ def to_json(self):

return match_json

class KeyFunctionMatch(Match):
CLASS = "uk.gov.gchq.gaffer.store.operation.handler.join.match.KeyFunctionMatch"

class Merge(ToJson, ToCodeString):
CLASS = "uk.gov.gchq.gaffer.operation.impl.join.merge.Merge"
def __init__(self, first_key_function=None, second_key_function=None):
super().__init__(_class_name=self.CLASS)

if not isinstance(first_key_function, gaffer_functions.Function):
self.first_key_function = JsonConverter.from_json(first_key_function, class_obj=gaffer_functions.Function)
else:
self.first_key_function = first_key_function

def __init__(self, _class_name):
self._class_name = _class_name
if not isinstance(second_key_function, gaffer_functions.Function):
self.second_key_function = JsonConverter.from_json(second_key_function, class_obj=gaffer_functions.Function)
else:
self.second_key_function = second_key_function

def to_json(self):
return {
'class': self._class_name
}

class ElementMerge(Merge):
CLASS = "uk.gov.gchq.gaffer.store.operation.handler.join.merge.ElementMerge"

def __init__(self, results_wanted=None, merge_type=None, schema=None):
super().__init__(_class_name=self.CLASS)
self.results_wanted = results_wanted
self.merge_type = merge_type
self.schema = schema
match_json = super().to_json()
if self.first_key_function is not None:
match_json['firstKeyFunction'] = self.first_key_function.to_json()
if self.second_key_function is not None:
match_json['secondKeyFunction'] = self.second_key_function.to_json()

def to_json(self):
merge_json = super().to_json()
if self.results_wanted is not None:
merge_json['resultsWanted'] = self.results_wanted
if self.merge_type is not None:
merge_json['mergeType'] = self.merge_type
if self.schema is not None:
merge_json['schema'] = self.schema

return merge_json
return match_json

class OperationChain(Operation):
CLASS = "uk.gov.gchq.gaffer.operation.OperationChain"
Expand Down Expand Up @@ -987,6 +980,20 @@ def to_json(self):
return operation


class CancelScheduledJob(Operation):
CLASS = "uk.gov.gchq.gaffer.operation.impl.job.CancelScheduledJob"

def __init__(self, job_id):
super().__init__(_class_name=self.CLASS)
self.job_id = job_id

def to_json(self):
operation_json = super().to_json()
if self.job_id is not None:
operation_json['jobId'] = self.job_id
return operation_json


class SplitStoreFromFile(Operation):
CLASS = 'uk.gov.gchq.gaffer.operation.impl.SplitStoreFromFile'

Expand Down Expand Up @@ -2644,10 +2651,9 @@ class Join(Operation):

CLASS = 'uk.gov.gchq.gaffer.operation.impl.join.Join'

def __init__(self, input=None, operation=None, match_method=None, match_key=None, merge_method=None, join_type=None, collection_limit=None, options=None):
def __init__(self, input=None, operation=None, match_method=None, match_key=None, flatten=None, join_type=None, collection_limit=None, options=None):
super().__init__(_class_name=self.CLASS, options=options)


if operation is not None:
if not isinstance(operation, Operation):
self.operation = JsonConverter.from_json(operation)
Expand All @@ -2660,14 +2666,8 @@ def __init__(self, input=None, operation=None, match_method=None, match_key=None
else:
self.match_method = match_method


if merge_method is not None:
if not isinstance(merge_method, Merge):
self.merge_method = JsonConverter.from_json(merge_method)
else:
self.merge_method = merge_method

self.input = input
self.flatten = flatten
self.match_key = match_key
self.collection_limit = collection_limit
self.join_type = join_type
Expand All @@ -2690,8 +2690,8 @@ def to_json(self):
operation_json['matchMethod'] = self.match_method.to_json()
if self.match_key is not None:
operation_json['matchKey'] = self.match_key
if self.merge_method is not None:
operation_json['mergeMethod'] = self.merge_method.to_json()
if self.flatten is not None:
operation_json['flatten'] = self.flatten
if self.join_type is not None:
operation_json['joinType'] = self.join_type
if self.collection_limit is not None:
Expand Down
1 change: 1 addition & 0 deletions python-shell/src/gafferpy/gaffer_predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ class TimeUnit:
MINUTE = 'MINUTE'
SECOND = 'SECOND'
MILLISECOND = 'MILLISECOND'
MICROSECOND = 'MICROSECOND'


class InTimeRange(AbstractPredicate):
Expand Down
61 changes: 60 additions & 1 deletion python-shell/src/test/test_gaffer_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ class GafferFunctionsTest(unittest.TestCase):
''',
g.ExtractKeys()
],
[
'''
{
"class": "uk.gov.gchq.koryphe.impl.function.DictionaryLookup",
"dictionary": {
"One": 1,
"Two": 2,
"Three": 3
}
}
''',
g.DictionaryLookup(dictionary=dict(One=1, Two=2, Three=3))
],
[
'''
{
Expand Down Expand Up @@ -530,8 +543,54 @@ class GafferFunctionsTest(unittest.TestCase):
g.func.MapFilter(
key_value_predicate=g.pred.AreEqual()
)
],
[
'''
{
"class" : "uk.gov.gchq.koryphe.impl.function.CreateObject",
"objectClass" : "java.lang.Long"
}
''',
g.func.CreateObject(
object_class="java.lang.Long"
)
],
[
'''
{
"class": "uk.gov.gchq.gaffer.time.function.MaskTimestampSetByTimeRange",
"startTime": {
"java.lang.Long": 15300000000000
},
"endTime": {
"java.lang.Long": 15400000000000
}
}
''',
g.func.MaskTimestampSetByTimeRange(
start_time=g.long(15300000000000),
end_time=g.long(15400000000000)
)
],
[
'''
{
"class": "uk.gov.gchq.gaffer.time.function.MaskTimestampSetByTimeRange",
"startTime": {
"java.lang.Long": 15300000000000
},
"endTime": {
"java.lang.Long": 15400000000000
},
"timeUnit": "SECOND"
}
''',
g.func.MaskTimestampSetByTimeRange(
start_time=g.long(15300000000000),
end_time=g.long(15400000000000),
time_unit=g.TimeUnit.SECOND
)
]

]

def test_examples(self):
Expand Down
Loading

0 comments on commit d90e128

Please sign in to comment.