http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/query/strategy/wholerow/PoWholeRowTriplePatternStrategy.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/query/strategy/wholerow/PoWholeRowTriplePatternStrategy.java b/common/rya.api/src/main/java/mvm/rya/api/query/strategy/wholerow/PoWholeRowTriplePatternStrategy.java deleted file mode 100644 index 3f050e0..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/query/strategy/wholerow/PoWholeRowTriplePatternStrategy.java +++ /dev/null @@ -1,128 +0,0 @@ -package mvm.rya.api.query.strategy.wholerow; - -/* - * 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. - */ - - - -import com.google.common.primitives.Bytes; -import mvm.rya.api.RdfCloudTripleStoreConfiguration; -import mvm.rya.api.RdfCloudTripleStoreConstants; -import mvm.rya.api.RdfCloudTripleStoreUtils; -import mvm.rya.api.domain.RyaRange; -import mvm.rya.api.domain.RyaType; -import mvm.rya.api.domain.RyaURI; -import mvm.rya.api.query.strategy.AbstractTriplePatternStrategy; -import mvm.rya.api.query.strategy.ByteRange; -import mvm.rya.api.resolver.RyaContext; -import mvm.rya.api.resolver.RyaTypeResolverException; - -import java.io.IOException; -import java.util.Map; - -import static mvm.rya.api.RdfCloudTripleStoreConstants.*; - -/** - * Date: 7/14/12 - * Time: 7:35 AM - */ -public class PoWholeRowTriplePatternStrategy extends AbstractTriplePatternStrategy { - - @Override - public RdfCloudTripleStoreConstants.TABLE_LAYOUT getLayout() { - return RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO; - } - - @Override - public Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, - ByteRange> defineRange(RyaURI subject, RyaURI predicate, RyaType object, - RyaURI context, RdfCloudTripleStoreConfiguration conf) throws IOException { - try { - //po(ng) - //po_r(s)(ng) - //p(ng) - //p_r(o)(ng) - //r(p)(ng) - if (!handles(subject, predicate, object, context)) return null; - - RyaContext ryaContext = RyaContext.getInstance(); - - RdfCloudTripleStoreConstants.TABLE_LAYOUT table_layout = RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO; - byte[] start, stop; - if (object != null) { - if (object instanceof RyaRange) { - //p_r(o) - RyaRange rv = (RyaRange) object; - rv = ryaContext.transformRange(rv); - byte[] objStartBytes = ryaContext.serializeType(rv.getStart())[0]; - byte[] objEndBytes = ryaContext.serializeType(rv.getStop())[0]; - byte[] predBytes = predicate.getData().getBytes(); - start = Bytes.concat(predBytes, DELIM_BYTES, objStartBytes); - stop = Bytes.concat(predBytes, DELIM_BYTES, objEndBytes, DELIM_BYTES, LAST_BYTES); - } else { - if (subject != null && subject instanceof RyaRange) { - //po_r(s) - RyaRange ru = (RyaRange) subject; - ru = ryaContext.transformRange(ru); - byte[] subjStartBytes = ru.getStart().getData().getBytes(); - byte[] subjStopBytes = ru.getStop().getData().getBytes(); - byte[] predBytes = predicate.getData().getBytes(); - byte[] objBytes = ryaContext.serializeType(object)[0]; - start = Bytes.concat(predBytes, DELIM_BYTES, objBytes, DELIM_BYTES, subjStartBytes); - stop = Bytes.concat(predBytes, DELIM_BYTES, objBytes, DELIM_BYTES, subjStopBytes, TYPE_DELIM_BYTES, LAST_BYTES); - } else { - //po - //TODO: There must be a better way than creating multiple byte[] - byte[] objBytes = ryaContext.serializeType(object)[0]; - start = Bytes.concat(predicate.getData().getBytes(), DELIM_BYTES, objBytes, DELIM_BYTES); - stop = Bytes.concat(start, LAST_BYTES); - } - } - } else if (predicate instanceof RyaRange) { - //r(p) - RyaRange rv = (RyaRange) predicate; - rv = ryaContext.transformRange(rv); - start = rv.getStart().getData().getBytes(); - stop = Bytes.concat(rv.getStop().getData().getBytes(), DELIM_BYTES, LAST_BYTES); - } else { - //p - start = Bytes.concat(predicate.getData().getBytes(), DELIM_BYTES); - stop = Bytes.concat(start, LAST_BYTES); - } - return new RdfCloudTripleStoreUtils.CustomEntry<RdfCloudTripleStoreConstants.TABLE_LAYOUT, - ByteRange>(table_layout, new ByteRange(start, stop)); - } catch (RyaTypeResolverException e) { - throw new IOException(e); - } - } - - @Override - public boolean handles(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context) { - //po(ng) - //p_r(o)(ng) - //po_r(s)(ng) - //p(ng) - //r(p)(ng) - if (predicate == null) return false; - if (subject != null && !(subject instanceof RyaRange)) return false; - if (predicate instanceof RyaRange) - return object == null && subject == null; - return subject == null || object != null; - } -}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/query/strategy/wholerow/SpoWholeRowTriplePatternStrategy.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/query/strategy/wholerow/SpoWholeRowTriplePatternStrategy.java b/common/rya.api/src/main/java/mvm/rya/api/query/strategy/wholerow/SpoWholeRowTriplePatternStrategy.java deleted file mode 100644 index 2b91a4b..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/query/strategy/wholerow/SpoWholeRowTriplePatternStrategy.java +++ /dev/null @@ -1,130 +0,0 @@ -package mvm.rya.api.query.strategy.wholerow; - -/* - * 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. - */ - - - -import com.google.common.primitives.Bytes; -import mvm.rya.api.RdfCloudTripleStoreConfiguration; -import mvm.rya.api.RdfCloudTripleStoreUtils; -import mvm.rya.api.domain.RyaRange; -import mvm.rya.api.domain.RyaType; -import mvm.rya.api.domain.RyaURI; -import mvm.rya.api.domain.RyaURIRange; -import mvm.rya.api.query.strategy.AbstractTriplePatternStrategy; -import mvm.rya.api.query.strategy.ByteRange; -import mvm.rya.api.resolver.RyaContext; -import mvm.rya.api.resolver.RyaTypeResolverException; - -import java.io.IOException; -import java.util.Map; - -import static mvm.rya.api.RdfCloudTripleStoreConstants.*; - -/** - * Date: 7/14/12 - * Time: 7:35 AM - */ -public class SpoWholeRowTriplePatternStrategy extends AbstractTriplePatternStrategy { - - @Override - public TABLE_LAYOUT getLayout() { - return TABLE_LAYOUT.SPO; - } - - @Override - public Map.Entry<TABLE_LAYOUT, ByteRange> defineRange(RyaURI subject, RyaURI predicate, RyaType object, - RyaURI context, RdfCloudTripleStoreConfiguration conf) throws IOException { - try { - //spo(ng) - //sp(ng) - //s(ng) - //sp_r(o)(ng) - //s_r(p)(ng) - if (!handles(subject, predicate, object, context)) return null; - - RyaContext ryaContext = RyaContext.getInstance(); - - TABLE_LAYOUT table_layout = TABLE_LAYOUT.SPO; - byte[] start; - byte[] stop; - if (predicate != null) { - if (object != null) { - if (object instanceof RyaRange) { - //sp_r(o) - //range = sp_r(o.s)->sp_r(o.e) (remove last byte to remove type info) - RyaRange rv = (RyaRange) object; - rv = ryaContext.transformRange(rv); - byte[] objStartBytes = ryaContext.serializeType(rv.getStart())[0]; - byte[] objEndBytes = ryaContext.serializeType(rv.getStop())[0]; - byte[] subjBytes = subject.getData().getBytes(); - byte[] predBytes = predicate.getData().getBytes(); - start = Bytes.concat(subjBytes, DELIM_BYTES, predBytes, DELIM_BYTES, objStartBytes); - stop = Bytes.concat(subjBytes, DELIM_BYTES, predBytes, DELIM_BYTES, objEndBytes, DELIM_BYTES, LAST_BYTES); - } else { - //spo - //range = spo->spo (remove last byte to remove type info) - //TODO: There must be a better way than creating multiple byte[] - byte[] objBytes = ryaContext.serializeType(object)[0]; - start = Bytes.concat(subject.getData().getBytes(), DELIM_BYTES, predicate.getData().getBytes(), DELIM_BYTES, objBytes, TYPE_DELIM_BYTES); - stop = Bytes.concat(start, LAST_BYTES); - } - } else if (predicate instanceof RyaRange) { - //s_r(p) - //range = s_r(p.s)->s_r(p.e) - RyaRange rv = (RyaRange) predicate; - rv = ryaContext.transformRange(rv); - byte[] subjBytes = subject.getData().getBytes(); - byte[] predStartBytes = rv.getStart().getData().getBytes(); - byte[] predStopBytes = rv.getStop().getData().getBytes(); - start = Bytes.concat(subjBytes, DELIM_BYTES, predStartBytes); - stop = Bytes.concat(subjBytes, DELIM_BYTES, predStopBytes, DELIM_BYTES, LAST_BYTES); - } else { - //sp - //range = sp - start = Bytes.concat(subject.getData().getBytes(), DELIM_BYTES, predicate.getData().getBytes(), DELIM_BYTES); - stop = Bytes.concat(start, LAST_BYTES); - } - } else if (subject instanceof RyaRange) { - //r(s) - //range = r(s.s) -> r(s.e) - RyaRange ru = (RyaRange) subject; - ru = ryaContext.transformRange(ru); - start = ru.getStart().getData().getBytes(); - stop = Bytes.concat(ru.getStop().getData().getBytes(), DELIM_BYTES, LAST_BYTES); - } else { - //s - //range = s - start = Bytes.concat(subject.getData().getBytes(), DELIM_BYTES); - stop = Bytes.concat(start, LAST_BYTES); - } - return new RdfCloudTripleStoreUtils.CustomEntry<TABLE_LAYOUT, ByteRange>(table_layout, - new ByteRange(start, stop)); - } catch (RyaTypeResolverException e) { - throw new IOException(e); - } - } - - @Override - public boolean handles(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context) { - //if subject is not null and (if predicate is null then object must be null) - return (subject != null && !(subject instanceof RyaURIRange && predicate != null)) && !((predicate == null || predicate instanceof RyaURIRange) && (object != null)); - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/CustomRyaTypeResolverMapping.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/CustomRyaTypeResolverMapping.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/CustomRyaTypeResolverMapping.java deleted file mode 100644 index 3a6d125..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/CustomRyaTypeResolverMapping.java +++ /dev/null @@ -1,57 +0,0 @@ -package mvm.rya.api.resolver; - -/* - * 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. - */ - - - -import org.openrdf.model.URI; - -/** - * Date: 7/16/12 - * Time: 12:25 PM - */ -public class CustomRyaTypeResolverMapping extends RyaTypeResolverMapping { - - protected URI ryaDataType; - protected byte markerByte; - - public CustomRyaTypeResolverMapping() { - } - - public CustomRyaTypeResolverMapping(URI ryaDataType, byte markerByte) { - this(null, ryaDataType, markerByte); - } - - public CustomRyaTypeResolverMapping(RyaTypeResolver ryaTypeResolver, URI ryaDataType, byte markerByte) { - super(ryaTypeResolver); - this.ryaDataType = ryaDataType; - this.markerByte = markerByte; - } - - @Override - public URI getRyaDataType() { - return ryaDataType; - } - - @Override - byte getMarkerByte() { - return markerByte; - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/RdfToRyaConversions.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/RdfToRyaConversions.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/RdfToRyaConversions.java deleted file mode 100644 index 485bf0d..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/RdfToRyaConversions.java +++ /dev/null @@ -1,93 +0,0 @@ -package mvm.rya.api.resolver; - -/* - * 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. - */ - - - -import mvm.rya.api.domain.*; -import org.openrdf.model.*; - -/** - * Date: 7/17/12 - * Time: 8:34 AM - */ -public class RdfToRyaConversions { - - public static RyaURI convertURI(URI uri) { - if (uri == null) return null; - if (uri instanceof RangeURI) { - RangeURI ruri = (RangeURI) uri; - return new RyaURIRange(convertURI(ruri.getStart()), convertURI(ruri.getEnd())); - } - return new RyaURI(uri.stringValue()); - } - - public static RyaType convertLiteral(Literal literal) { - if (literal == null) return null; - if (literal.getDatatype() != null) { - return new RyaType(literal.getDatatype(), literal.stringValue()); - } - //no language literal conversion yet - return new RyaType(literal.stringValue()); - } - - public static RyaType convertValue(Value value) { - if (value == null) return null; - //assuming either uri or Literal here - if(value instanceof Resource) { - return convertResource((Resource) value); - } - if (value instanceof Literal) { - return convertLiteral((Literal) value); - } - if (value instanceof RangeValue) { - RangeValue rv = (RangeValue) value; - if (rv.getStart() instanceof URI) { - return new RyaURIRange(convertURI((URI) rv.getStart()), convertURI((URI) rv.getEnd())); - } else { - //literal - return new RyaTypeRange(convertLiteral((Literal) rv.getStart()), convertLiteral((Literal) rv.getEnd())); - } - } - return null; - } - - public static RyaURI convertResource(Resource subject) { - if(subject == null) return null; - if (subject instanceof BNode) { - return new RyaURI(RyaSchema.BNODE_NAMESPACE + ((BNode) subject).getID()); - } - return convertURI((URI) subject); - } - - public static RyaStatement convertStatement(Statement statement) { - if (statement == null) return null; - Resource subject = statement.getSubject(); - URI predicate = statement.getPredicate(); - Value object = statement.getObject(); - Resource context = statement.getContext(); - return new RyaStatement( - convertResource(subject), - convertURI(predicate), - convertValue(object), - convertResource(context)); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaContext.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaContext.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaContext.java deleted file mode 100644 index 2b97e1c..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaContext.java +++ /dev/null @@ -1,192 +0,0 @@ -package mvm.rya.api.resolver; - -/* - * 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. - */ - - - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import mvm.rya.api.domain.RyaRange; -import mvm.rya.api.domain.RyaType; -import mvm.rya.api.resolver.impl.BooleanRyaTypeResolver; -import mvm.rya.api.resolver.impl.ByteRyaTypeResolver; -import mvm.rya.api.resolver.impl.CustomDatatypeResolver; -import mvm.rya.api.resolver.impl.DateTimeRyaTypeResolver; -import mvm.rya.api.resolver.impl.DoubleRyaTypeResolver; -import mvm.rya.api.resolver.impl.FloatRyaTypeResolver; -import mvm.rya.api.resolver.impl.IntegerRyaTypeResolver; -import mvm.rya.api.resolver.impl.LongRyaTypeResolver; -import mvm.rya.api.resolver.impl.RyaTypeResolverImpl; -import mvm.rya.api.resolver.impl.RyaURIResolver; -import mvm.rya.api.resolver.impl.ServiceBackedRyaTypeResolverMappings; -import mvm.rya.api.resolver.impl.ShortRyaTypeResolver; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.openrdf.model.URI; -import org.openrdf.model.vocabulary.XMLSchema; - -/** - * Date: 7/16/12 - * Time: 12:04 PM - */ -public class RyaContext { - - public Log logger = LogFactory.getLog(RyaContext.class); - - private Map<URI, RyaTypeResolver> uriToResolver = new HashMap<URI, RyaTypeResolver>(); - private Map<Byte, RyaTypeResolver> byteToResolver = new HashMap<Byte, RyaTypeResolver>(); - private RyaTypeResolver defaultResolver = new CustomDatatypeResolver(); - - private RyaContext() { - //add default - addDefaultMappings(); - } - - protected void addDefaultMappings() { - if (logger.isDebugEnabled()) { - logger.debug("Adding default mappings"); - } - addRyaTypeResolverMapping(new RyaTypeResolverMapping(new RyaTypeResolverImpl())); // plain string - addRyaTypeResolverMapping(new RyaTypeResolverMapping(new RyaURIResolver())); // uri - addRyaTypeResolverMapping(new RyaTypeResolverMapping(new DateTimeRyaTypeResolver())); // dateTime - addRyaTypeResolverMapping(new RyaTypeResolverMapping(new DoubleRyaTypeResolver())); // double - addRyaTypeResolverMapping(new RyaTypeResolverMapping(new FloatRyaTypeResolver())); // float - addRyaTypeResolverMapping(new RyaTypeResolverMapping(new IntegerRyaTypeResolver())); // integer - addRyaTypeResolverMapping(new RyaTypeResolverMapping(new ShortRyaTypeResolver())); // short - addRyaTypeResolverMapping(new RyaTypeResolverMapping(new LongRyaTypeResolver())); // long - addRyaTypeResolverMapping(new RyaTypeResolverMapping(new BooleanRyaTypeResolver())); // boolean - addRyaTypeResolverMapping(new RyaTypeResolverMapping(new ByteRyaTypeResolver())); // byte - - //int is integer - uriToResolver.put(XMLSchema.INT, new IntegerRyaTypeResolver()); - - //add service loaded mappings - addRyaTypeResolverMappings(new ServiceBackedRyaTypeResolverMappings().getResolvers()); - } - - private static class RyaContextHolder { - public static final RyaContext INSTANCE = new RyaContext(); - } - - public synchronized static RyaContext getInstance() { - return RyaContextHolder.INSTANCE; - } - - - //need to go from datatype->resolver - public RyaTypeResolver retrieveResolver(URI datatype) { - RyaTypeResolver ryaTypeResolver = uriToResolver.get(datatype); - if (ryaTypeResolver == null) return defaultResolver; - return ryaTypeResolver; - } - - //need to go from byte->resolver - public RyaTypeResolver retrieveResolver(byte markerByte) { - RyaTypeResolver ryaTypeResolver = byteToResolver.get(markerByte); - if (ryaTypeResolver == null) return defaultResolver; - return ryaTypeResolver; - } - - public byte[] serialize(RyaType ryaType) throws RyaTypeResolverException { - RyaTypeResolver ryaTypeResolver = retrieveResolver(ryaType.getDataType()); - if (ryaTypeResolver != null) { - return ryaTypeResolver.serialize(ryaType); - } - return null; - } - - public byte[][] serializeType(RyaType ryaType) throws RyaTypeResolverException { - RyaTypeResolver ryaTypeResolver = retrieveResolver(ryaType.getDataType()); - if (ryaTypeResolver != null) { - return ryaTypeResolver.serializeType(ryaType); - } - return null; - } - - public RyaType deserialize(byte[] bytes) throws RyaTypeResolverException { - RyaTypeResolver ryaTypeResolver = retrieveResolver(bytes[bytes.length - 1]); - if (ryaTypeResolver != null) { - return ryaTypeResolver.deserialize(bytes); - } - return null; - } - - public void addRyaTypeResolverMapping(RyaTypeResolverMapping mapping) { - if (!uriToResolver.containsKey(mapping.getRyaDataType())) { - if (logger.isDebugEnabled()) { - logger.debug("addRyaTypeResolverMapping uri:[" + mapping.getRyaDataType() + "] byte:[" + mapping.getMarkerByte() + "] for mapping[" + mapping + "]"); - } - uriToResolver.put(mapping.getRyaDataType(), mapping.getRyaTypeResolver()); - byteToResolver.put(mapping.getMarkerByte(), mapping.getRyaTypeResolver()); - } else { - logger.warn("Could not add ryaType mapping because one already exists. uri:[" + mapping.getRyaDataType() + "] byte:[" + mapping.getMarkerByte() + "] for mapping[" + mapping + "]"); - } - } - - public void addRyaTypeResolverMappings(List<RyaTypeResolverMapping> mappings) { - for (RyaTypeResolverMapping mapping : mappings) { - addRyaTypeResolverMapping(mapping); - } - } - - public RyaTypeResolver removeRyaTypeResolver(URI dataType) { - RyaTypeResolver ryaTypeResolver = uriToResolver.remove(dataType); - if (ryaTypeResolver != null) { - if (logger.isDebugEnabled()) { - logger.debug("Removing ryaType Resolver uri[" + dataType + "] + [" + ryaTypeResolver + "]"); - } - byteToResolver.remove(ryaTypeResolver.getMarkerByte()); - return ryaTypeResolver; - } - return null; - } - - public RyaTypeResolver removeRyaTypeResolver(byte markerByte) { - RyaTypeResolver ryaTypeResolver = byteToResolver.remove(markerByte); - if (ryaTypeResolver != null) { - if (logger.isDebugEnabled()) { - logger.debug("Removing ryaType Resolver byte[" + markerByte + "] + [" + ryaTypeResolver + "]"); - } - uriToResolver.remove(ryaTypeResolver.getRyaDataType()); - return ryaTypeResolver; - } - return null; - } - - //transform range - public RyaRange transformRange(RyaRange range) throws RyaTypeResolverException { - RyaTypeResolver ryaTypeResolver = retrieveResolver(range.getStart().getDataType()); - if (ryaTypeResolver != null) { - return ryaTypeResolver.transformRange(range); - } - return range; - } - - public RyaTypeResolver getDefaultResolver() { - return defaultResolver; - } - - public void setDefaultResolver(RyaTypeResolver defaultResolver) { - this.defaultResolver = defaultResolver; - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaToRdfConversions.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaToRdfConversions.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaToRdfConversions.java deleted file mode 100644 index a30d250..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaToRdfConversions.java +++ /dev/null @@ -1,75 +0,0 @@ -package mvm.rya.api.resolver; - -/* - * 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. - */ - - - -import mvm.rya.api.domain.RyaStatement; -import mvm.rya.api.domain.RyaType; -import mvm.rya.api.domain.RyaURI; -import org.openrdf.model.Literal; -import org.openrdf.model.Statement; -import org.openrdf.model.URI; -import org.openrdf.model.Value; -import org.openrdf.model.impl.ContextStatementImpl; -import org.openrdf.model.impl.LiteralImpl; -import org.openrdf.model.impl.StatementImpl; -import org.openrdf.model.impl.URIImpl; -import org.openrdf.model.vocabulary.XMLSchema; - -/** - * Date: 7/17/12 - * Time: 8:34 AM - */ -public class RyaToRdfConversions { - - public static URI convertURI(RyaURI uri) { - return new URIImpl(uri.getData()); - } - - public static Literal convertLiteral(RyaType literal) { - if (XMLSchema.STRING.equals(literal.getDataType())) { - return new LiteralImpl(literal.getData()); - } else { - return new LiteralImpl(literal.getData(), literal.getDataType()); - } - //TODO: No Language support yet - } - - public static Value convertValue(RyaType value) { - //assuming either uri or Literal here - return (value instanceof RyaURI) ? convertURI((RyaURI) value) : convertLiteral(value); - } - - public static Statement convertStatement(RyaStatement statement) { - assert statement != null; - if (statement.getContext() != null) { - return new ContextStatementImpl(convertURI(statement.getSubject()), - convertURI(statement.getPredicate()), - convertValue(statement.getObject()), - convertURI(statement.getContext())); - } else { - return new StatementImpl(convertURI(statement.getSubject()), - convertURI(statement.getPredicate()), - convertValue(statement.getObject())); - } - } - -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTripleContext.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTripleContext.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTripleContext.java deleted file mode 100644 index b3c244e..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTripleContext.java +++ /dev/null @@ -1,123 +0,0 @@ -package mvm.rya.api.resolver; - -/* - * 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. - */ - - - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import mvm.rya.api.RdfCloudTripleStoreConfiguration; -import mvm.rya.api.RdfCloudTripleStoreConstants; -import mvm.rya.api.domain.RyaStatement; -import mvm.rya.api.domain.RyaType; -import mvm.rya.api.domain.RyaURI; -import mvm.rya.api.query.strategy.TriplePatternStrategy; -import mvm.rya.api.query.strategy.wholerow.HashedPoWholeRowTriplePatternStrategy; -import mvm.rya.api.query.strategy.wholerow.HashedSpoWholeRowTriplePatternStrategy; -import mvm.rya.api.query.strategy.wholerow.OspWholeRowTriplePatternStrategy; -import mvm.rya.api.query.strategy.wholerow.PoWholeRowTriplePatternStrategy; -import mvm.rya.api.query.strategy.wholerow.SpoWholeRowTriplePatternStrategy; -import mvm.rya.api.resolver.triple.TripleRow; -import mvm.rya.api.resolver.triple.TripleRowResolver; -import mvm.rya.api.resolver.triple.TripleRowResolverException; -import mvm.rya.api.resolver.triple.impl.WholeRowHashedTripleResolver; -import mvm.rya.api.resolver.triple.impl.WholeRowTripleResolver; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Date: 7/16/12 - * Time: 12:04 PM - */ -public class RyaTripleContext { - - public Log logger = LogFactory.getLog(RyaTripleContext.class); - private TripleRowResolver tripleResolver; - private List<TriplePatternStrategy> triplePatternStrategyList = new ArrayList<TriplePatternStrategy>(); - - private RyaTripleContext(boolean addPrefixHash) { - addDefaultTriplePatternStrategies(addPrefixHash); - if (addPrefixHash){ - tripleResolver = new WholeRowHashedTripleResolver(); - } - else { - tripleResolver = new WholeRowTripleResolver(); - } - } - - - private static class RyaTripleContextHolder { - // TODO want to be able to support more variability in configuration here - public static final RyaTripleContext INSTANCE = new RyaTripleContext(false); - public static final RyaTripleContext HASHED_INSTANCE = new RyaTripleContext(true); - } - - public synchronized static RyaTripleContext getInstance(RdfCloudTripleStoreConfiguration conf) { - if (conf.isPrefixRowsWithHash()){ - return RyaTripleContextHolder.HASHED_INSTANCE; - } - return RyaTripleContextHolder.INSTANCE; - } - - - public Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serializeTriple(RyaStatement statement) throws TripleRowResolverException { - return getTripleResolver().serialize(statement); - } - - public RyaStatement deserializeTriple(RdfCloudTripleStoreConstants.TABLE_LAYOUT table_layout, TripleRow tripleRow) throws TripleRowResolverException { - return getTripleResolver().deserialize(table_layout, tripleRow); - } - - protected void addDefaultTriplePatternStrategies(boolean addPrefixHash) { - if (addPrefixHash){ - triplePatternStrategyList.add(new HashedSpoWholeRowTriplePatternStrategy()); - triplePatternStrategyList.add(new HashedPoWholeRowTriplePatternStrategy()); - } - else { - triplePatternStrategyList.add(new SpoWholeRowTriplePatternStrategy()); - triplePatternStrategyList.add(new PoWholeRowTriplePatternStrategy()); - } - triplePatternStrategyList.add(new OspWholeRowTriplePatternStrategy()); - } - - //retrieve triple pattern strategy - public TriplePatternStrategy retrieveStrategy(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context) { - for (TriplePatternStrategy strategy : triplePatternStrategyList) { - if (strategy.handles(subject, predicate, object, context)) - return strategy; - } - return null; - } - - public TriplePatternStrategy retrieveStrategy(RyaStatement stmt) { - return retrieveStrategy(stmt.getSubject(), stmt.getPredicate(), stmt.getObject(), stmt.getContext()); - } - - public TripleRowResolver getTripleResolver() { - return tripleResolver; - } - - public void setTripleResolver(TripleRowResolver tripleResolver) { - this.tripleResolver = tripleResolver; - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTypeResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTypeResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTypeResolver.java deleted file mode 100644 index 5b1cd20..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTypeResolver.java +++ /dev/null @@ -1,60 +0,0 @@ -package mvm.rya.api.resolver; - -/* - * 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. - */ - - - -import mvm.rya.api.domain.RyaRange; -import mvm.rya.api.domain.RyaType; -import mvm.rya.api.domain.RyaTypeRange; -import org.openrdf.model.URI; - -/** - * Date: 7/16/12 - * Time: 12:08 PM - */ -public interface RyaTypeResolver { - public byte[] serialize(RyaType ryaType) throws RyaTypeResolverException; - public byte[][] serializeType(RyaType ryaType) throws RyaTypeResolverException; - - public RyaType deserialize(byte[] bytes) throws RyaTypeResolverException; - - public RyaType newInstance(); - - /** - * @param bytes - * @return true if this byte[] is deserializable by this resolver - */ - public boolean deserializable(byte[] bytes); - - public URI getRyaDataType(); - - byte getMarkerByte(); - - /** - * This will allow a resolver to modify a range. For example, a date time resolver, with a reverse index, - * might want to reverse the start and stop - * - * @return - * @throws RyaTypeResolverException - */ - public RyaRange transformRange(RyaRange ryaRange) throws RyaTypeResolverException; - -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTypeResolverException.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTypeResolverException.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTypeResolverException.java deleted file mode 100644 index 45f874c..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTypeResolverException.java +++ /dev/null @@ -1,43 +0,0 @@ -package mvm.rya.api.resolver; - -/* - * 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. - */ - - - -/** - * Date: 7/16/12 - * Time: 12:09 PM - */ -public class RyaTypeResolverException extends Exception { - public RyaTypeResolverException() { - } - - public RyaTypeResolverException(String s) { - super(s); - } - - public RyaTypeResolverException(String s, Throwable throwable) { - super(s, throwable); - } - - public RyaTypeResolverException(Throwable throwable) { - super(throwable); - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTypeResolverMapping.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTypeResolverMapping.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTypeResolverMapping.java deleted file mode 100644 index 0c7a30a..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/RyaTypeResolverMapping.java +++ /dev/null @@ -1,57 +0,0 @@ -package mvm.rya.api.resolver; - -/* - * 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. - */ - - - -import org.openrdf.model.URI; - -/** - * Date: 7/16/12 - * Time: 12:11 PM - */ -public class RyaTypeResolverMapping { - - protected RyaTypeResolver ryaTypeResolver; - - public RyaTypeResolverMapping() { - } - - public RyaTypeResolverMapping(RyaTypeResolver ryaTypeResolver) { - this.ryaTypeResolver = ryaTypeResolver; - } - - public void setRyaTypeResolver(RyaTypeResolver ryaTypeResolver) { - this.ryaTypeResolver = ryaTypeResolver; - } - - public RyaTypeResolver getRyaTypeResolver() { - return ryaTypeResolver; - } - - public URI getRyaDataType() { - return ryaTypeResolver.getRyaDataType(); - } - - byte getMarkerByte() { - return ryaTypeResolver.getMarkerByte(); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/BooleanRyaTypeResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/BooleanRyaTypeResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/BooleanRyaTypeResolver.java deleted file mode 100644 index f5de2de..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/BooleanRyaTypeResolver.java +++ /dev/null @@ -1,61 +0,0 @@ -package mvm.rya.api.resolver.impl; - -/* - * 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. - */ - - - -import mvm.rya.api.resolver.RyaTypeResolverException; -import org.calrissian.mango.types.LexiTypeEncoders; -import org.calrissian.mango.types.TypeEncoder; -import org.calrissian.mango.types.exception.TypeDecodingException; -import org.calrissian.mango.types.exception.TypeEncodingException; -import org.openrdf.model.vocabulary.XMLSchema; - -public class BooleanRyaTypeResolver extends RyaTypeResolverImpl { - public static final int BOOLEAN_LITERAL_MARKER = 10; - public static final TypeEncoder<Boolean, String> BOOLEAN_TYPE_ENCODER = LexiTypeEncoders - .booleanEncoder(); - - public BooleanRyaTypeResolver() { - super((byte) BOOLEAN_LITERAL_MARKER, XMLSchema.BOOLEAN); - } - - @Override - protected String serializeData(String data) throws - RyaTypeResolverException { - try { - boolean value = Boolean.parseBoolean(data); - return BOOLEAN_TYPE_ENCODER.encode(value); - } catch (TypeEncodingException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } - } - - @Override - protected String deserializeData(String value) throws RyaTypeResolverException { - try { - return BOOLEAN_TYPE_ENCODER.decode(value).toString(); - } catch (TypeDecodingException e) { - throw new RyaTypeResolverException( - "Exception occurred deserializing data[" + value + "]", e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/ByteRyaTypeResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/ByteRyaTypeResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/ByteRyaTypeResolver.java deleted file mode 100644 index 4b80679..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/ByteRyaTypeResolver.java +++ /dev/null @@ -1,63 +0,0 @@ -package mvm.rya.api.resolver.impl; - -/* - * 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. - */ - - - -import mvm.rya.api.resolver.RyaTypeResolverException; -import org.calrissian.mango.types.LexiTypeEncoders; -import org.calrissian.mango.types.TypeEncoder; -import org.calrissian.mango.types.exception.TypeDecodingException; -import org.calrissian.mango.types.exception.TypeEncodingException; -import org.openrdf.model.vocabulary.XMLSchema; - -public class ByteRyaTypeResolver extends RyaTypeResolverImpl { - public static final int LITERAL_MARKER = 9; - public static final TypeEncoder<Byte, String> BYTE_STRING_TYPE_ENCODER = LexiTypeEncoders - .byteEncoder(); - - public ByteRyaTypeResolver() { - super((byte) LITERAL_MARKER, XMLSchema.BYTE); - } - - @Override - protected String serializeData(String data) throws RyaTypeResolverException { - try { - Byte value = Byte.parseByte(data); - return BYTE_STRING_TYPE_ENCODER.encode(value); - } catch (NumberFormatException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } catch (TypeEncodingException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } - } - - @Override - protected String deserializeData(String value) throws RyaTypeResolverException { - try { - return BYTE_STRING_TYPE_ENCODER.decode(value).toString(); - } catch (TypeDecodingException e) { - throw new RyaTypeResolverException( - "Exception occurred deserializing data[" + value + "]", e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/CustomDatatypeResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/CustomDatatypeResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/CustomDatatypeResolver.java deleted file mode 100644 index ae93e0f..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/CustomDatatypeResolver.java +++ /dev/null @@ -1,70 +0,0 @@ -package mvm.rya.api.resolver.impl; - -/* - * 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. - */ - - - -import com.google.common.primitives.Bytes; -import mvm.rya.api.domain.RyaType; -import mvm.rya.api.resolver.RyaTypeResolverException; -import org.openrdf.model.impl.URIImpl; -import static mvm.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTE; -import static mvm.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTES; - -/** - * Date: 7/16/12 - * Time: 1:12 PM - */ -public class CustomDatatypeResolver extends RyaTypeResolverImpl { - public static final int DT_LITERAL_MARKER = 8; - - public CustomDatatypeResolver() { - super((byte) DT_LITERAL_MARKER, null); - } - - @Override - public byte[][] serializeType(RyaType ryaType) throws RyaTypeResolverException { - byte[] bytes = serializeData(ryaType.getData()).getBytes(); - return new byte[][]{bytes, Bytes.concat(TYPE_DELIM_BYTES, ryaType.getDataType().stringValue().getBytes(), TYPE_DELIM_BYTES, markerBytes)}; - } - - @Override - public byte[] serialize(RyaType ryaType) throws RyaTypeResolverException { - byte[][] bytes = serializeType(ryaType); - return Bytes.concat(bytes[0], bytes[1]); - } - - @Override - public RyaType deserialize(byte[] bytes) throws RyaTypeResolverException { - if (!deserializable(bytes)) { - throw new RyaTypeResolverException("Bytes not deserializable"); - } - RyaType rt = newInstance(); - int length = bytes.length; - int indexOfType = Bytes.indexOf(bytes, TYPE_DELIM_BYTE); - if (indexOfType < 1) { - throw new RyaTypeResolverException("Not a datatype literal"); - } - String label = deserializeData(new String(bytes, 0, indexOfType)); - rt.setDataType(new URIImpl(new String(bytes, indexOfType + 1, (length - indexOfType) - 3))); - rt.setData(label); - return rt; - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/DateTimeRyaTypeResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/DateTimeRyaTypeResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/DateTimeRyaTypeResolver.java deleted file mode 100644 index cb3e7cf..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/DateTimeRyaTypeResolver.java +++ /dev/null @@ -1,76 +0,0 @@ -package mvm.rya.api.resolver.impl; - -/* - * 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. - */ - - - -import mvm.rya.api.resolver.RyaTypeResolverException; -import org.calrissian.mango.types.LexiTypeEncoders; -import org.calrissian.mango.types.TypeEncoder; -import org.calrissian.mango.types.exception.TypeDecodingException; -import org.calrissian.mango.types.exception.TypeEncodingException; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.format.DateTimeFormatter; -import org.joda.time.format.ISODateTimeFormat; -import org.openrdf.model.vocabulary.XMLSchema; - -import java.util.Date; - -/** - * Reverse index xml datetime strings - * <p/> - * Date: 7/13/12 - * Time: 7:33 AM - */ -public class DateTimeRyaTypeResolver extends RyaTypeResolverImpl { - public static final int DATETIME_LITERAL_MARKER = 7; - public static final TypeEncoder<Date, String> DATE_STRING_TYPE_ENCODER = LexiTypeEncoders.dateEncoder(); - public static final DateTimeFormatter XMLDATETIME_PARSER = org.joda.time.format.ISODateTimeFormat.dateTimeParser(); - public static final DateTimeFormatter UTC_XMLDATETIME_FORMATTER = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC); - - - public DateTimeRyaTypeResolver() { - super((byte) DATETIME_LITERAL_MARKER, XMLSchema.DATETIME); - } - - @Override - protected String serializeData(String data) throws RyaTypeResolverException { - try { - DateTime dateTime = DateTime.parse(data, XMLDATETIME_PARSER); - Date value = dateTime.toDate(); - return DATE_STRING_TYPE_ENCODER.encode(value); - } catch (TypeEncodingException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } - } - - @Override - protected String deserializeData(String value) throws RyaTypeResolverException { - try { - Date date = DATE_STRING_TYPE_ENCODER.decode(value); - return UTC_XMLDATETIME_FORMATTER.print(date.getTime()); - } catch (TypeDecodingException e) { - throw new RyaTypeResolverException( - "Exception occurred deserializing data[" + value + "]", e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/DoubleRyaTypeResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/DoubleRyaTypeResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/DoubleRyaTypeResolver.java deleted file mode 100644 index 88daa0f..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/DoubleRyaTypeResolver.java +++ /dev/null @@ -1,68 +0,0 @@ -package mvm.rya.api.resolver.impl; - -/* - * 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. - */ - - - -import mvm.rya.api.resolver.RyaTypeResolverException; -import org.calrissian.mango.types.LexiTypeEncoders; -import org.calrissian.mango.types.TypeEncoder; -import org.calrissian.mango.types.exception.TypeDecodingException; -import org.calrissian.mango.types.exception.TypeEncodingException; -import org.openrdf.model.vocabulary.XMLSchema; - -import java.text.DecimalFormat; - -/** - * Date: 7/20/12 - * Time: 9:33 AM - */ -public class DoubleRyaTypeResolver extends RyaTypeResolverImpl { - public static final int DOUBLE_LITERAL_MARKER = 6; - public static final TypeEncoder<Double, String> DOUBLE_TYPE_ENCODER = LexiTypeEncoders.doubleEncoder(); - - public DoubleRyaTypeResolver() { - super((byte) DOUBLE_LITERAL_MARKER, XMLSchema.DOUBLE); - } - - @Override - protected String serializeData(String data) throws RyaTypeResolverException { - try { - double value = Double.parseDouble(data); - return DOUBLE_TYPE_ENCODER.encode(value); - } catch (NumberFormatException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } catch (TypeEncodingException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } - } - - @Override - protected String deserializeData(String value) throws RyaTypeResolverException { - try { - return DOUBLE_TYPE_ENCODER.decode(value).toString(); - } catch (TypeDecodingException e) { - throw new RyaTypeResolverException( - "Exception occurred deserializing data[" + value + "]", e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/FloatRyaTypeResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/FloatRyaTypeResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/FloatRyaTypeResolver.java deleted file mode 100644 index 2969a4b..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/FloatRyaTypeResolver.java +++ /dev/null @@ -1,64 +0,0 @@ -package mvm.rya.api.resolver.impl; - -/* - * 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. - */ - - - -import mvm.rya.api.resolver.RyaTypeResolverException; -import org.calrissian.mango.types.LexiTypeEncoders; -import org.calrissian.mango.types.TypeEncoder; -import org.calrissian.mango.types.exception.TypeDecodingException; -import org.calrissian.mango.types.exception.TypeEncodingException; -import org.openrdf.model.vocabulary.XMLSchema; - -/** - */ -public class FloatRyaTypeResolver extends RyaTypeResolverImpl { - public static final int FLOAT_LITERAL_MARKER = 11; - public static final TypeEncoder<Float, String> FLOAT_TYPE_ENCODER = LexiTypeEncoders.floatEncoder(); - - public FloatRyaTypeResolver() { - super((byte) FLOAT_LITERAL_MARKER, XMLSchema.FLOAT); - } - - @Override - protected String serializeData(String data) throws RyaTypeResolverException { - try { - float value = Float.parseFloat(data); - return FLOAT_TYPE_ENCODER.encode(value); - } catch (NumberFormatException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } catch (TypeEncodingException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } - } - - @Override - protected String deserializeData(String value) throws RyaTypeResolverException { - try { - return FLOAT_TYPE_ENCODER.decode(value).toString(); - } catch (TypeDecodingException e) { - throw new RyaTypeResolverException( - "Exception occurred deserializing data[" + value + "]", e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/IntegerRyaTypeResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/IntegerRyaTypeResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/IntegerRyaTypeResolver.java deleted file mode 100644 index 2f6c727..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/IntegerRyaTypeResolver.java +++ /dev/null @@ -1,67 +0,0 @@ -package mvm.rya.api.resolver.impl; - -/* - * 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. - */ - - - -import mvm.rya.api.resolver.RyaTypeResolverException; -import org.calrissian.mango.types.LexiTypeEncoders; -import org.calrissian.mango.types.TypeEncoder; -import org.calrissian.mango.types.exception.TypeDecodingException; -import org.calrissian.mango.types.exception.TypeEncodingException; -import org.openrdf.model.vocabulary.XMLSchema; - -/** - * Date: 7/20/12 - * Time: 10:13 AM - */ -public class IntegerRyaTypeResolver extends RyaTypeResolverImpl { - public static final int INTEGER_LITERAL_MARKER = 5; - public static final TypeEncoder<Integer, String> INTEGER_STRING_TYPE_ENCODER = LexiTypeEncoders - .integerEncoder(); - - public IntegerRyaTypeResolver() { - super((byte) INTEGER_LITERAL_MARKER, XMLSchema.INTEGER); - } - - @Override - protected String serializeData(String data) throws - RyaTypeResolverException { - try { - return INTEGER_STRING_TYPE_ENCODER.encode(Integer.parseInt(data)); - } catch (NumberFormatException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } catch (TypeEncodingException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } - } - - @Override - protected String deserializeData(String value) throws RyaTypeResolverException { - try { - return INTEGER_STRING_TYPE_ENCODER.decode(value).toString(); - } catch (TypeDecodingException e) { - throw new RyaTypeResolverException( - "Exception occurred deserializing data[" + value + "]", e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/LongRyaTypeResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/LongRyaTypeResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/LongRyaTypeResolver.java deleted file mode 100644 index e073495..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/LongRyaTypeResolver.java +++ /dev/null @@ -1,68 +0,0 @@ -package mvm.rya.api.resolver.impl; - -/* - * 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. - */ - - - -import mvm.rya.api.resolver.RyaTypeResolverException; -import org.calrissian.mango.types.LexiTypeEncoders; -import org.calrissian.mango.types.TypeEncoder; -import org.calrissian.mango.types.exception.TypeDecodingException; -import org.calrissian.mango.types.exception.TypeEncodingException; -import org.openrdf.model.vocabulary.XMLSchema; - -/** - * Date: 7/20/12 - * Time: 10:13 AM - */ -public class LongRyaTypeResolver extends RyaTypeResolverImpl { - public static final int LONG_LITERAL_MARKER = 4; - public static final TypeEncoder<Long, String> LONG_STRING_TYPE_ENCODER = LexiTypeEncoders - .longEncoder(); - - public LongRyaTypeResolver() { - super((byte) LONG_LITERAL_MARKER, XMLSchema.LONG); - } - - @Override - protected String serializeData(String data) throws - RyaTypeResolverException { - try { - return LONG_STRING_TYPE_ENCODER.encode(Long.parseLong(data)); - } catch (NumberFormatException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } catch (TypeEncodingException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } - } - - @Override - protected String deserializeData(String value) - throws RyaTypeResolverException { - try { - return LONG_STRING_TYPE_ENCODER.decode(value).toString(); - } catch (TypeDecodingException e) { - throw new RyaTypeResolverException( - "Exception occurred deserializing data[" + value + "]", e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/RyaTypeResolverImpl.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/RyaTypeResolverImpl.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/RyaTypeResolverImpl.java deleted file mode 100644 index 3f4d6b8..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/RyaTypeResolverImpl.java +++ /dev/null @@ -1,124 +0,0 @@ -package mvm.rya.api.resolver.impl; - -/* - * 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. - */ - - - -import com.google.common.primitives.Bytes; -import mvm.rya.api.domain.RyaRange; -import mvm.rya.api.domain.RyaType; -import mvm.rya.api.resolver.RyaTypeResolver; -import mvm.rya.api.resolver.RyaTypeResolverException; -import org.calrissian.mango.types.LexiTypeEncoders; -import org.calrissian.mango.types.TypeEncoder; -import org.openrdf.model.URI; -import org.openrdf.model.vocabulary.XMLSchema; - -import static mvm.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTE; -import static mvm.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTES; - -/** - * Date: 7/16/12 - * Time: 12:42 PM - */ -public class RyaTypeResolverImpl implements RyaTypeResolver { - public static final int PLAIN_LITERAL_MARKER = 3; - public static final TypeEncoder<String, String> STRING_TYPE_ENCODER = LexiTypeEncoders - .stringEncoder(); - - protected byte markerByte; - protected URI dataType; - protected byte[] markerBytes; - - public RyaTypeResolverImpl() { - this((byte) PLAIN_LITERAL_MARKER, XMLSchema.STRING); - } - - public RyaTypeResolverImpl(byte markerByte, URI dataType) { - setMarkerByte(markerByte); - setRyaDataType(dataType); - } - - public void setMarkerByte(byte markerByte) { - this.markerByte = markerByte; - this.markerBytes = new byte[]{markerByte}; - } - - @Override - public byte getMarkerByte() { - return markerByte; - } - - @Override - public RyaRange transformRange(RyaRange ryaRange) throws RyaTypeResolverException { - return ryaRange; - } - - @Override - public byte[] serialize(RyaType ryaType) throws RyaTypeResolverException { - byte[][] bytes = serializeType(ryaType); - return Bytes.concat(bytes[0], bytes[1]); - } - - @Override - public byte[][] serializeType(RyaType ryaType) throws RyaTypeResolverException { - byte[] bytes = serializeData(ryaType.getData()).getBytes(); - return new byte[][]{bytes, Bytes.concat(TYPE_DELIM_BYTES, markerBytes)}; - } - - @Override - public URI getRyaDataType() { - return dataType; - } - - public void setRyaDataType(URI dataType) { - this.dataType = dataType; - } - - @Override - public RyaType newInstance() { - return new RyaType(); - } - - @Override - public boolean deserializable(byte[] bytes) { - return bytes != null && bytes.length >= 2 && bytes[bytes.length - 1] == getMarkerByte() && bytes[bytes.length - 2] == TYPE_DELIM_BYTE; - } - - protected String serializeData(String data) throws RyaTypeResolverException { - return STRING_TYPE_ENCODER.encode(data); - } - - @Override - public RyaType deserialize(byte[] bytes) throws RyaTypeResolverException { - if (!deserializable(bytes)) { - throw new RyaTypeResolverException("Bytes not deserializable"); - } - RyaType rt = newInstance(); - rt.setDataType(getRyaDataType()); - String data = new String(bytes, 0, bytes.length - 2); - rt.setData(deserializeData(data)); - return rt; - } - - protected String deserializeData(String data) throws RyaTypeResolverException { - return STRING_TYPE_ENCODER.decode(data); - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/RyaURIResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/RyaURIResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/RyaURIResolver.java deleted file mode 100644 index 8f8bf00..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/RyaURIResolver.java +++ /dev/null @@ -1,44 +0,0 @@ -package mvm.rya.api.resolver.impl; - -/* - * 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. - */ - - - -import mvm.rya.api.domain.RyaType; -import mvm.rya.api.domain.RyaURI; -import org.openrdf.model.vocabulary.XMLSchema; - -/** - * Date: 7/16/12 - * Time: 12:41 PM - */ -public class RyaURIResolver extends RyaTypeResolverImpl { - - public static final int URI_MARKER = 2; - - public RyaURIResolver() { - super((byte) URI_MARKER, XMLSchema.ANYURI); - } - - @Override - public RyaType newInstance() { - return new RyaURI(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/ServiceBackedRyaTypeResolverMappings.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/ServiceBackedRyaTypeResolverMappings.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/ServiceBackedRyaTypeResolverMappings.java deleted file mode 100644 index ce3f05b..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/ServiceBackedRyaTypeResolverMappings.java +++ /dev/null @@ -1,45 +0,0 @@ -package mvm.rya.api.resolver.impl; - -/* - * 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. - */ - - - -import mvm.rya.api.resolver.RyaTypeResolver; -import mvm.rya.api.resolver.RyaTypeResolverMapping; - -import java.util.ArrayList; -import java.util.List; -import java.util.ServiceLoader; - -/** - * Date: 8/29/12 - * Time: 2:04 PM - */ -public class ServiceBackedRyaTypeResolverMappings { - - public List<RyaTypeResolverMapping> getResolvers() { - ServiceLoader<RyaTypeResolver> loader = ServiceLoader.load(RyaTypeResolver.class); - List<RyaTypeResolverMapping> resolvers = new ArrayList<RyaTypeResolverMapping>(); - for (RyaTypeResolver aLoader : loader) { - resolvers.add(new RyaTypeResolverMapping(aLoader)); - } - return resolvers; - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/ShortRyaTypeResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/ShortRyaTypeResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/ShortRyaTypeResolver.java deleted file mode 100644 index dba9773..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/impl/ShortRyaTypeResolver.java +++ /dev/null @@ -1,65 +0,0 @@ -package mvm.rya.api.resolver.impl; - -/* - * 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. - */ - - - -import mvm.rya.api.resolver.RyaTypeResolverException; -import org.calrissian.mango.types.LexiTypeEncoders; -import org.calrissian.mango.types.TypeEncoder; -import org.calrissian.mango.types.exception.TypeDecodingException; -import org.calrissian.mango.types.exception.TypeEncodingException; -import org.openrdf.model.vocabulary.XMLSchema; - -/** - */ -public class ShortRyaTypeResolver extends RyaTypeResolverImpl { - public static final int INTEGER_LITERAL_MARKER = 12; - public static final TypeEncoder<Integer, String> INTEGER_STRING_TYPE_ENCODER = LexiTypeEncoders - .integerEncoder(); - - public ShortRyaTypeResolver() { - super((byte) INTEGER_LITERAL_MARKER, XMLSchema.SHORT); - } - - @Override - protected String serializeData(String data) throws - RyaTypeResolverException { - try { - return INTEGER_STRING_TYPE_ENCODER.encode(Integer.parseInt(data)); - } catch (NumberFormatException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } catch (TypeEncodingException e) { - throw new RyaTypeResolverException( - "Exception occurred serializing data[" + data + "]", e); - } - } - - @Override - protected String deserializeData(String value) throws RyaTypeResolverException { - try { - return INTEGER_STRING_TYPE_ENCODER.decode(value).toString(); - } catch (TypeDecodingException e) { - throw new RyaTypeResolverException( - "Exception occurred deserializing data[" + value + "]", e); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRow.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRow.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRow.java deleted file mode 100644 index f825e86..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRow.java +++ /dev/null @@ -1,107 +0,0 @@ -package mvm.rya.api.resolver.triple; - -/* - * 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. - */ - - - -import java.util.Arrays; - -/** - * Date: 7/13/12 - * Time: 8:54 AM - */ -public class TripleRow { - private byte[] row, columnFamily, columnQualifier, columnVisibility, value; - private Long timestamp; - - public TripleRow(byte[] row, byte[] columnFamily, byte[] columnQualifier) { - this(row, columnFamily, columnQualifier, null, null, null); - } - public TripleRow(byte[] row, byte[] columnFamily, byte[] columnQualifier, Long timestamp, - byte[] columnVisibility, byte[] value) { - this.row = row; - this.columnFamily = columnFamily; - this.columnQualifier = columnQualifier; - //Default TS to current time to ensure the timestamps on all the tables are the same for the same triple - this.timestamp = timestamp != null ? timestamp : System.currentTimeMillis(); - this.columnVisibility = columnVisibility; - this.value = value; - } - - public byte[] getRow() { - return row; - } - - public byte[] getColumnFamily() { - return columnFamily; - } - - public byte[] getColumnQualifier() { - return columnQualifier; - } - - public byte[] getColumnVisibility() { - return columnVisibility; - } - - public byte[] getValue() { - return value; - } - - public Long getTimestamp() { - return timestamp; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TripleRow tripleRow = (TripleRow) o; - - if (!Arrays.equals(columnFamily, tripleRow.columnFamily)) return false; - if (!Arrays.equals(columnQualifier, tripleRow.columnQualifier)) return false; - if (!Arrays.equals(row, tripleRow.row)) return false; - - return true; - } - - @Override - public int hashCode() { - int result = row != null ? Arrays.hashCode(row) : 0; - result = 31 * result + (columnFamily != null ? Arrays.hashCode(columnFamily) : 0); - result = 31 * result + (columnQualifier != null ? Arrays.hashCode(columnQualifier) : 0); - result = 31 * result + (columnVisibility != null ? Arrays.hashCode(columnVisibility) : 0); - result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "TripleRow{" + - "row=" + row + - ", columnFamily=" + columnFamily + - ", columnQualifier=" + columnQualifier + - ", columnVisibility=" + columnVisibility + - ", value=" + value + - ", timestamp=" + timestamp + - '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRowRegex.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRowRegex.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRowRegex.java deleted file mode 100644 index 36d23df..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRowRegex.java +++ /dev/null @@ -1,84 +0,0 @@ -package mvm.rya.api.resolver.triple; - -/* - * 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. - */ - - - -import java.util.Arrays; - -/** - * Date: 7/13/12 - * Time: 8:54 AM - */ -public class TripleRowRegex { - private String row, columnFamily, columnQualifier; - - public TripleRowRegex(String row, String columnFamily, String columnQualifier) { - this.row = row; - this.columnFamily = columnFamily; - this.columnQualifier = columnQualifier; - } - - public String getRow() { - return row; - } - - public String getColumnFamily() { - return columnFamily; - } - - public String getColumnQualifier() { - return columnQualifier; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - TripleRowRegex that = (TripleRowRegex) o; - - if (columnFamily != null ? !columnFamily.equals(that.columnFamily) : that.columnFamily != null) return false; - if (columnQualifier != null ? !columnQualifier.equals(that.columnQualifier) : that.columnQualifier != null) - return false; - if (row != null ? !row.equals(that.row) : that.row != null) return false; - - return true; - } - - @Override - public int hashCode() { - int result = row != null ? row.hashCode() : 0; - result = 31 * result + (columnFamily != null ? columnFamily.hashCode() : 0); - result = 31 * result + (columnQualifier != null ? columnQualifier.hashCode() : 0); - return result; - } - - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("TripleRowRegex"); - sb.append("{row='").append(row).append('\''); - sb.append(", columnFamily='").append(columnFamily).append('\''); - sb.append(", columnQualifier='").append(columnQualifier).append('\''); - sb.append('}'); - return sb.toString(); - } -}
