[GitHub] incubator-rya issue #240: Rya 374
Github user asfgit commented on the issue: https://github.com/apache/incubator-rya/pull/240 Refer to this link for build results (access rights to CI server needed): https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/520/ ---
[GitHub] incubator-rya pull request #240: Rya 374
GitHub user meiercaleb opened a pull request: https://github.com/apache/incubator-rya/pull/240 Rya 374 ## Description Added Aggregation State to Fluo Query Nodes so that any node that is dependent on Aggregation Values can check the Aggregation state before writing to make sure that the state has not changed. This helps provide the guarantee that any result emitted by Fluo that contains an Aggregation Value reflects the most up to date Aggregation state. ### Tests Integration tests were written to verify that Aggregation state was being verified before writing and that the results emitted to Kafka reflected the current Aggregation state. ### Links [Jira](https://issues.apache.org/jira/browse/RYA-372) ### Checklist - [ ] Code Review - [ ] Squash Commits People To Reivew @kchilton2 @jdasch You can merge this pull request into a Git repository by running: $ git pull https://github.com/meiercaleb/incubator-rya RYA-374 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-rya/pull/240.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #240 commit 07d52cbf5a6a9028aac45ed7b68d933419ffe8a9 Author: Caleb MeierDate: 2017-09-21T14:47:47Z RYA-374-Aggregation Value Join Bug Fix commit 003045c80429f8ec08c45378cfc0dd56be2e1084 Author: Caleb Meier Date: 2017-10-09T15:03:49Z Broke KafkaExport IT in two ---
[jira] [Commented] (RYA-392) Temporal Difference Function
[ https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16197113#comment-16197113 ] ASF GitHub Bot commented on RYA-392: Github user asfgit commented on the issue: https://github.com/apache/incubator-rya/pull/237 Refer to this link for build results (access rights to CI server needed): https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/519/ > Temporal Difference Function > > > Key: RYA-392 > URL: https://issues.apache.org/jira/browse/RYA-392 > Project: Rya > Issue Type: New Feature >Affects Versions: 3.2.11 >Reporter: Caleb Meier >Assignee: Caleb Meier > > Currently Rya does not provide a Function that determines whether two > temporal literals are within a given period of time of one another. This is > extremely useful for filtering on query results that occurred within a fixed > period of time of a given instant. Currently, if one attempts to form the > following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will > be thrown if ?time1 and ?time2 are date time literals. I propose > implementing a Function that takes in two temporal literals, an integer and a > time unit and determines whether the date times are within the prescribed > period of one another. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[GitHub] incubator-rya issue #237: RYA-392-Datetime-Within
Github user asfgit commented on the issue: https://github.com/apache/incubator-rya/pull/237 Refer to this link for build results (access rights to CI server needed): https://builds.apache.org/job/incubator-rya-master-with-optionals-pull-requests/519/ ---
[jira] [Commented] (RYA-392) Temporal Difference Function
[ https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16197055#comment-16197055 ] ASF GitHub Bot commented on RYA-392: Github user meiercaleb commented on a diff in the pull request: https://github.com/apache/incubator-rya/pull/237#discussion_r143482636 --- Diff: common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java --- @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.rya.api.functions; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.time.temporal.ChronoUnit; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.openrdf.model.URI; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.impl.ValueFactoryImpl; + +/** + * Constants for OWL-Time primitives in the OWL-Time namespace. + * + */ +public class OWLTime { + +private static final ValueFactory FACTORY = ValueFactoryImpl.getInstance(); + +/** + * Indicates namespace of OWL-Time ontology + */ +public static final String NAMESPACE = "http://www.w3.org/2006/time#;; +/** + * Seconds class of type DurationDescription in OWL-Time ontology + */ +public static final URI SECONDS_URI = FACTORY.createURI(NAMESPACE, "seconds"); +/** + * Minutes class of type DurationDescription in OWL-Time ontology + */ +public static final URI MINUTES_URI = FACTORY.createURI(NAMESPACE, "minutes"); +/** + * Hours class of type DurationDescription in OWL-Time ontology + */ +public static final URI HOURS_URI = FACTORY.createURI(NAMESPACE, "hours"); +/** + * Days class of type DurationDescription in OWL-Time ontology + */ +public static final URI DAYS_URI = FACTORY.createURI(NAMESPACE, "days"); +/** + * Weeks class of type DurationDescription in OWL-Time ontology + */ +public static final URI WEEKS_URI = FACTORY.createURI(NAMESPACE, "weeks"); + +private static final MapDURATION_MAP = new HashMap<>(); + +static { +DURATION_MAP.put(SECONDS_URI, ChronoUnit.SECONDS); +DURATION_MAP.put(MINUTES_URI, ChronoUnit.MINUTES); +DURATION_MAP.put(HOURS_URI, ChronoUnit.HOURS); +DURATION_MAP.put(DAYS_URI, ChronoUnit.DAYS); +DURATION_MAP.put(WEEKS_URI, ChronoUnit.WEEKS); +} + +/** + * Verifies whether URI is a valid OWL-Time URI that is supported by this class. + * @param durationURI - OWLTime URI indicating the time unit --- End diff -- Done. > Temporal Difference Function > > > Key: RYA-392 > URL: https://issues.apache.org/jira/browse/RYA-392 > Project: Rya > Issue Type: New Feature >Affects Versions: 3.2.11 >Reporter: Caleb Meier >Assignee: Caleb Meier > > Currently Rya does not provide a Function that determines whether two > temporal literals are within a given period of time of one another. This is > extremely useful for filtering on query results that occurred within a fixed > period of time of a given instant. Currently, if one attempts to form the > following filter Filter(?time1 - ?time2 < "24"^^xsd:hour), an exception will > be thrown if ?time1 and ?time2 are date time literals. I propose > implementing a Function that takes in two temporal literals, an integer and a > time unit and determines whether the date times are within the prescribed > period of one another. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (RYA-392) Temporal Difference Function
[ https://issues.apache.org/jira/browse/RYA-392?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16197053#comment-16197053 ] ASF GitHub Bot commented on RYA-392: Github user meiercaleb commented on a diff in the pull request: https://github.com/apache/incubator-rya/pull/237#discussion_r143482605 --- Diff: common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java --- @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */package org.apache.rya.api.functions; + +import static com.google.common.base.Preconditions.checkArgument; + +import java.time.Duration; +import java.time.Instant; + +import org.openrdf.model.Literal; +import org.openrdf.model.URI; +import org.openrdf.model.Value; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.datatypes.XMLDatatypeUtil; +import org.openrdf.model.vocabulary.FN; +import org.openrdf.model.vocabulary.XMLSchema; +import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException; +import org.openrdf.query.algebra.evaluation.function.Function; + +/** + * This {@link Function} determines whether two {@link XMLSchema#DATETIME}s occur within a specified period of time of + * one another. The method {@link Function#evaluate(ValueFactory, Value...)} expects four values, where the first two + * values are the datetimes, the third value is an integer indicating the period, and the fourth value is a URI + * indicating the time unit of the period. The URI must be of Type DurationDescription in the OWL-Time ontology (see + * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). Examples of valid time unit URIs can + * be found in the class {@link OWLTime} and below + * + * http://www.w3.org/2006/time#days + * http://www.w3.org/2006/time#hours + * http://www.w3.org/2006/time#minutes + * http://www.w3.org/2006/time#seconds + * + * + */ +public class DateTimeWithinPeriod implements Function { + +private static final String FUNCTION_URI = FN.NAMESPACE + "dateTimeWithin"; + +@Override +public String getURI() { +return FUNCTION_URI; +} + +/** + * Determines whether two datetimes occur within a specified period of time of one another. This method expects four + * values, where the first two values are the datetimes, the third value is an integer indicating the period, and + * the fourth value is a URI indicating the time unit of the period. The URI must be of Type DurationDescription in + * the OWL-Time ontology (see https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). + * Examples of valid time unit URIs can be found in the class {@link OWLTime} and below + * + * http://www.w3.org/2006/time#days + * http://www.w3.org/2006/time#hours + * http://www.w3.org/2006/time#minutes + * http://www.w3.org/2006/time#seconds + * + * + * @param valueFactory - factory for creating values + * @param values - array of Value arguments for this Function. + */ +@Override +public Value evaluate(ValueFactory valueFactory, Value... values) throws ValueExprEvaluationException { --- End diff -- Done. > Temporal Difference Function > > > Key: RYA-392 > URL: https://issues.apache.org/jira/browse/RYA-392 > Project: Rya > Issue Type: New Feature >Affects Versions: 3.2.11 >Reporter: Caleb Meier >Assignee: Caleb Meier > > Currently Rya does not provide a Function that determines whether two > temporal literals are within a given period of time of one another. This is > extremely useful for filtering on query results that occurred within a fixed > period of time of a given instant. Currently, if one attempts to form the > following filter Filter(?time1 -
[GitHub] incubator-rya pull request #237: RYA-392-Datetime-Within
Github user meiercaleb commented on a diff in the pull request: https://github.com/apache/incubator-rya/pull/237#discussion_r143482605 --- Diff: common/rya.api/src/main/java/org/apache/rya/api/functions/DateTimeWithinPeriod.java --- @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */package org.apache.rya.api.functions; + +import static com.google.common.base.Preconditions.checkArgument; + +import java.time.Duration; +import java.time.Instant; + +import org.openrdf.model.Literal; +import org.openrdf.model.URI; +import org.openrdf.model.Value; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.datatypes.XMLDatatypeUtil; +import org.openrdf.model.vocabulary.FN; +import org.openrdf.model.vocabulary.XMLSchema; +import org.openrdf.query.algebra.evaluation.ValueExprEvaluationException; +import org.openrdf.query.algebra.evaluation.function.Function; + +/** + * This {@link Function} determines whether two {@link XMLSchema#DATETIME}s occur within a specified period of time of + * one another. The method {@link Function#evaluate(ValueFactory, Value...)} expects four values, where the first two + * values are the datetimes, the third value is an integer indicating the period, and the fourth value is a URI + * indicating the time unit of the period. The URI must be of Type DurationDescription in the OWL-Time ontology (see + * https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). Examples of valid time unit URIs can + * be found in the class {@link OWLTime} and below + * + * http://www.w3.org/2006/time#days + * http://www.w3.org/2006/time#hours + * http://www.w3.org/2006/time#minutes + * http://www.w3.org/2006/time#seconds + * + * + */ +public class DateTimeWithinPeriod implements Function { + +private static final String FUNCTION_URI = FN.NAMESPACE + "dateTimeWithin"; + +@Override +public String getURI() { +return FUNCTION_URI; +} + +/** + * Determines whether two datetimes occur within a specified period of time of one another. This method expects four + * values, where the first two values are the datetimes, the third value is an integer indicating the period, and + * the fourth value is a URI indicating the time unit of the period. The URI must be of Type DurationDescription in + * the OWL-Time ontology (see https://www.w3.org/TR/owl-time/;>https://www.w3.org/TR/owl-time/). + * Examples of valid time unit URIs can be found in the class {@link OWLTime} and below + * + * http://www.w3.org/2006/time#days + * http://www.w3.org/2006/time#hours + * http://www.w3.org/2006/time#minutes + * http://www.w3.org/2006/time#seconds + * + * + * @param valueFactory - factory for creating values + * @param values - array of Value arguments for this Function. + */ +@Override +public Value evaluate(ValueFactory valueFactory, Value... values) throws ValueExprEvaluationException { --- End diff -- Done. ---
[GitHub] incubator-rya pull request #237: RYA-392-Datetime-Within
Github user meiercaleb commented on a diff in the pull request: https://github.com/apache/incubator-rya/pull/237#discussion_r143481881 --- Diff: common/rya.api/src/main/java/org/apache/rya/api/functions/OWLTime.java --- @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.rya.api.functions; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.time.temporal.ChronoUnit; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +import org.openrdf.model.URI; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.impl.ValueFactoryImpl; + +/** + * Constants for OWL-Time primitives in the OWL-Time namespace. + * + */ +public class OWLTime { + +private static final ValueFactory FACTORY = ValueFactoryImpl.getInstance(); + +/** + * Indicates namespace of OWL-Time ontology + */ +public static final String NAMESPACE = "http://www.w3.org/2006/time#;; +/** + * Seconds class of type DurationDescription in OWL-Time ontology + */ +public static final URI SECONDS_URI = FACTORY.createURI(NAMESPACE, "seconds"); +/** + * Minutes class of type DurationDescription in OWL-Time ontology + */ +public static final URI MINUTES_URI = FACTORY.createURI(NAMESPACE, "minutes"); +/** + * Hours class of type DurationDescription in OWL-Time ontology + */ +public static final URI HOURS_URI = FACTORY.createURI(NAMESPACE, "hours"); +/** + * Days class of type DurationDescription in OWL-Time ontology + */ +public static final URI DAYS_URI = FACTORY.createURI(NAMESPACE, "days"); +/** + * Weeks class of type DurationDescription in OWL-Time ontology + */ +public static final URI WEEKS_URI = FACTORY.createURI(NAMESPACE, "weeks"); + +private static final MapDURATION_MAP = new HashMap<>(); + +static { +DURATION_MAP.put(SECONDS_URI, ChronoUnit.SECONDS); +DURATION_MAP.put(MINUTES_URI, ChronoUnit.MINUTES); +DURATION_MAP.put(HOURS_URI, ChronoUnit.HOURS); +DURATION_MAP.put(DAYS_URI, ChronoUnit.DAYS); +DURATION_MAP.put(WEEKS_URI, ChronoUnit.WEEKS); +} + +/** + * Verifies whether URI is a valid OWL-Time URI that is supported by this class. + * @param durationURI - OWLTime URI indicating the time unit + * @return - {@code true} if this URI indicates a supported OWLTime time unit + */ +public static boolean isValidDurationType(URI durationURI) { +checkNotNull(durationURI); +return DURATION_MAP.containsKey(durationURI); +} + +/** + * Returns the duration in milliseconds + * + * @param duration - amount of time in the units indicated by the provided {@link OWLTime} URI + * @param uri - OWLTime URI indicating the time unit of duration + * @return - the amount of time in milliseconds + * @throws IllegalArgumentException if provided {@link URI} is not a valid, supported OWL-Time time unit. + */ +public static long getMillis(int duration, URI uri) throws IllegalArgumentException { +Optional unit = getChronoUnitFromURI(uri); +checkArgument(unit.isPresent(), +String.format("URI %s does not indicate a valid OWLTime time unit. URI must of be of type %s, %s, %s, %s, or %s .", uri, +SECONDS_URI, MINUTES_URI, HOURS_URI, DAYS_URI, WEEKS_URI)); +return duration * unit.get().getDuration().toMillis(); +} + +/** + * Converts the {@link OWLTime} URI time unit to a {@link ChronoUnit} time unit + * + * @param durationURI - OWLTime time unit URI + * @return - corresponding