You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rya.apache.org by ca...@apache.org on 2017/10/12 18:43:28 UTC
[07/11] incubator-rya git commit: RYA-401 Fixed all default charset
bugs. Closes #243.
RYA-401 Fixed all default charset bugs. Closes #243.
- Added findbugs policy to build.
- removed the maven-surefire-plugin's -Dfile.encoding=UTF-8 argLine
Project: http://git-wip-us.apache.org/repos/asf/incubator-rya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rya/commit/538cfccc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rya/tree/538cfccc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rya/diff/538cfccc
Branch: refs/heads/master
Commit: 538cfccc8ce7b6cfda564a0160f6382209fdfdff
Parents: 4089e70
Author: jdasch <hc...@gmail.com>
Authored: Wed Oct 11 09:10:38 2017 -0400
Committer: jdasch <hc...@gmail.com>
Committed: Thu Oct 12 12:52:52 2017 -0400
----------------------------------------------------------------------
.../rya/api/RdfCloudTripleStoreConstants.java | 21 +-
.../org/apache/rya/api/domain/RyaStatement.java | 120 +-
.../java/org/apache/rya/api/domain/RyaType.java | 58 +-
.../strategy/AbstractTriplePatternStrategy.java | 26 +-
.../AbstractHashedTriplePatternStrategy.java | 26 +-
.../HashedPoWholeRowTriplePatternStrategy.java | 73 +-
.../HashedSpoWholeRowTriplePatternStrategy.java | 89 +-
.../OspWholeRowTriplePatternStrategy.java | 36 +-
.../PoWholeRowTriplePatternStrategy.java | 70 +-
.../SpoWholeRowTriplePatternStrategy.java | 62 +-
.../resolver/impl/CustomDatatypeResolver.java | 37 +-
.../api/resolver/impl/RyaTypeResolverImpl.java | 42 +-
.../impl/WholeRowHashedTripleResolver.java | 137 ++-
.../triple/impl/WholeRowTripleResolver.java | 109 +-
.../AccumuloNamespaceTableIterator.java | 44 +-
.../rya/accumulo/AccumuloRdfEvalStatsDAO.java | 85 +-
.../org/apache/rya/accumulo/AccumuloRyaDAO.java | 10 +-
.../dao/SimpleMongoDBNamespaceManager.java | 88 +-
.../dao/SimpleMongoDBStorageStrategy.java | 6 +-
.../DocumentIndexIntersectingIterator.java | 18 +-
.../java/org/apache/rya/indexing/KeyParts.java | 7 +-
.../accumulo/entity/AccumuloDocIdIndexer.java | 117 +-
.../accumulo/entity/EntityCentricIndex.java | 56 +-
.../rya/indexing/accumulo/entity/StarQuery.java | 123 +-
.../freetext/iterators/AndingIterator.java | 169 +--
.../freetext/query/SimpleCharStream.java | 1057 ++----------------
.../src/main/java/RyaDirectExample.java | 14 +-
.../serialization/BindingSetSerDe.java | 47 +-
.../export/accumulo/util/AccumuloRyaUtils.java | 5 +-
.../client/merge/VisibilityStatementMerger.java | 8 +-
.../apache/rya/accumulo/mr/merge/CopyTool.java | 17 +-
.../mr/merge/util/AccumuloRyaUtils.java | 19 +-
.../accumulo/mr/merge/util/QueryRuleset.java | 48 +-
.../pcj/fluo/demo/FluoAndHistoricPcjsDemo.java | 3 +-
.../joinselect/mr/JoinSelectProspectOutput.java | 64 +-
.../rya/prospector/plans/impl/CountPlan.java | 17 +-
.../rya/prospector/utils/ProspectorUtils.java | 19 +-
.../rya/reasoning/mr/ConformanceTest.java | 118 +-
.../rya/accumulo/mr/GraphXEdgeInputFormat.java | 74 +-
.../apache/rya/accumulo/mr/RyaOutputFormat.java | 155 +--
.../accumulo/mr/tools/AccumuloRdfCountTool.java | 100 +-
.../apache/rya/camel/cbsail/CbSailProducer.java | 99 +-
.../rya/accumulo/pig/AccumuloStorage.java | 145 +--
.../rya/accumulo/pig/IndexWritingTool.java | 168 ++-
.../rya/accumulo/pig/SparqlQueryPigEngine.java | 111 +-
.../accumulo/pig/StatementPatternStorage.java | 38 +-
pom.xml | 30 +-
.../RdfCloudTripleStoreConnection.java | 8 +-
48 files changed, 1615 insertions(+), 2378 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/common/rya.api/src/main/java/org/apache/rya/api/RdfCloudTripleStoreConstants.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/RdfCloudTripleStoreConstants.java b/common/rya.api/src/main/java/org/apache/rya/api/RdfCloudTripleStoreConstants.java
index 2092951..dd7ada0 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/RdfCloudTripleStoreConstants.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/RdfCloudTripleStoreConstants.java
@@ -1,7 +1,3 @@
-package org.apache.rya.api;
-
-import org.apache.hadoop.io.Text;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -10,9 +6,9 @@ import org.apache.hadoop.io.Text;
* 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
@@ -20,9 +16,11 @@ import org.apache.hadoop.io.Text;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.api;
+import java.nio.charset.StandardCharsets;
-
+import org.apache.hadoop.io.Text;
import org.apache.rya.api.domain.RyaSchema;
import org.apache.rya.api.domain.RyaType;
import org.apache.rya.api.domain.RyaURI;
@@ -89,8 +87,9 @@ public class RdfCloudTripleStoreConstants {
public static Text TBL_NAMESPACE_TXT = new Text(TBL_NAMESPACE);
public static void prefixTables(String prefix) {
- if (prefix == null)
+ if (prefix == null) {
prefix = TBL_PRFX_DEF;
+ }
TBL_SPO = prefix + TBL_SPO_SUFFIX;
TBL_PO = prefix + TBL_PO_SUFFIX;
TBL_OSP = prefix + TBL_OSP_SUFFIX;
@@ -115,9 +114,9 @@ public class RdfCloudTripleStoreConstants {
public static final String DELIM = "\u0000";
public static final String DELIM_STOP = "\u0001";
public static final String LAST = "\uFFDD";
- public static final String TYPE_DELIM = new String(TYPE_DELIM_BYTES);
- public static final byte[] DELIM_BYTES = DELIM.getBytes();
- public static final byte[] DELIM_STOP_BYTES = DELIM_STOP.getBytes();
+ public static final String TYPE_DELIM = new String(TYPE_DELIM_BYTES, StandardCharsets.UTF_8);
+ public static final byte[] DELIM_BYTES = DELIM.getBytes(StandardCharsets.UTF_8);
+ public static final byte[] DELIM_STOP_BYTES = DELIM_STOP.getBytes(StandardCharsets.UTF_8);
/* RECORD TYPES */
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/common/rya.api/src/main/java/org/apache/rya/api/domain/RyaStatement.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/domain/RyaStatement.java b/common/rya.api/src/main/java/org/apache/rya/api/domain/RyaStatement.java
index de41be9..eac6740 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/domain/RyaStatement.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/domain/RyaStatement.java
@@ -1,5 +1,3 @@
-package org.apache.rya.api.domain;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -8,9 +6,9 @@ package org.apache.rya.api.domain;
* 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
@@ -18,9 +16,9 @@ package org.apache.rya.api.domain;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.api.domain;
-
-
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
/**
@@ -40,34 +38,34 @@ public class RyaStatement {
public RyaStatement() {
}
- public RyaStatement(RyaURI subject, RyaURI predicate, RyaType object) {
+ public RyaStatement(final RyaURI subject, final RyaURI predicate, final RyaType object) {
this(subject, predicate, object, null);
}
- public RyaStatement(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context) {
+ public RyaStatement(final RyaURI subject, final RyaURI predicate, final RyaType object, final RyaURI context) {
this(subject, predicate, object, context, null);
}
- public RyaStatement(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context, String qualifier) {
+ public RyaStatement(final RyaURI subject, final RyaURI predicate, final RyaType object, final RyaURI context, final String qualifier) {
this(subject, predicate, object, context, qualifier, new StatementMetadata());
}
- public RyaStatement(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context, String qualifier, StatementMetadata metadata) {
+ public RyaStatement(final RyaURI subject, final RyaURI predicate, final RyaType object, final RyaURI context, final String qualifier, final StatementMetadata metadata) {
this(subject, predicate, object, context, qualifier, metadata, null);
}
- public RyaStatement(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context, String qualifier, StatementMetadata metadata, byte[] columnVisibility) {
+ public RyaStatement(final RyaURI subject, final RyaURI predicate, final RyaType object, final RyaURI context, final String qualifier, final StatementMetadata metadata, final byte[] columnVisibility) {
this(subject, predicate, object, context, qualifier, columnVisibility, metadata.toBytes());
}
@Deprecated
- public RyaStatement(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context, String qualifier, byte[] columnVisibility, byte[] value) {
+ public RyaStatement(final RyaURI subject, final RyaURI predicate, final RyaType object, final RyaURI context, final String qualifier, final byte[] columnVisibility, final byte[] value) {
this(subject, predicate, object, context, qualifier, columnVisibility, value, null);
}
@Deprecated
- public RyaStatement(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context, String qualifier, byte[] columnVisibility, byte[] value, Long timestamp) {
+ public RyaStatement(final RyaURI subject, final RyaURI predicate, final RyaType object, final RyaURI context, final String qualifier, final byte[] columnVisibility, final byte[] value, final Long timestamp) {
this.subject = subject;
this.predicate = predicate;
this.object = object;
@@ -82,7 +80,7 @@ public class RyaStatement {
return subject;
}
- public void setSubject(RyaURI subject) {
+ public void setSubject(final RyaURI subject) {
this.subject = subject;
}
@@ -90,7 +88,7 @@ public class RyaStatement {
return predicate;
}
- public void setPredicate(RyaURI predicate) {
+ public void setPredicate(final RyaURI predicate) {
this.predicate = predicate;
}
@@ -98,7 +96,7 @@ public class RyaStatement {
return object;
}
- public void setObject(RyaType object) {
+ public void setObject(final RyaType object) {
this.object = object;
}
@@ -106,7 +104,7 @@ public class RyaStatement {
return context;
}
- public void setContext(RyaURI context) {
+ public void setContext(final RyaURI context) {
this.context = context;
}
@@ -114,22 +112,22 @@ public class RyaStatement {
return columnVisibility;
}
- public void setColumnVisibility(byte[] columnVisibility) {
+ public void setColumnVisibility(final byte[] columnVisibility) {
this.columnVisibility = columnVisibility;
}
-
+
public StatementMetadata getMetadata() {
- // try to deserialize the value, if not assume that there was
+ // try to deserialize the value, if not assume that there was
// no explicit metadata
try {
return new StatementMetadata(value);
}
- catch (Exception ex){
+ catch (final Exception ex){
return null;
}
}
-
- public void setStatementMetadata(StatementMetadata metadata){
+
+ public void setStatementMetadata(final StatementMetadata metadata){
this.value = metadata.toBytes();
}
@@ -139,7 +137,7 @@ public class RyaStatement {
}
@Deprecated
- public void setValue(byte[] value) {
+ public void setValue(final byte[] value) {
this.value = value;
}
@@ -147,25 +145,45 @@ public class RyaStatement {
return timestamp;
}
- public void setTimestamp(Long timestamp) {
+ public void setTimestamp(final Long timestamp) {
this.timestamp = timestamp;
}
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
- RyaStatement that = (RyaStatement) o;
+ final RyaStatement that = (RyaStatement) o;
- if (!Arrays.equals(columnVisibility, that.columnVisibility)) return false;
- if (context != null ? !context.equals(that.context) : that.context != null) return false;
- if (object != null ? !object.equals(that.object) : that.object != null) return false;
- if (predicate != null ? !predicate.equals(that.predicate) : that.predicate != null) return false;
- if (qualifer != null ? !qualifer.equals(that.qualifer) : that.qualifer != null) return false;
- if (subject != null ? !subject.equals(that.subject) : that.subject != null) return false;
- if (timestamp != null ? !timestamp.equals(that.timestamp) : that.timestamp != null) return false;
- if (!Arrays.equals(value, that.value)) return false;
+ if (!Arrays.equals(columnVisibility, that.columnVisibility)) {
+ return false;
+ }
+ if (context != null ? !context.equals(that.context) : that.context != null) {
+ return false;
+ }
+ if (object != null ? !object.equals(that.object) : that.object != null) {
+ return false;
+ }
+ if (predicate != null ? !predicate.equals(that.predicate) : that.predicate != null) {
+ return false;
+ }
+ if (qualifer != null ? !qualifer.equals(that.qualifer) : that.qualifer != null) {
+ return false;
+ }
+ if (subject != null ? !subject.equals(that.subject) : that.subject != null) {
+ return false;
+ }
+ if (timestamp != null ? !timestamp.equals(that.timestamp) : that.timestamp != null) {
+ return false;
+ }
+ if (!Arrays.equals(value, that.value)) {
+ return false;
+ }
return true;
}
@@ -187,7 +205,7 @@ public class RyaStatement {
return qualifer;
}
- public void setQualifer(String qualifer) {
+ public void setQualifer(final String qualifer) {
this.qualifer = qualifer;
}
@@ -200,8 +218,8 @@ public class RyaStatement {
sb.append(", object=").append(object);
sb.append(", context=").append(context);
sb.append(", qualifier=").append(qualifer);
- sb.append(", columnVisibility=").append(columnVisibility == null ? "null" : new String(columnVisibility));
- sb.append(", value=").append(value == null ? "null" : new String(value));
+ sb.append(", columnVisibility=").append(columnVisibility == null ? "null" : new String(columnVisibility, StandardCharsets.UTF_8));
+ sb.append(", value=").append(value == null ? "null" : new String(value, StandardCharsets.UTF_8));
sb.append(", timestamp=").append(timestamp);
sb.append('}');
return sb.toString();
@@ -211,7 +229,7 @@ public class RyaStatement {
return new RyaStatementBuilder();
}
- public static RyaStatementBuilder builder(RyaStatement ryaStatement) {
+ public static RyaStatementBuilder builder(final RyaStatement ryaStatement) {
return new RyaStatementBuilder(ryaStatement);
}
@@ -225,52 +243,52 @@ public class RyaStatement {
ryaStatement = new RyaStatement();
}
- public RyaStatementBuilder(RyaStatement ryaStatement) {
+ public RyaStatementBuilder(final RyaStatement ryaStatement) {
this.ryaStatement = ryaStatement;
}
- public RyaStatementBuilder setTimestamp(Long timestamp) {
+ public RyaStatementBuilder setTimestamp(final Long timestamp) {
ryaStatement.setTimestamp(timestamp);
return this;
}
@Deprecated
- public RyaStatementBuilder setValue(byte[] value) {
+ public RyaStatementBuilder setValue(final byte[] value) {
ryaStatement.setValue(value);
return this;
}
- public RyaStatementBuilder setMetadata(StatementMetadata metadata) {
+ public RyaStatementBuilder setMetadata(final StatementMetadata metadata) {
ryaStatement.setValue(metadata.toBytes());
return this;
}
- public RyaStatementBuilder setColumnVisibility(byte[] columnVisibility) {
+ public RyaStatementBuilder setColumnVisibility(final byte[] columnVisibility) {
ryaStatement.setColumnVisibility(columnVisibility);
return this;
}
- public RyaStatementBuilder setQualifier(String str) {
+ public RyaStatementBuilder setQualifier(final String str) {
ryaStatement.setQualifer(str);
return this;
}
- public RyaStatementBuilder setContext(RyaURI ryaURI) {
+ public RyaStatementBuilder setContext(final RyaURI ryaURI) {
ryaStatement.setContext(ryaURI);
return this;
}
- public RyaStatementBuilder setSubject(RyaURI ryaURI) {
+ public RyaStatementBuilder setSubject(final RyaURI ryaURI) {
ryaStatement.setSubject(ryaURI);
return this;
}
- public RyaStatementBuilder setPredicate(RyaURI ryaURI) {
+ public RyaStatementBuilder setPredicate(final RyaURI ryaURI) {
ryaStatement.setPredicate(ryaURI);
return this;
}
- public RyaStatementBuilder setObject(RyaType ryaType) {
+ public RyaStatementBuilder setObject(final RyaType ryaType) {
ryaStatement.setObject(ryaType);
return this;
}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/common/rya.api/src/main/java/org/apache/rya/api/domain/RyaType.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/domain/RyaType.java b/common/rya.api/src/main/java/org/apache/rya/api/domain/RyaType.java
index 94a0ecf..ab5306e 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/domain/RyaType.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/domain/RyaType.java
@@ -1,5 +1,3 @@
-package org.apache.rya.api.domain;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -8,9 +6,9 @@ package org.apache.rya.api.domain;
* 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
@@ -18,9 +16,7 @@ package org.apache.rya.api.domain;
* specific language governing permissions and limitations
* under the License.
*/
-
-
-
+package org.apache.rya.api.domain;
import org.openrdf.model.URI;
import org.openrdf.model.vocabulary.XMLSchema;
@@ -39,12 +35,12 @@ public class RyaType implements Comparable {
setDataType(XMLSchema.STRING);
}
- public RyaType(String data) {
+ public RyaType(final String data) {
this(XMLSchema.STRING, data);
}
- public RyaType(URI dataType, String data) {
+ public RyaType(final URI dataType, final String data) {
setDataType(dataType);
setData(data);
}
@@ -62,11 +58,11 @@ public class RyaType implements Comparable {
return data;
}
- public void setDataType(URI dataType) {
+ public void setDataType(final URI dataType) {
this.dataType = dataType;
}
- public void setData(String data) {
+ public void setData(final String data) {
this.data = data;
}
@@ -86,12 +82,20 @@ public class RyaType implements Comparable {
* @return true if the other object is also a RyaType and both data and datatype match.
*/
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || !(o instanceof RyaType)) return false;
- RyaType ryaType = (RyaType) o;
- if (data != null ? !data.equals(ryaType.data) : ryaType.data != null) return false;
- if (dataType != null ? !dataType.equals(ryaType.dataType) : ryaType.dataType != null) return false;
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || !(o instanceof RyaType)) {
+ return false;
+ }
+ final RyaType ryaType = (RyaType) o;
+ if (data != null ? !data.equals(ryaType.data) : ryaType.data != null) {
+ return false;
+ }
+ if (dataType != null ? !dataType.equals(ryaType.dataType) : ryaType.dataType != null) {
+ return false;
+ }
return true;
}
@@ -114,19 +118,27 @@ public class RyaType implements Comparable {
* Otherwise, an integer whose sign yields a consistent ordering.
*/
@Override
- public int compareTo(Object o) {
+ public int compareTo(final Object o) {
int result = -1;
if (o != null && o instanceof RyaType) {
result = 0;
- RyaType other = (RyaType) o;
+ final RyaType other = (RyaType) o;
if (this.data != other.data) {
- if (this.data == null) return 1;
- if (other.data == null) return -1;
+ if (this.data == null) {
+ return 1;
+ }
+ if (other.data == null) {
+ return -1;
+ }
result = this.data.compareTo(other.data);
}
if (result == 0 && this.dataType != other.dataType) {
- if (this.dataType == null) return 1;
- if (other.dataType == null) return -1;
+ if (this.dataType == null) {
+ return 1;
+ }
+ if (other.dataType == null) {
+ return -1;
+ }
result = this.dataType.toString().compareTo(other.dataType.toString());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/AbstractTriplePatternStrategy.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/AbstractTriplePatternStrategy.java b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/AbstractTriplePatternStrategy.java
index 0224787..814fe5f 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/AbstractTriplePatternStrategy.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/AbstractTriplePatternStrategy.java
@@ -1,5 +1,3 @@
-package org.apache.rya.api.query.strategy;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -8,9 +6,9 @@ package org.apache.rya.api.query.strategy;
* 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
@@ -18,16 +16,17 @@ package org.apache.rya.api.query.strategy;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.api.query.strategy;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.DELIM;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM;
+import java.nio.charset.StandardCharsets;
-import com.google.common.base.Preconditions;
import org.apache.rya.api.RdfCloudTripleStoreConstants;
-import org.apache.rya.api.resolver.RyaContext;
import org.apache.rya.api.resolver.triple.TripleRowRegex;
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.DELIM;
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM;
+import com.google.common.base.Preconditions;
/**
* Date: 7/14/12
@@ -36,16 +35,17 @@ import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM;
public abstract class AbstractTriplePatternStrategy implements TriplePatternStrategy {
public static final String ALL_REGEX = "([\\s\\S]*)";
+ @Override
public abstract RdfCloudTripleStoreConstants.TABLE_LAYOUT getLayout();
@Override
- public TripleRowRegex buildRegex(String subject, String predicate, String object, String context, byte[] objectTypeInfo) {
- RdfCloudTripleStoreConstants.TABLE_LAYOUT table_layout = getLayout();
+ public TripleRowRegex buildRegex(final String subject, final String predicate, final String object, final String context, final byte[] objectTypeInfo) {
+ final RdfCloudTripleStoreConstants.TABLE_LAYOUT table_layout = getLayout();
Preconditions.checkNotNull(table_layout);
if (subject == null && predicate == null && object == null && context == null && objectTypeInfo == null) {
return null; //no regex
}
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
String first = subject;
String second = predicate;
String third = object;
@@ -79,12 +79,12 @@ public abstract class AbstractTriplePatternStrategy implements TriplePatternStra
sb.append(TYPE_DELIM);
sb.append(ALL_REGEX);
}else {
- sb.append(new String(objectTypeInfo));
+ sb.append(new String(objectTypeInfo, StandardCharsets.UTF_8));
}
}else {
sb.append(ALL_REGEX);
if (objectTypeInfo != null) {
- sb.append(new String(objectTypeInfo));
+ sb.append(new String(objectTypeInfo, StandardCharsets.UTF_8));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/AbstractHashedTriplePatternStrategy.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/AbstractHashedTriplePatternStrategy.java b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/AbstractHashedTriplePatternStrategy.java
index 60853f1..140a301 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/AbstractHashedTriplePatternStrategy.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/AbstractHashedTriplePatternStrategy.java
@@ -1,4 +1,3 @@
-package org.apache.rya.api.query.strategy.wholerow;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -7,9 +6,9 @@ package org.apache.rya.api.query.strategy.wholerow;
* 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
@@ -17,24 +16,29 @@ package org.apache.rya.api.query.strategy.wholerow;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.api.query.strategy.wholerow;
+
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.DELIM;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM;
+
+import java.nio.charset.StandardCharsets;
-import com.google.common.base.Preconditions;
import org.apache.rya.api.RdfCloudTripleStoreConstants;
import org.apache.rya.api.query.strategy.AbstractTriplePatternStrategy;
import org.apache.rya.api.query.strategy.TriplePatternStrategy;
import org.apache.rya.api.resolver.triple.TripleRowRegex;
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.DELIM;
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM;
+import com.google.common.base.Preconditions;
public abstract class AbstractHashedTriplePatternStrategy extends AbstractTriplePatternStrategy implements TriplePatternStrategy {
public static final String HASHED_ALL_REGEX = "([0-9a-f]{32})\u0000";
+ @Override
public abstract RdfCloudTripleStoreConstants.TABLE_LAYOUT getLayout();
@Override
- public TripleRowRegex buildRegex(String subject, String predicate, String object, String context, byte[] objectTypeInfo) {
- RdfCloudTripleStoreConstants.TABLE_LAYOUT table_layout = getLayout();
+ public TripleRowRegex buildRegex(final String subject, final String predicate, final String object, final String context, final byte[] objectTypeInfo) {
+ final RdfCloudTripleStoreConstants.TABLE_LAYOUT table_layout = getLayout();
Preconditions.checkNotNull(table_layout);
//O is not hashed so kick out to super
@@ -45,7 +49,7 @@ public abstract class AbstractHashedTriplePatternStrategy extends AbstractTriple
if (subject == null && predicate == null && object == null && context == null && objectTypeInfo == null) {
return null; //no regex
}
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
String first = subject;
String second = predicate;
String third = object;
@@ -76,12 +80,12 @@ public abstract class AbstractHashedTriplePatternStrategy extends AbstractTriple
sb.append(TYPE_DELIM);
sb.append(ALL_REGEX);
}else {
- sb.append(new String(objectTypeInfo));
+ sb.append(new String(objectTypeInfo, StandardCharsets.UTF_8));
}
}else {
sb.append(ALL_REGEX);
if (objectTypeInfo != null) {
- sb.append(new String(objectTypeInfo));
+ sb.append(new String(objectTypeInfo, StandardCharsets.UTF_8));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/HashedPoWholeRowTriplePatternStrategy.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/HashedPoWholeRowTriplePatternStrategy.java b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/HashedPoWholeRowTriplePatternStrategy.java
index f1abba9..6e8bb31 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/HashedPoWholeRowTriplePatternStrategy.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/HashedPoWholeRowTriplePatternStrategy.java
@@ -1,5 +1,3 @@
-package org.apache.rya.api.query.strategy.wholerow;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -8,9 +6,9 @@ package org.apache.rya.api.query.strategy.wholerow;
* 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
@@ -18,22 +16,19 @@ package org.apache.rya.api.query.strategy.wholerow;
* specific language governing permissions and limitations
* under the License.
*/
-
-
+package org.apache.rya.api.query.strategy.wholerow;
import static org.apache.rya.api.RdfCloudTripleStoreConstants.DELIM_BYTES;
import static org.apache.rya.api.RdfCloudTripleStoreConstants.LAST_BYTES;
import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTES;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
import org.apache.commons.codec.binary.Hex;
-
-import com.google.common.primitives.Bytes;
-
import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
import org.apache.rya.api.RdfCloudTripleStoreConstants;
import org.apache.rya.api.RdfCloudTripleStoreUtils;
@@ -44,6 +39,8 @@ import org.apache.rya.api.query.strategy.ByteRange;
import org.apache.rya.api.resolver.RyaContext;
import org.apache.rya.api.resolver.RyaTypeResolverException;
+import com.google.common.primitives.Bytes;
+
/**
* Date: 7/14/12
* Time: 7:35 AM
@@ -57,31 +54,33 @@ public class HashedPoWholeRowTriplePatternStrategy extends AbstractHashedTripleP
@Override
public Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT,
- ByteRange> defineRange(RyaURI subject, RyaURI predicate, RyaType object,
- RyaURI context, RdfCloudTripleStoreConfiguration conf) throws IOException {
+ ByteRange> defineRange(final RyaURI subject, final RyaURI predicate, final RyaType object,
+ final RyaURI context, final 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;
+ if (!handles(subject, predicate, object, context)) {
+ return null;
+ }
+
+ final RyaContext ryaContext = RyaContext.getInstance();
+ final MessageDigest md = MessageDigest.getInstance("MD5");
- RyaContext ryaContext = RyaContext.getInstance();
- MessageDigest md = MessageDigest.getInstance("MD5");
-
- RdfCloudTripleStoreConstants.TABLE_LAYOUT table_layout = RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO;
+ final 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();
- byte[] predHash = Hex.encodeHexString(md.digest(predBytes)).getBytes();
+ final byte[] objStartBytes = ryaContext.serializeType(rv.getStart())[0];
+ final byte[] objEndBytes = ryaContext.serializeType(rv.getStop())[0];
+ final byte[] predBytes = predicate.getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] predHash = Hex.encodeHexString(md.digest(predBytes)).getBytes(StandardCharsets.UTF_8);
start = Bytes.concat(predHash, DELIM_BYTES, predBytes, DELIM_BYTES, objStartBytes);
stop = Bytes.concat(predHash, DELIM_BYTES, predBytes,DELIM_BYTES, objEndBytes, DELIM_BYTES, LAST_BYTES);
} else {
@@ -89,48 +88,52 @@ public class HashedPoWholeRowTriplePatternStrategy extends AbstractHashedTripleP
//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[] predHash = Hex.encodeHexString(md.digest(predBytes)).getBytes();
- byte[] objBytes = ryaContext.serializeType(object)[0];
+ final byte[] subjStartBytes = ru.getStart().getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] subjStopBytes = ru.getStop().getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] predBytes = predicate.getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] predHash = Hex.encodeHexString(md.digest(predBytes)).getBytes(StandardCharsets.UTF_8);
+ final byte[] objBytes = ryaContext.serializeType(object)[0];
start = Bytes.concat(predHash, DELIM_BYTES, predBytes, DELIM_BYTES, objBytes, DELIM_BYTES, subjStartBytes);
stop = Bytes.concat(predHash, DELIM_BYTES, 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[] predBytes = predicate.getData().getBytes();
- byte[] predHash = Hex.encodeHexString(md.digest(predBytes)).getBytes();
- byte[] objBytes = ryaContext.serializeType(object)[0];
+ final byte[] predBytes = predicate.getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] predHash = Hex.encodeHexString(md.digest(predBytes)).getBytes(StandardCharsets.UTF_8);
+ final byte[] objBytes = ryaContext.serializeType(object)[0];
start = Bytes.concat(predHash, DELIM_BYTES, predBytes, DELIM_BYTES, objBytes, DELIM_BYTES);
stop = Bytes.concat(start, LAST_BYTES);
}
}
} else {
//p
- byte[] predBytes = predicate.getData().getBytes();
- byte[] predHash = Hex.encodeHexString(md.digest(predBytes)).getBytes();
+ final byte[] predBytes = predicate.getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] predHash = Hex.encodeHexString(md.digest(predBytes)).getBytes(StandardCharsets.UTF_8);
start = Bytes.concat(predHash, DELIM_BYTES, predBytes, 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) {
+ } catch (final RyaTypeResolverException e) {
throw new IOException(e);
- } catch (NoSuchAlgorithmException e) {
+ } catch (final NoSuchAlgorithmException e) {
throw new IOException(e);
}
}
@Override
- public boolean handles(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context) {
+ public boolean handles(final RyaURI subject, final RyaURI predicate, final RyaType object, final RyaURI context) {
//po(ng)
//p_r(o)(ng)
//po_r(s)(ng)
//p(ng)
//r(p)(ng)
- if ((predicate == null) || (predicate instanceof RyaRange)) return false;
- if (subject != null && !(subject instanceof RyaRange)) return false;
+ if ((predicate == null) || (predicate instanceof RyaRange)) {
+ return false;
+ }
+ if (subject != null && !(subject instanceof RyaRange)) {
+ return false;
+ }
return subject == null || object != null;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/HashedSpoWholeRowTriplePatternStrategy.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/HashedSpoWholeRowTriplePatternStrategy.java b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/HashedSpoWholeRowTriplePatternStrategy.java
index c650b89..c87d268 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/HashedSpoWholeRowTriplePatternStrategy.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/HashedSpoWholeRowTriplePatternStrategy.java
@@ -1,16 +1,3 @@
-package org.apache.rya.api.query.strategy.wholerow;
-
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.DELIM_BYTES;
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.LAST_BYTES;
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTES;
-
-import java.io.IOException;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Map;
-
-import org.apache.commons.codec.binary.Hex;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,9 +6,9 @@ import org.apache.commons.codec.binary.Hex;
* 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
@@ -29,11 +16,19 @@ import org.apache.commons.codec.binary.Hex;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.api.query.strategy.wholerow;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.DELIM_BYTES;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.LAST_BYTES;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTES;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Map;
-import com.google.common.primitives.Bytes;
-
+import org.apache.commons.codec.binary.Hex;
import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
import org.apache.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT;
import org.apache.rya.api.RdfCloudTripleStoreUtils;
@@ -45,6 +40,8 @@ import org.apache.rya.api.query.strategy.ByteRange;
import org.apache.rya.api.resolver.RyaContext;
import org.apache.rya.api.resolver.RyaTypeResolverException;
+import com.google.common.primitives.Bytes;
+
/**
* Date: 7/14/12
* Time: 7:35 AM
@@ -58,20 +55,22 @@ public class HashedSpoWholeRowTriplePatternStrategy extends AbstractHashedTriple
}
@Override
- public Map.Entry<TABLE_LAYOUT, ByteRange> defineRange(RyaURI subject, RyaURI predicate, RyaType object,
- RyaURI context, RdfCloudTripleStoreConfiguration conf) throws IOException {
+ public Map.Entry<TABLE_LAYOUT, ByteRange> defineRange(final RyaURI subject, final RyaURI predicate, final RyaType object,
+ final RyaURI context, final 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;
- MessageDigest md = MessageDigest.getInstance("MD5");
-
- RyaContext ryaContext = RyaContext.getInstance();
+ if (!handles(subject, predicate, object, context)) {
+ return null;
+ }
+ final MessageDigest md = MessageDigest.getInstance("MD5");
+
+ final RyaContext ryaContext = RyaContext.getInstance();
- TABLE_LAYOUT table_layout = TABLE_LAYOUT.SPO;
+ final TABLE_LAYOUT table_layout = TABLE_LAYOUT.SPO;
byte[] start;
byte[] stop;
if (predicate != null) {
@@ -81,21 +80,21 @@ public class HashedSpoWholeRowTriplePatternStrategy extends AbstractHashedTriple
//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[] hashSubj = Hex.encodeHexString(md.digest(subjBytes)).getBytes();
- byte[] predBytes = predicate.getData().getBytes();
+ final byte[] objStartBytes = ryaContext.serializeType(rv.getStart())[0];
+ final byte[] objEndBytes = ryaContext.serializeType(rv.getStop())[0];
+ final byte[] subjBytes = subject.getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] hashSubj = Hex.encodeHexString(md.digest(subjBytes)).getBytes(StandardCharsets.UTF_8);
+ final byte[] predBytes = predicate.getData().getBytes(StandardCharsets.UTF_8);
start = Bytes.concat(hashSubj, DELIM_BYTES, subjBytes, DELIM_BYTES, predBytes, DELIM_BYTES, objStartBytes);
stop = Bytes.concat(hashSubj, DELIM_BYTES,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[] subjBytes = subject.getData().getBytes();
- byte[] hashSubj = Hex.encodeHexString(md.digest(subjBytes)).getBytes();
- byte[] objBytes = ryaContext.serializeType(object)[0];
- start = Bytes.concat(hashSubj, DELIM_BYTES, subjBytes, DELIM_BYTES, predicate.getData().getBytes(), DELIM_BYTES, objBytes, TYPE_DELIM_BYTES);
+ final byte[] subjBytes = subject.getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] hashSubj = Hex.encodeHexString(md.digest(subjBytes)).getBytes(StandardCharsets.UTF_8);
+ final byte[] objBytes = ryaContext.serializeType(object)[0];
+ start = Bytes.concat(hashSubj, DELIM_BYTES, subjBytes, DELIM_BYTES, predicate.getData().getBytes(StandardCharsets.UTF_8), DELIM_BYTES, objBytes, TYPE_DELIM_BYTES);
stop = Bytes.concat(start, LAST_BYTES);
}
} else if (predicate instanceof RyaRange) {
@@ -103,39 +102,39 @@ public class HashedSpoWholeRowTriplePatternStrategy extends AbstractHashedTriple
//range = s_r(p.s)->s_r(p.e)
RyaRange rv = (RyaRange) predicate;
rv = ryaContext.transformRange(rv);
- byte[] subjBytes = subject.getData().getBytes();
- byte[] hashSubj = Hex.encodeHexString(md.digest(subjBytes)).getBytes();
- byte[] predStartBytes = rv.getStart().getData().getBytes();
- byte[] predStopBytes = rv.getStop().getData().getBytes();
+ final byte[] subjBytes = subject.getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] hashSubj = Hex.encodeHexString(md.digest(subjBytes)).getBytes(StandardCharsets.UTF_8);
+ final byte[] predStartBytes = rv.getStart().getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] predStopBytes = rv.getStop().getData().getBytes(StandardCharsets.UTF_8);
start = Bytes.concat(hashSubj, DELIM_BYTES, subjBytes, DELIM_BYTES, predStartBytes);
stop = Bytes.concat(hashSubj, DELIM_BYTES, subjBytes, DELIM_BYTES, predStopBytes, DELIM_BYTES, LAST_BYTES);
} else {
//sp
//range = sp
- byte[] subjBytes = subject.getData().getBytes();
- byte[] hashSubj = Hex.encodeHexString(md.digest(subjBytes)).getBytes();
- start = Bytes.concat(hashSubj, DELIM_BYTES, subjBytes, DELIM_BYTES, predicate.getData().getBytes(), DELIM_BYTES);
+ final byte[] subjBytes = subject.getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] hashSubj = Hex.encodeHexString(md.digest(subjBytes)).getBytes(StandardCharsets.UTF_8);
+ start = Bytes.concat(hashSubj, DELIM_BYTES, subjBytes, DELIM_BYTES, predicate.getData().getBytes(StandardCharsets.UTF_8), DELIM_BYTES);
stop = Bytes.concat(start, LAST_BYTES);
}
} else {
//s
//range = s
- byte[] subjBytes = subject.getData().getBytes();
- byte[] hashSubj = Hex.encodeHexString(md.digest(subjBytes)).getBytes();
+ final byte[] subjBytes = subject.getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] hashSubj = Hex.encodeHexString(md.digest(subjBytes)).getBytes(StandardCharsets.UTF_8);
start = Bytes.concat(hashSubj, DELIM_BYTES, subjBytes, DELIM_BYTES);
stop = Bytes.concat(start, LAST_BYTES);
}
return new RdfCloudTripleStoreUtils.CustomEntry<TABLE_LAYOUT, ByteRange>(table_layout,
new ByteRange(start, stop));
- } catch (RyaTypeResolverException e) {
+ } catch (final RyaTypeResolverException e) {
throw new IOException(e);
- } catch (NoSuchAlgorithmException e) {
+ } catch (final NoSuchAlgorithmException e) {
throw new IOException(e);
}
}
@Override
- public boolean handles(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context) {
+ public boolean handles(final RyaURI subject, final RyaURI predicate, final RyaType object, final RyaURI context) {
//if subject is not null and not a range (if predicate is null then object must be null)
return (subject != null && !(subject instanceof RyaURIRange)) && !((predicate == null || predicate instanceof RyaURIRange) && (object != null));
}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/OspWholeRowTriplePatternStrategy.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/OspWholeRowTriplePatternStrategy.java b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/OspWholeRowTriplePatternStrategy.java
index 013dd8b..98861c0 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/OspWholeRowTriplePatternStrategy.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/OspWholeRowTriplePatternStrategy.java
@@ -1,5 +1,3 @@
-package org.apache.rya.api.query.strategy.wholerow;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -8,9 +6,9 @@ package org.apache.rya.api.query.strategy.wholerow;
* 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
@@ -18,13 +16,13 @@ package org.apache.rya.api.query.strategy.wholerow;
* specific language governing permissions and limitations
* under the License.
*/
-
-
+package org.apache.rya.api.query.strategy.wholerow;
import static org.apache.rya.api.RdfCloudTripleStoreConstants.DELIM_BYTES;
import static org.apache.rya.api.RdfCloudTripleStoreConstants.LAST_BYTES;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
@@ -53,33 +51,35 @@ public class OspWholeRowTriplePatternStrategy extends AbstractTriplePatternStrat
@Override
public Map.Entry<TABLE_LAYOUT,
- ByteRange> defineRange(RyaURI subject, RyaURI predicate, RyaType object,
- RyaURI context, RdfCloudTripleStoreConfiguration conf) throws IOException {
+ ByteRange> defineRange(final RyaURI subject, final RyaURI predicate, final RyaType object,
+ final RyaURI context, final RdfCloudTripleStoreConfiguration conf) throws IOException {
try {
//os(ng)
//o_r(s)(ng)
//o(ng)
//r(o)
- if (!handles(subject, predicate, object, context)) return null;
+ if (!handles(subject, predicate, object, context)) {
+ return null;
+ }
- RyaContext ryaContext = RyaContext.getInstance();
+ final RyaContext ryaContext = RyaContext.getInstance();
- TABLE_LAYOUT table_layout = TABLE_LAYOUT.OSP;
+ final TABLE_LAYOUT table_layout = TABLE_LAYOUT.OSP;
byte[] start, stop;
if (subject != null) {
if (subject instanceof RyaRange) {
//o_r(s)
RyaRange ru = (RyaRange) subject;
ru = ryaContext.transformRange(ru);
- byte[] subjStartBytes = ru.getStart().getData().getBytes();
- byte[] subjEndBytes = ru.getStop().getData().getBytes();
- byte[] objBytes = ryaContext.serializeType(object)[0];
+ final byte[] subjStartBytes = ru.getStart().getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] subjEndBytes = ru.getStop().getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] objBytes = ryaContext.serializeType(object)[0];
start = Bytes.concat(objBytes, DELIM_BYTES, subjStartBytes);
stop = Bytes.concat(objBytes, DELIM_BYTES, subjEndBytes, DELIM_BYTES, LAST_BYTES);
} else {
//os
- byte[] objBytes = ryaContext.serializeType(object)[0];
- start = Bytes.concat(objBytes, DELIM_BYTES, subject.getData().getBytes(), DELIM_BYTES);
+ final byte[] objBytes = ryaContext.serializeType(object)[0];
+ start = Bytes.concat(objBytes, DELIM_BYTES, subject.getData().getBytes(StandardCharsets.UTF_8), DELIM_BYTES);
stop = Bytes.concat(start, LAST_BYTES);
}
} else {
@@ -97,13 +97,13 @@ public class OspWholeRowTriplePatternStrategy extends AbstractTriplePatternStrat
}
return new RdfCloudTripleStoreUtils.CustomEntry<TABLE_LAYOUT,
ByteRange>(table_layout, new ByteRange(start, stop));
- } catch (RyaTypeResolverException e) {
+ } catch (final RyaTypeResolverException e) {
throw new IOException(e);
}
}
@Override
- public boolean handles(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context) {
+ public boolean handles(final RyaURI subject, final RyaURI predicate, final RyaType object, final RyaURI context) {
//os(ng)
//o_r(s)(ng)
//o(ng)
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/PoWholeRowTriplePatternStrategy.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/PoWholeRowTriplePatternStrategy.java b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/PoWholeRowTriplePatternStrategy.java
index 2667cb7..e09e5d0 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/PoWholeRowTriplePatternStrategy.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/PoWholeRowTriplePatternStrategy.java
@@ -1,5 +1,3 @@
-package org.apache.rya.api.query.strategy.wholerow;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -8,9 +6,9 @@ package org.apache.rya.api.query.strategy.wholerow;
* 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
@@ -18,10 +16,16 @@ package org.apache.rya.api.query.strategy.wholerow;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.api.query.strategy.wholerow;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.DELIM_BYTES;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.LAST_BYTES;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTES;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
-import com.google.common.primitives.Bytes;
import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
import org.apache.rya.api.RdfCloudTripleStoreConstants;
import org.apache.rya.api.RdfCloudTripleStoreUtils;
@@ -33,10 +37,7 @@ import org.apache.rya.api.query.strategy.ByteRange;
import org.apache.rya.api.resolver.RyaContext;
import org.apache.rya.api.resolver.RyaTypeResolverException;
-import java.io.IOException;
-import java.util.Map;
-
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.*;
+import com.google.common.primitives.Bytes;
/**
* Date: 7/14/12
@@ -51,28 +52,30 @@ public class PoWholeRowTriplePatternStrategy extends AbstractTriplePatternStrate
@Override
public Map.Entry<RdfCloudTripleStoreConstants.TABLE_LAYOUT,
- ByteRange> defineRange(RyaURI subject, RyaURI predicate, RyaType object,
- RyaURI context, RdfCloudTripleStoreConfiguration conf) throws IOException {
+ ByteRange> defineRange(final RyaURI subject, final RyaURI predicate, final RyaType object,
+ final RyaURI context, final 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;
+ if (!handles(subject, predicate, object, context)) {
+ return null;
+ }
- RyaContext ryaContext = RyaContext.getInstance();
+ final RyaContext ryaContext = RyaContext.getInstance();
- RdfCloudTripleStoreConstants.TABLE_LAYOUT table_layout = RdfCloudTripleStoreConstants.TABLE_LAYOUT.PO;
+ final 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();
+ final byte[] objStartBytes = ryaContext.serializeType(rv.getStart())[0];
+ final byte[] objEndBytes = ryaContext.serializeType(rv.getStop())[0];
+ final byte[] predBytes = predicate.getData().getBytes(StandardCharsets.UTF_8);
start = Bytes.concat(predBytes, DELIM_BYTES, objStartBytes);
stop = Bytes.concat(predBytes, DELIM_BYTES, objEndBytes, DELIM_BYTES, LAST_BYTES);
} else {
@@ -80,17 +83,17 @@ public class PoWholeRowTriplePatternStrategy extends AbstractTriplePatternStrate
//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];
+ final byte[] subjStartBytes = ru.getStart().getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] subjStopBytes = ru.getStop().getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] predBytes = predicate.getData().getBytes(StandardCharsets.UTF_8);
+ final 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);
+ final byte[] objBytes = ryaContext.serializeType(object)[0];
+ start = Bytes.concat(predicate.getData().getBytes(StandardCharsets.UTF_8), DELIM_BYTES, objBytes, DELIM_BYTES);
stop = Bytes.concat(start, LAST_BYTES);
}
}
@@ -98,31 +101,36 @@ public class PoWholeRowTriplePatternStrategy extends AbstractTriplePatternStrate
//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);
+ start = rv.getStart().getData().getBytes(StandardCharsets.UTF_8);
+ stop = Bytes.concat(rv.getStop().getData().getBytes(StandardCharsets.UTF_8), DELIM_BYTES, LAST_BYTES);
} else {
//p
- start = Bytes.concat(predicate.getData().getBytes(), DELIM_BYTES);
+ start = Bytes.concat(predicate.getData().getBytes(StandardCharsets.UTF_8), 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) {
+ } catch (final RyaTypeResolverException e) {
throw new IOException(e);
}
}
@Override
- public boolean handles(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context) {
+ public boolean handles(final RyaURI subject, final RyaURI predicate, final RyaType object, final 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)
+ 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/538cfccc/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/SpoWholeRowTriplePatternStrategy.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/SpoWholeRowTriplePatternStrategy.java b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/SpoWholeRowTriplePatternStrategy.java
index dc83210..b2c29bb 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/SpoWholeRowTriplePatternStrategy.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/query/strategy/wholerow/SpoWholeRowTriplePatternStrategy.java
@@ -1,5 +1,3 @@
-package org.apache.rya.api.query.strategy.wholerow;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -8,9 +6,9 @@ package org.apache.rya.api.query.strategy.wholerow;
* 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
@@ -18,11 +16,18 @@ package org.apache.rya.api.query.strategy.wholerow;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.api.query.strategy.wholerow;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.DELIM_BYTES;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.LAST_BYTES;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTES;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
-import com.google.common.primitives.Bytes;
import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
+import org.apache.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT;
import org.apache.rya.api.RdfCloudTripleStoreUtils;
import org.apache.rya.api.domain.RyaRange;
import org.apache.rya.api.domain.RyaType;
@@ -33,10 +38,7 @@ import org.apache.rya.api.query.strategy.ByteRange;
import org.apache.rya.api.resolver.RyaContext;
import org.apache.rya.api.resolver.RyaTypeResolverException;
-import java.io.IOException;
-import java.util.Map;
-
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.*;
+import com.google.common.primitives.Bytes;
/**
* Date: 7/14/12
@@ -50,19 +52,21 @@ public class SpoWholeRowTriplePatternStrategy extends AbstractTriplePatternStrat
}
@Override
- public Map.Entry<TABLE_LAYOUT, ByteRange> defineRange(RyaURI subject, RyaURI predicate, RyaType object,
- RyaURI context, RdfCloudTripleStoreConfiguration conf) throws IOException {
+ public Map.Entry<TABLE_LAYOUT, ByteRange> defineRange(final RyaURI subject, final RyaURI predicate, final RyaType object,
+ final RyaURI context, final 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;
+ if (!handles(subject, predicate, object, context)) {
+ return null;
+ }
- RyaContext ryaContext = RyaContext.getInstance();
+ final RyaContext ryaContext = RyaContext.getInstance();
- TABLE_LAYOUT table_layout = TABLE_LAYOUT.SPO;
+ final TABLE_LAYOUT table_layout = TABLE_LAYOUT.SPO;
byte[] start;
byte[] stop;
if (predicate != null) {
@@ -72,18 +76,18 @@ public class SpoWholeRowTriplePatternStrategy extends AbstractTriplePatternStrat
//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();
+ final byte[] objStartBytes = ryaContext.serializeType(rv.getStart())[0];
+ final byte[] objEndBytes = ryaContext.serializeType(rv.getStop())[0];
+ final byte[] subjBytes = subject.getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] predBytes = predicate.getData().getBytes(StandardCharsets.UTF_8);
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);
+ final byte[] objBytes = ryaContext.serializeType(object)[0];
+ start = Bytes.concat(subject.getData().getBytes(StandardCharsets.UTF_8), DELIM_BYTES, predicate.getData().getBytes(StandardCharsets.UTF_8), DELIM_BYTES, objBytes, TYPE_DELIM_BYTES);
stop = Bytes.concat(start, LAST_BYTES);
}
} else if (predicate instanceof RyaRange) {
@@ -91,15 +95,15 @@ public class SpoWholeRowTriplePatternStrategy extends AbstractTriplePatternStrat
//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();
+ final byte[] subjBytes = subject.getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] predStartBytes = rv.getStart().getData().getBytes(StandardCharsets.UTF_8);
+ final byte[] predStopBytes = rv.getStop().getData().getBytes(StandardCharsets.UTF_8);
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);
+ start = Bytes.concat(subject.getData().getBytes(StandardCharsets.UTF_8), DELIM_BYTES, predicate.getData().getBytes(StandardCharsets.UTF_8), DELIM_BYTES);
stop = Bytes.concat(start, LAST_BYTES);
}
} else if (subject instanceof RyaRange) {
@@ -107,23 +111,23 @@ public class SpoWholeRowTriplePatternStrategy extends AbstractTriplePatternStrat
//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);
+ start = ru.getStart().getData().getBytes(StandardCharsets.UTF_8);
+ stop = Bytes.concat(ru.getStop().getData().getBytes(StandardCharsets.UTF_8), DELIM_BYTES, LAST_BYTES);
} else {
//s
//range = s
- start = Bytes.concat(subject.getData().getBytes(), DELIM_BYTES);
+ start = Bytes.concat(subject.getData().getBytes(StandardCharsets.UTF_8), DELIM_BYTES);
stop = Bytes.concat(start, LAST_BYTES);
}
return new RdfCloudTripleStoreUtils.CustomEntry<TABLE_LAYOUT, ByteRange>(table_layout,
new ByteRange(start, stop));
- } catch (RyaTypeResolverException e) {
+ } catch (final RyaTypeResolverException e) {
throw new IOException(e);
}
}
@Override
- public boolean handles(RyaURI subject, RyaURI predicate, RyaType object, RyaURI context) {
+ public boolean handles(final RyaURI subject, final RyaURI predicate, final RyaType object, final 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/538cfccc/common/rya.api/src/main/java/org/apache/rya/api/resolver/impl/CustomDatatypeResolver.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/resolver/impl/CustomDatatypeResolver.java b/common/rya.api/src/main/java/org/apache/rya/api/resolver/impl/CustomDatatypeResolver.java
index 2c4b689..3b4dcfa 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/resolver/impl/CustomDatatypeResolver.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/resolver/impl/CustomDatatypeResolver.java
@@ -1,5 +1,3 @@
-package org.apache.rya.api.resolver.impl;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -8,9 +6,9 @@ package org.apache.rya.api.resolver.impl;
* 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
@@ -18,15 +16,18 @@ package org.apache.rya.api.resolver.impl;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.api.resolver.impl;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTE;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTES;
+import java.nio.charset.StandardCharsets;
-import com.google.common.primitives.Bytes;
import org.apache.rya.api.domain.RyaType;
import org.apache.rya.api.resolver.RyaTypeResolverException;
import org.openrdf.model.impl.URIImpl;
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTE;
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTES;
+
+import com.google.common.primitives.Bytes;
/**
* Date: 7/16/12
@@ -40,30 +41,30 @@ public class CustomDatatypeResolver extends RyaTypeResolverImpl {
}
@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)};
+ public byte[][] serializeType(final RyaType ryaType) throws RyaTypeResolverException {
+ final byte[] bytes = serializeData(ryaType.getData()).getBytes(StandardCharsets.UTF_8);
+ return new byte[][]{bytes, Bytes.concat(TYPE_DELIM_BYTES, ryaType.getDataType().stringValue().getBytes(StandardCharsets.UTF_8), TYPE_DELIM_BYTES, markerBytes)};
}
@Override
- public byte[] serialize(RyaType ryaType) throws RyaTypeResolverException {
- byte[][] bytes = serializeType(ryaType);
+ public byte[] serialize(final RyaType ryaType) throws RyaTypeResolverException {
+ final byte[][] bytes = serializeType(ryaType);
return Bytes.concat(bytes[0], bytes[1]);
}
@Override
- public RyaType deserialize(byte[] bytes) throws RyaTypeResolverException {
+ public RyaType deserialize(final 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);
+ final RyaType rt = newInstance();
+ final int length = bytes.length;
+ final 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)));
+ final String label = deserializeData(new String(bytes, 0, indexOfType, StandardCharsets.UTF_8));
+ rt.setDataType(new URIImpl(new String(bytes, indexOfType + 1, (length - indexOfType) - 3, StandardCharsets.UTF_8)));
rt.setData(label);
return rt;
}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/538cfccc/common/rya.api/src/main/java/org/apache/rya/api/resolver/impl/RyaTypeResolverImpl.java
----------------------------------------------------------------------
diff --git a/common/rya.api/src/main/java/org/apache/rya/api/resolver/impl/RyaTypeResolverImpl.java b/common/rya.api/src/main/java/org/apache/rya/api/resolver/impl/RyaTypeResolverImpl.java
index 3e6c6b4..943a1d3 100644
--- a/common/rya.api/src/main/java/org/apache/rya/api/resolver/impl/RyaTypeResolverImpl.java
+++ b/common/rya.api/src/main/java/org/apache/rya/api/resolver/impl/RyaTypeResolverImpl.java
@@ -1,5 +1,3 @@
-package org.apache.rya.api.resolver.impl;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -8,9 +6,9 @@ package org.apache.rya.api.resolver.impl;
* 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
@@ -18,10 +16,13 @@ package org.apache.rya.api.resolver.impl;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.api.resolver.impl;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTE;
+import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTES;
+import java.nio.charset.StandardCharsets;
-import com.google.common.primitives.Bytes;
import org.apache.rya.api.domain.RyaRange;
import org.apache.rya.api.domain.RyaType;
import org.apache.rya.api.resolver.RyaTypeResolver;
@@ -31,8 +32,7 @@ import org.calrissian.mango.types.TypeEncoder;
import org.openrdf.model.URI;
import org.openrdf.model.vocabulary.XMLSchema;
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTE;
-import static org.apache.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTES;
+import com.google.common.primitives.Bytes;
/**
* Date: 7/16/12
@@ -51,12 +51,12 @@ public class RyaTypeResolverImpl implements RyaTypeResolver {
this((byte) PLAIN_LITERAL_MARKER, XMLSchema.STRING);
}
- public RyaTypeResolverImpl(byte markerByte, URI dataType) {
+ public RyaTypeResolverImpl(final byte markerByte, final URI dataType) {
setMarkerByte(markerByte);
setRyaDataType(dataType);
}
- public void setMarkerByte(byte markerByte) {
+ public void setMarkerByte(final byte markerByte) {
this.markerByte = markerByte;
this.markerBytes = new byte[]{markerByte};
}
@@ -67,19 +67,19 @@ public class RyaTypeResolverImpl implements RyaTypeResolver {
}
@Override
- public RyaRange transformRange(RyaRange ryaRange) throws RyaTypeResolverException {
+ public RyaRange transformRange(final RyaRange ryaRange) throws RyaTypeResolverException {
return ryaRange;
}
@Override
- public byte[] serialize(RyaType ryaType) throws RyaTypeResolverException {
- byte[][] bytes = serializeType(ryaType);
+ public byte[] serialize(final RyaType ryaType) throws RyaTypeResolverException {
+ final 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();
+ public byte[][] serializeType(final RyaType ryaType) throws RyaTypeResolverException {
+ final byte[] bytes = serializeData(ryaType.getData()).getBytes(StandardCharsets.UTF_8);
return new byte[][]{bytes, Bytes.concat(TYPE_DELIM_BYTES, markerBytes)};
}
@@ -88,7 +88,7 @@ public class RyaTypeResolverImpl implements RyaTypeResolver {
return dataType;
}
- public void setRyaDataType(URI dataType) {
+ public void setRyaDataType(final URI dataType) {
this.dataType = dataType;
}
@@ -98,27 +98,27 @@ public class RyaTypeResolverImpl implements RyaTypeResolver {
}
@Override
- public boolean deserializable(byte[] bytes) {
+ public boolean deserializable(final 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 {
+ protected String serializeData(final String data) throws RyaTypeResolverException {
return STRING_TYPE_ENCODER.encode(data);
}
@Override
- public RyaType deserialize(byte[] bytes) throws RyaTypeResolverException {
+ public RyaType deserialize(final byte[] bytes) throws RyaTypeResolverException {
if (!deserializable(bytes)) {
throw new RyaTypeResolverException("Bytes not deserializable");
}
- RyaType rt = newInstance();
+ final RyaType rt = newInstance();
rt.setDataType(getRyaDataType());
- String data = new String(bytes, 0, bytes.length - 2);
+ final String data = new String(bytes, 0, bytes.length - 2, StandardCharsets.UTF_8);
rt.setData(deserializeData(data));
return rt;
}
- protected String deserializeData(String data) throws RyaTypeResolverException {
+ protected String deserializeData(final String data) throws RyaTypeResolverException {
return STRING_TYPE_ENCODER.decode(data);
}
}