http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/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/44a2dcf0/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/44a2dcf0/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/44a2dcf0/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/44a2dcf0/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/44a2dcf0/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/44a2dcf0/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/44a2dcf0/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/44a2dcf0/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(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRowResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRowResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRowResolver.java deleted file mode 100644 index 2ccc986..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRowResolver.java +++ /dev/null @@ -1,43 +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 mvm.rya.api.RdfCloudTripleStoreConstants; -import mvm.rya.api.domain.RyaStatement; -import mvm.rya.api.domain.RyaType; -import mvm.rya.api.domain.RyaURI; - -import java.util.Map; - -import static mvm.rya.api.RdfCloudTripleStoreConstants.TABLE_LAYOUT; - -/** - * Date: 7/17/12 - * Time: 7:33 AM - */ -public interface TripleRowResolver { - - public Map<RdfCloudTripleStoreConstants.TABLE_LAYOUT, TripleRow> serialize(RyaStatement statement) throws TripleRowResolverException; - - public RyaStatement deserialize(TABLE_LAYOUT table_layout, TripleRow tripleRow) throws TripleRowResolverException; - -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRowResolverException.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRowResolverException.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRowResolverException.java deleted file mode 100644 index d1824b1..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/TripleRowResolverException.java +++ /dev/null @@ -1,43 +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. - */ - - - -/** - * Date: 7/17/12 - * Time: 7:35 AM - */ -public class TripleRowResolverException extends Exception { - public TripleRowResolverException() { - } - - public TripleRowResolverException(String s) { - super(s); - } - - public TripleRowResolverException(String s, Throwable throwable) { - super(s, throwable); - } - - public TripleRowResolverException(Throwable throwable) { - super(throwable); - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/impl/WholeRowHashedTripleResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/impl/WholeRowHashedTripleResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/impl/WholeRowHashedTripleResolver.java deleted file mode 100644 index cbfc30f..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/impl/WholeRowHashedTripleResolver.java +++ /dev/null @@ -1,160 +0,0 @@ -package mvm.rya.api.resolver.triple.impl; - -import static mvm.rya.api.RdfCloudTripleStoreConstants.DELIM_BYTE; -import static mvm.rya.api.RdfCloudTripleStoreConstants.DELIM_BYTES; -import static mvm.rya.api.RdfCloudTripleStoreConstants.EMPTY_BYTES; -import static mvm.rya.api.RdfCloudTripleStoreConstants.TYPE_DELIM_BYTE; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Arrays; -import java.util.HashMap; -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 - * 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.RdfCloudTripleStoreConstants.TABLE_LAYOUT; -import mvm.rya.api.domain.RyaStatement; -import mvm.rya.api.domain.RyaType; -import mvm.rya.api.domain.RyaURI; -import mvm.rya.api.resolver.RyaContext; -import mvm.rya.api.resolver.RyaTypeResolverException; -import mvm.rya.api.resolver.triple.TripleRow; -import mvm.rya.api.resolver.triple.TripleRowResolver; -import mvm.rya.api.resolver.triple.TripleRowResolverException; - -/** - * Will store triple in spo, po, osp. Storing everything in the whole row. - * Date: 7/13/12 - * Time: 8:51 AM - */ -public class WholeRowHashedTripleResolver implements TripleRowResolver { - - @Override - public Map<TABLE_LAYOUT, TripleRow> serialize(RyaStatement stmt) throws TripleRowResolverException { - try { - RyaURI subject = stmt.getSubject(); - RyaURI predicate = stmt.getPredicate(); - RyaType object = stmt.getObject(); - RyaURI context = stmt.getContext(); - Long timestamp = stmt.getTimestamp(); - byte[] columnVisibility = stmt.getColumnVisibility(); - String qualifer = stmt.getQualifer(); - byte[] qualBytes = qualifer == null ? EMPTY_BYTES : qualifer.getBytes(); - byte[] value = stmt.getValue(); - assert subject != null && predicate != null && object != null; - byte[] cf = (context == null) ? EMPTY_BYTES : context.getData().getBytes(); - Map<TABLE_LAYOUT, TripleRow> tripleRowMap = new HashMap<TABLE_LAYOUT, TripleRow>(); - MessageDigest md = MessageDigest.getInstance("MD5"); - byte[] subjBytes = subject.getData().getBytes(); - byte[] subjHashBytes = md.digest(subjBytes); - byte[] predBytes = predicate.getData().getBytes(); - byte[] predHashBytes = md.digest(predBytes); - byte[][] objBytes = RyaContext.getInstance().serializeType(object); - tripleRowMap.put(TABLE_LAYOUT.SPO, - new TripleRow(Bytes.concat(Hex.encodeHexString(subjHashBytes).getBytes(), DELIM_BYTES, subjBytes, DELIM_BYTES, - predBytes, DELIM_BYTES, - objBytes[0], objBytes[1]), cf, qualBytes, - timestamp, columnVisibility, value)); - tripleRowMap.put(TABLE_LAYOUT.PO, - new TripleRow(Bytes.concat(Hex.encodeHexString(predHashBytes).getBytes(), DELIM_BYTES, predBytes, DELIM_BYTES, - objBytes[0], DELIM_BYTES, - subjBytes, objBytes[1]), cf, qualBytes, - timestamp, columnVisibility, value)); - tripleRowMap.put(TABLE_LAYOUT.OSP, - new TripleRow(Bytes.concat(objBytes[0], DELIM_BYTES, - subjBytes, DELIM_BYTES, - predBytes, objBytes[1]), cf, qualBytes, - timestamp, columnVisibility, value)); - return tripleRowMap; - } catch (RyaTypeResolverException e) { - throw new TripleRowResolverException(e); - } catch (NoSuchAlgorithmException e) { - throw new TripleRowResolverException(e); - } - } - - @Override - public RyaStatement deserialize(TABLE_LAYOUT table_layout, TripleRow tripleRow) throws TripleRowResolverException { - try { - assert tripleRow != null && table_layout != null; - byte[] row = tripleRow.getRow(); - - // if it is a hashed row, ony keep the row after the hash - if ((table_layout == TABLE_LAYOUT.SPO) || (table_layout == TABLE_LAYOUT.PO)) { - int hashStart = Bytes.indexOf(row, DELIM_BYTE); - row = Arrays.copyOfRange(row, hashStart + 1, row.length); - } - - int firstIndex = Bytes.indexOf(row, DELIM_BYTE); - byte[] first= Arrays.copyOf(row, firstIndex); - int secondIndex = Bytes.lastIndexOf(row, DELIM_BYTE); - int typeIndex = Bytes.indexOf(row, TYPE_DELIM_BYTE); - byte[] second = Arrays.copyOfRange(row, firstIndex + 1, secondIndex); - byte[] third = Arrays.copyOfRange(row, secondIndex + 1, typeIndex); - byte[] type = Arrays.copyOfRange(row, typeIndex, row.length); - byte[] columnFamily = tripleRow.getColumnFamily(); - boolean contextExists = columnFamily != null && columnFamily.length > 0; - RyaURI context = (contextExists) ? (new RyaURI(new String(columnFamily))) : null; - byte[] columnQualifier = tripleRow.getColumnQualifier(); - String qualifier = columnQualifier != null && columnQualifier.length > 0 ? new String(columnQualifier) : null; - Long timestamp = tripleRow.getTimestamp(); - byte[] columnVisibility = tripleRow.getColumnVisibility(); - byte[] value = tripleRow.getValue(); - - switch (table_layout) { - case SPO: { - byte[] obj = Bytes.concat(third, type); - return new RyaStatement( - new RyaURI(new String(first)), - new RyaURI(new String(second)), - RyaContext.getInstance().deserialize(obj), - context, qualifier, columnVisibility, value, timestamp); - } - case PO: { - byte[] obj = Bytes.concat(second, type); - return new RyaStatement( - new RyaURI(new String(third)), - new RyaURI(new String(first)), - RyaContext.getInstance().deserialize(obj), - context, qualifier, columnVisibility, value, timestamp); - } - case OSP: { - byte[] obj = Bytes.concat(first, type); - return new RyaStatement( - new RyaURI(new String(second)), - new RyaURI(new String(third)), - RyaContext.getInstance().deserialize(obj), - context, qualifier, columnVisibility, value, timestamp); - } - } - } catch (RyaTypeResolverException e) { - throw new TripleRowResolverException(e); - } - throw new TripleRowResolverException("TripleRow[" + tripleRow + "] with Table layout[" + table_layout + "] is not deserializable"); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/impl/WholeRowTripleResolver.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/impl/WholeRowTripleResolver.java b/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/impl/WholeRowTripleResolver.java deleted file mode 100644 index dc0695b..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/resolver/triple/impl/WholeRowTripleResolver.java +++ /dev/null @@ -1,139 +0,0 @@ -package mvm.rya.api.resolver.triple.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.RyaStatement; -import mvm.rya.api.domain.RyaType; -import mvm.rya.api.domain.RyaURI; -import mvm.rya.api.resolver.RyaContext; -import mvm.rya.api.resolver.RyaTypeResolverException; -import mvm.rya.api.resolver.triple.TripleRow; -import mvm.rya.api.resolver.triple.TripleRowResolver; -import mvm.rya.api.resolver.triple.TripleRowResolverException; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import static mvm.rya.api.RdfCloudTripleStoreConstants.*; - -/** - * Will store triple in spo, po, osp. Storing everything in the whole row. - * Date: 7/13/12 - * Time: 8:51 AM - */ -public class WholeRowTripleResolver implements TripleRowResolver { - - @Override - public Map<TABLE_LAYOUT, TripleRow> serialize(RyaStatement stmt) throws TripleRowResolverException { - try { - RyaURI subject = stmt.getSubject(); - RyaURI predicate = stmt.getPredicate(); - RyaType object = stmt.getObject(); - RyaURI context = stmt.getContext(); - Long timestamp = stmt.getTimestamp(); - byte[] columnVisibility = stmt.getColumnVisibility(); - String qualifer = stmt.getQualifer(); - byte[] qualBytes = qualifer == null ? EMPTY_BYTES : qualifer.getBytes(); - byte[] value = stmt.getValue(); - assert subject != null && predicate != null && object != null; - byte[] cf = (context == null) ? EMPTY_BYTES : context.getData().getBytes(); - Map<TABLE_LAYOUT, TripleRow> tripleRowMap = new HashMap<TABLE_LAYOUT, TripleRow>(); - byte[] subjBytes = subject.getData().getBytes(); - byte[] predBytes = predicate.getData().getBytes(); - byte[][] objBytes = RyaContext.getInstance().serializeType(object); - tripleRowMap.put(TABLE_LAYOUT.SPO, - new TripleRow(Bytes.concat(subjBytes, DELIM_BYTES, - predBytes, DELIM_BYTES, - objBytes[0], objBytes[1]), cf, qualBytes, - timestamp, columnVisibility, value)); - tripleRowMap.put(TABLE_LAYOUT.PO, - new TripleRow(Bytes.concat(predBytes, DELIM_BYTES, - objBytes[0], DELIM_BYTES, - subjBytes, objBytes[1]), cf, qualBytes, - timestamp, columnVisibility, value)); - tripleRowMap.put(TABLE_LAYOUT.OSP, - new TripleRow(Bytes.concat(objBytes[0], DELIM_BYTES, - subjBytes, DELIM_BYTES, - predBytes, objBytes[1]), cf, qualBytes, - timestamp, columnVisibility, value)); - return tripleRowMap; - } catch (RyaTypeResolverException e) { - throw new TripleRowResolverException(e); - } - } - - @Override - public RyaStatement deserialize(TABLE_LAYOUT table_layout, TripleRow tripleRow) throws TripleRowResolverException { - try { - assert tripleRow != null && table_layout != null; - byte[] row = tripleRow.getRow(); - int firstIndex = Bytes.indexOf(row, DELIM_BYTE); - int secondIndex = Bytes.lastIndexOf(row, DELIM_BYTE); - int typeIndex = Bytes.indexOf(row, TYPE_DELIM_BYTE); - byte[] first = Arrays.copyOf(row, firstIndex); - byte[] second = Arrays.copyOfRange(row, firstIndex + 1, secondIndex); - byte[] third = Arrays.copyOfRange(row, secondIndex + 1, typeIndex); - byte[] type = Arrays.copyOfRange(row, typeIndex, row.length); - byte[] columnFamily = tripleRow.getColumnFamily(); - boolean contextExists = columnFamily != null && columnFamily.length > 0; - RyaURI context = (contextExists) ? (new RyaURI(new String(columnFamily))) : null; - byte[] columnQualifier = tripleRow.getColumnQualifier(); - String qualifier = columnQualifier != null && columnQualifier.length > 0 ? new String(columnQualifier) : null; - Long timestamp = tripleRow.getTimestamp(); - byte[] columnVisibility = tripleRow.getColumnVisibility(); - byte[] value = tripleRow.getValue(); - - switch (table_layout) { - case SPO: { - byte[] obj = Bytes.concat(third, type); - return new RyaStatement( - new RyaURI(new String(first)), - new RyaURI(new String(second)), - RyaContext.getInstance().deserialize(obj), - context, qualifier, columnVisibility, value, timestamp); - } - case PO: { - byte[] obj = Bytes.concat(second, type); - return new RyaStatement( - new RyaURI(new String(third)), - new RyaURI(new String(first)), - RyaContext.getInstance().deserialize(obj), - context, qualifier, columnVisibility, value, timestamp); - } - case OSP: { - byte[] obj = Bytes.concat(first, type); - return new RyaStatement( - new RyaURI(new String(second)), - new RyaURI(new String(third)), - RyaContext.getInstance().deserialize(obj), - context, qualifier, columnVisibility, value, timestamp); - } - } - } catch (RyaTypeResolverException e) { - throw new TripleRowResolverException(e); - } - throw new TripleRowResolverException("TripleRow[" + tripleRow + "] with Table layout[" + table_layout + "] is not deserializable"); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/mvm/rya/api/security/SecurityProvider.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/security/SecurityProvider.java b/common/rya.api/src/main/java/mvm/rya/api/security/SecurityProvider.java deleted file mode 100644 index 61b14d9..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/security/SecurityProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -package mvm.rya.api.security; - -/* - * 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 javax.servlet.http.HttpServletRequest; - -public interface SecurityProvider { - - public String[] getUserAuths(HttpServletRequest incRequest); -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/mvm/rya/api/utils/CloseableIterableIteration.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/utils/CloseableIterableIteration.java b/common/rya.api/src/main/java/mvm/rya/api/utils/CloseableIterableIteration.java deleted file mode 100644 index f3e5479..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/utils/CloseableIterableIteration.java +++ /dev/null @@ -1,76 +0,0 @@ -package mvm.rya.api.utils; - -/* - * 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 info.aduna.iteration.CloseableIteration; - -import java.io.IOException; -import java.util.Iterator; -import java.util.NoSuchElementException; - -import org.calrissian.mango.collect.CloseableIterable; - -/** - * Date: 1/30/13 - * Time: 2:21 PM - */ -public class CloseableIterableIteration<T, X extends Exception> implements CloseableIteration<T, X> { - - private CloseableIterable<T> closeableIterable; - private final Iterator<T> iterator; - - private boolean isClosed = false; - - public CloseableIterableIteration(CloseableIterable<T> closeableIterable) { - this.closeableIterable = closeableIterable; - iterator = closeableIterable.iterator(); - } - - @Override - public void close() throws X { - try { - isClosed = true; - closeableIterable.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public boolean hasNext() throws X { - return iterator.hasNext(); - } - - @Override - public T next() throws X { - if (!hasNext() || isClosed) { - throw new NoSuchElementException(); - } - - return iterator.next(); - } - - @Override - public void remove() throws X { - iterator.remove(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/mvm/rya/api/utils/EnumerationWrapper.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/utils/EnumerationWrapper.java b/common/rya.api/src/main/java/mvm/rya/api/utils/EnumerationWrapper.java deleted file mode 100644 index b098e52..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/utils/EnumerationWrapper.java +++ /dev/null @@ -1,58 +0,0 @@ -package mvm.rya.api.utils; - -/* - * 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 info.aduna.iteration.CloseableIteration; - -import java.util.Enumeration; - -/** - * Date: 7/26/12 - * Time: 9:12 AM - */ -public class EnumerationWrapper<E, X extends Exception> implements CloseableIteration<E, X> { - private Enumeration<E> enumeration; - - public EnumerationWrapper(Enumeration<E> enumeration) { - this.enumeration = enumeration; - } - - @Override - public void close() throws X { - //nothing - } - - @Override - public boolean hasNext() throws X { - return enumeration.hasMoreElements(); - } - - @Override - public E next() throws X { - return enumeration.nextElement(); - } - - @Override - public void remove() throws X { - enumeration.nextElement(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/mvm/rya/api/utils/IteratorWrapper.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/utils/IteratorWrapper.java b/common/rya.api/src/main/java/mvm/rya/api/utils/IteratorWrapper.java deleted file mode 100644 index 86748f9..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/utils/IteratorWrapper.java +++ /dev/null @@ -1,58 +0,0 @@ -package mvm.rya.api.utils; - -/* - * 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 info.aduna.iteration.CloseableIteration; - -import java.util.Iterator; - -/** - * Date: 7/26/12 - * Time: 9:12 AM - */ -public class IteratorWrapper<E, X extends Exception> implements CloseableIteration<E, X> { - private Iterator<E> iterator; - - public IteratorWrapper(Iterator<E> iterator) { - this.iterator = iterator; - } - - @Override - public void close() throws X { - //nothing - } - - @Override - public boolean hasNext() throws X { - return iterator.hasNext(); - } - - @Override - public E next() throws X { - return iterator.next(); - } - - @Override - public void remove() throws X { - iterator.remove(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/mvm/rya/api/utils/NullableStatementImpl.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/utils/NullableStatementImpl.java b/common/rya.api/src/main/java/mvm/rya/api/utils/NullableStatementImpl.java deleted file mode 100644 index dfa17e8..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/utils/NullableStatementImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -package mvm.rya.api.utils; - -/* - * 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.Resource; -import org.openrdf.model.Statement; -import org.openrdf.model.URI; -import org.openrdf.model.Value; - -/** - * Class NullableStatementImpl - * Date: Feb 23, 2011 - * Time: 10:37:34 AM - */ -public class NullableStatementImpl implements Statement { - - private Resource subject; - private URI predicate; - private Value object; - private Resource[] contexts; - - public NullableStatementImpl(Resource subject, URI predicate, Value object, Resource... contexts) { - this.subject = subject; - this.predicate = predicate; - this.object = object; - this.contexts = contexts; - } - - @Override - public int hashCode() { - return 961 * ((this.getSubject() == null) ? (0) : (this.getSubject().hashCode())) + - 31 * ((this.getPredicate() == null) ? (0) : (this.getPredicate().hashCode())) + - ((this.getObject() == null) ? (0) : (this.getObject().hashCode())); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(256); - sb.append("("); - sb.append(getSubject()); - sb.append(", "); - sb.append(getPredicate()); - sb.append(", "); - sb.append(getObject()); - sb.append(")"); - return sb.toString(); - } - - @Override - public boolean equals(Object other) { - if (this == other) - return true; - if (other instanceof Statement) { - Statement otherSt = (Statement) other; - return this.hashCode() == otherSt.hashCode(); - } else { - return false; - } - } - - public Value getObject() { - return object; - } - - public URI getPredicate() { - return predicate; - } - - public Resource getSubject() { - return subject; - } - - public Resource getContext() { - if (contexts == null || contexts.length == 0) - return null; - else return contexts[0]; - } - - public Resource[] getContexts() { - return contexts; - } - - public void setContexts(Resource[] contexts) { - this.contexts = contexts; - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/mvm/rya/api/utils/PeekingCloseableIteration.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/utils/PeekingCloseableIteration.java b/common/rya.api/src/main/java/mvm/rya/api/utils/PeekingCloseableIteration.java deleted file mode 100644 index 297c950..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/utils/PeekingCloseableIteration.java +++ /dev/null @@ -1,74 +0,0 @@ -package mvm.rya.api.utils; - -/* - * 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.base.Preconditions; -import info.aduna.iteration.CloseableIteration; - -/** - * Date: 7/24/12 - * Time: 4:40 PM - */ -public class PeekingCloseableIteration<E, X extends java.lang.Exception> implements CloseableIteration<E, X> { - - private final CloseableIteration<E, X> iteration; - private boolean hasPeeked; - private E peekedElement; - - public PeekingCloseableIteration(CloseableIteration<E, X> iteration) { - this.iteration = Preconditions.checkNotNull(iteration); - } - - @Override - public void close() throws X { - iteration.close(); - } - - public boolean hasNext() throws X { - return hasPeeked || iteration.hasNext(); - } - - public E next() throws X { - if (!hasPeeked) { - return iteration.next(); - } else { - E result = peekedElement; - hasPeeked = false; - peekedElement = null; - return result; - } - } - - public void remove() throws X { - Preconditions.checkState(!hasPeeked, "Can't remove after you've peeked at next"); - iteration.remove(); - } - - public E peek() throws X { - if (!hasPeeked) { - peekedElement = iteration.next(); - hasPeeked = true; - } - return peekedElement; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/mvm/rya/api/utils/RyaStatementAddBindingSetFunction.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/utils/RyaStatementAddBindingSetFunction.java b/common/rya.api/src/main/java/mvm/rya/api/utils/RyaStatementAddBindingSetFunction.java deleted file mode 100644 index 0fc2a7f..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/utils/RyaStatementAddBindingSetFunction.java +++ /dev/null @@ -1,40 +0,0 @@ -package mvm.rya.api.utils; - -/* - * 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.base.Function; -import mvm.rya.api.RdfCloudTripleStoreUtils; -import mvm.rya.api.domain.RyaStatement; -import org.openrdf.query.BindingSet; - -import java.util.Map; - -/** - * Date: 1/18/13 - * Time: 1:25 PM - */ -public class RyaStatementAddBindingSetFunction implements Function<RyaStatement, Map.Entry<RyaStatement, BindingSet>> { - @Override - public Map.Entry<RyaStatement, BindingSet> apply(RyaStatement ryaStatement) { - return new RdfCloudTripleStoreUtils.CustomEntry<mvm.rya.api.domain.RyaStatement, org.openrdf.query.BindingSet>(ryaStatement, null); - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/mvm/rya/api/utils/RyaStatementRemoveBindingSetCloseableIteration.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/mvm/rya/api/utils/RyaStatementRemoveBindingSetCloseableIteration.java b/common/rya.api/src/main/java/mvm/rya/api/utils/RyaStatementRemoveBindingSetCloseableIteration.java deleted file mode 100644 index b39fafe..0000000 --- a/common/rya.api/src/main/java/mvm/rya/api/utils/RyaStatementRemoveBindingSetCloseableIteration.java +++ /dev/null @@ -1,61 +0,0 @@ -package mvm.rya.api.utils; - -/* - * 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 info.aduna.iteration.CloseableIteration; -import mvm.rya.api.domain.RyaStatement; -import mvm.rya.api.persist.RyaDAOException; -import org.openrdf.query.BindingSet; - -import java.util.Map; - -/** - * Date: 1/18/13 - * Time: 1:22 PM - */ -public class RyaStatementRemoveBindingSetCloseableIteration implements CloseableIteration<RyaStatement, RyaDAOException>{ - - private CloseableIteration<? extends Map.Entry<RyaStatement, BindingSet>, RyaDAOException> iter; - - public RyaStatementRemoveBindingSetCloseableIteration(CloseableIteration<? extends Map.Entry<RyaStatement, BindingSet>, RyaDAOException> iter) { - this.iter = iter; - } - - @Override - public void close() throws RyaDAOException { - iter.close(); - } - - @Override - public boolean hasNext() throws RyaDAOException { - return iter.hasNext(); - } - - @Override - public RyaStatement next() throws RyaDAOException { - return iter.next().getKey(); - } - - @Override - public void remove() throws RyaDAOException { - } -} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/org/apache/rya/api/InvalidValueTypeMarkerRuntimeException.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/org/apache/rya/api/InvalidValueTypeMarkerRuntimeException.java b/common/rya.api/src/main/java/org/apache/rya/api/InvalidValueTypeMarkerRuntimeException.java new file mode 100644 index 0000000..eea50f4 --- /dev/null +++ b/common/rya.api/src/main/java/org/apache/rya/api/InvalidValueTypeMarkerRuntimeException.java @@ -0,0 +1,55 @@ +package mvm.rya.api; + +/* + * 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. + */ + + + +/** + * Class InvalidValueTypeMarkerRuntimeException + * Date: Jan 7, 2011 + * Time: 12:58:27 PM + */ +public class InvalidValueTypeMarkerRuntimeException extends RuntimeException { + private int valueTypeMarker = -1; + + public InvalidValueTypeMarkerRuntimeException(int valueTypeMarker) { + super(); + this.valueTypeMarker = valueTypeMarker; + } + + public InvalidValueTypeMarkerRuntimeException(int valueTypeMarker, String s) { + super(s); + this.valueTypeMarker = valueTypeMarker; + } + + public InvalidValueTypeMarkerRuntimeException(int valueTypeMarker, String s, Throwable throwable) { + super(s, throwable); + this.valueTypeMarker = valueTypeMarker; + } + + public InvalidValueTypeMarkerRuntimeException(int valueTypeMarker, Throwable throwable) { + super(throwable); + this.valueTypeMarker = valueTypeMarker; + } + + public int getValueTypeMarker() { + return valueTypeMarker; + } +} http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/44a2dcf0/common/rya.api/src/main/java/org/apache/rya/api/RdfCloudTripleStoreConfiguration.java ---------------------------------------------------------------------- diff --git a/common/rya.api/src/main/java/org/apache/rya/api/RdfCloudTripleStoreConfiguration.java b/common/rya.api/src/main/java/org/apache/rya/api/RdfCloudTripleStoreConfiguration.java new file mode 100644 index 0000000..86e22a2 --- /dev/null +++ b/common/rya.api/src/main/java/org/apache/rya/api/RdfCloudTripleStoreConfiguration.java @@ -0,0 +1,520 @@ +package mvm.rya.api; + +/* + * 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.List; + +import mvm.rya.api.layout.TableLayoutStrategy; +import mvm.rya.api.layout.TablePrefixLayoutStrategy; +import mvm.rya.api.persist.RdfEvalStatsDAO; + +import org.apache.hadoop.conf.Configuration; +import org.openrdf.query.algebra.evaluation.QueryOptimizer; + +import com.google.common.base.Joiner; +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; + +/** + * Rdf triple store specific configuration + */ +public abstract class RdfCloudTripleStoreConfiguration extends Configuration { + + // public static final String CONF_ISQUERYTIMEBASED = "query.timebased"; + public static final String CONF_TTL = "query.ttl"; + public static final String CONF_STARTTIME = "query.startTime"; + // public static final String CONF_TIMEINDEXURIS = "query.timeindexuris"; + public static final String CONF_NUM_THREADS = "query.numthreads"; + public static final String CONF_PERFORMANT = "query.performant"; + public static final String CONF_INFER = "query.infer"; + public static final String CONF_USE_STATS = "query.usestats"; + public static final String CONF_USE_COMPOSITE = "query.usecompositecard"; + public static final String CONF_USE_SELECTIVITY = "query.useselectivity"; + public static final String CONF_TBL_PREFIX = "query.tblprefix"; + public static final String CONF_BATCH_SIZE = "query.batchsize"; + public static final String CONF_OFFSET = "query.offset"; + public static final String CONF_LIMIT = "query.limit"; + public static final String CONF_QUERYPLAN_FLAG = "query.printqueryplan"; + public static final String CONF_QUERY_AUTH = "query.auth"; + public static final String CONF_RESULT_FORMAT = "query.resultformat"; + public static final String CONF_CV = "conf.cv"; + public static final String CONF_TBL_SPO = "tbl.spo"; + public static final String CONF_TBL_PO = "tbl.po"; + public static final String CONF_TBL_OSP = "tbl.osp"; + public static final String CONF_TBL_NS = "tbl.ns"; + public static final String CONF_TBL_EVAL = "tbl.eval"; + public static final String CONF_PREFIX_ROW_WITH_HASH = "tbl.hashprefix"; + public static final String CONF_OPTIMIZERS = "query.optimizers"; + public static final String CONF_PCJ_OPTIMIZER = "pcj.query.optimizer"; + public static final String CONF_PCJ_TABLES = "pcj.index.tables"; + + + /** + * @deprecated use CONF_* + */ + @Deprecated + public static final String BINDING_DISP_QUERYPLAN = CONF_QUERYPLAN_FLAG; + /** + * @deprecated use CONF_* + */ + @Deprecated + public static final String BINDING_AUTH = CONF_QUERY_AUTH; + /** + * @deprecated use CONF_* + */ + @Deprecated + public static final String BINDING_CV = CONF_CV; + /** + * @deprecated use CONF_* + */ + @Deprecated + public static final String BINDING_TTL = CONF_TTL; + /** + * @deprecated use CONF_* + */ + @Deprecated + public static final String BINDING_STARTTIME = CONF_STARTTIME; + /** + * @deprecated use CONF_* + */ + @Deprecated + public static final String BINDING_PERFORMANT = CONF_PERFORMANT; + /** + * @deprecated use CONF_* + */ + @Deprecated + public static final String BINDING_INFER = CONF_INFER; + /** + * @deprecated use CONF_* + */ + @Deprecated + public static final String BINDING_USESTATS = CONF_USE_STATS; + /** + * @deprecated use CONF_* + */ + @Deprecated + public static final String BINDING_OFFSET = CONF_OFFSET; + /** + * @deprecated use CONF_* + */ + @Deprecated + public static final String BINDING_LIMIT = CONF_LIMIT; + + public static final String STATS_PUSH_EMPTY_RDFTYPE_DOWN = "conf.stats.rdftype.down"; + public static final String INFER_INCLUDE_INVERSEOF = "infer.include.inverseof"; + public static final String INFER_INCLUDE_SUBCLASSOF = "infer.include.subclassof"; + public static final String INFER_INCLUDE_SUBPROPOF = "infer.include.subpropof"; + public static final String INFER_INCLUDE_SYMMPROP = "infer.include.symmprop"; + public static final String INFER_INCLUDE_TRANSITIVEPROP = "infer.include.transprop"; + + public static final String RDF_DAO_CLASS = "class.rdf.dao"; + public static final String RDF_EVAL_STATS_DAO_CLASS = "class.rdf.evalstats"; + + public static final String REGEX_SUBJECT = "query.regex.subject"; + public static final String REGEX_PREDICATE = "query.regex.predicate"; + public static final String REGEX_OBJECT = "query.regex.object"; + private static final String[] EMPTY_STR_ARR = new String[0]; + + private TableLayoutStrategy tableLayoutStrategy = new TablePrefixLayoutStrategy(); + + public RdfCloudTripleStoreConfiguration() { + } + + public RdfCloudTripleStoreConfiguration(Configuration other) { + super(other); + if (other instanceof RdfCloudTripleStoreConfiguration) { + setTableLayoutStrategy(((RdfCloudTripleStoreConfiguration) other).getTableLayoutStrategy()); + } + } + + @Override + public abstract RdfCloudTripleStoreConfiguration clone(); + + public TableLayoutStrategy getTableLayoutStrategy() { + return tableLayoutStrategy; + } + + public void setTableLayoutStrategy(TableLayoutStrategy tableLayoutStrategy) { + if (tableLayoutStrategy != null) { + this.tableLayoutStrategy = tableLayoutStrategy; + } else { + this.tableLayoutStrategy = new TablePrefixLayoutStrategy(); //default + } + set(CONF_TBL_SPO, this.tableLayoutStrategy.getSpo()); + set(CONF_TBL_PO, this.tableLayoutStrategy.getPo()); + set(CONF_TBL_OSP, this.tableLayoutStrategy.getOsp()); + set(CONF_TBL_NS, this.tableLayoutStrategy.getNs()); + set(CONF_TBL_EVAL, this.tableLayoutStrategy.getEval()); + } + + public Long getTtl() { + String val = get(CONF_TTL); + if (val != null) { + return Long.valueOf(val); + } + return null; + } + + public void setTtl(Long ttl) { + Preconditions.checkNotNull(ttl); + Preconditions.checkArgument(ttl >= 0, "ttl must be non negative"); + set(CONF_TTL, ttl.toString()); + } + + public Long getStartTime() { + String val = get(CONF_STARTTIME); + if (val != null) { + return Long.valueOf(val); + } + return null; + } + + public void setStartTime(Long startTime) { + Preconditions.checkNotNull(startTime); + Preconditions.checkArgument(startTime >= 0, "startTime must be non negative"); + set(CONF_STARTTIME, startTime.toString()); + } + + public Integer getNumThreads() { + return getInt(CONF_NUM_THREADS, 2); + } + + public void setNumThreads(Integer numThreads) { + Preconditions.checkNotNull(numThreads); + Preconditions.checkArgument(numThreads > 0, "numThreads must be greater than 0"); + setInt(CONF_NUM_THREADS, numThreads); + } + + public Boolean isPerformant() { + return getBoolean(CONF_PERFORMANT, true); + } + + public void setPerformant(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(CONF_PERFORMANT, val); + } + + public Boolean isInfer() { + return getBoolean(CONF_INFER, false); + } + + public void setInfer(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(CONF_INFER, val); + } + + public Boolean isUseStats() { + return getBoolean(CONF_USE_STATS, false); + } + + public void setUseStats(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(CONF_USE_STATS, val); + } + + public Boolean isUseSelectivity() { + return getBoolean(CONF_USE_SELECTIVITY, false); + } + + public void setUseSelectivity(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(CONF_USE_SELECTIVITY, val); + } + + public Boolean isPrefixRowsWithHash() { + return getBoolean(CONF_PREFIX_ROW_WITH_HASH, false); + } + + public void setPrefixRowsWithHash(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(CONF_PREFIX_ROW_WITH_HASH, val); + } + + public String getTablePrefix() { + return get(CONF_TBL_PREFIX, RdfCloudTripleStoreConstants.TBL_PRFX_DEF); + } + + public void setTablePrefix(String tablePrefix) { + Preconditions.checkNotNull(tablePrefix); + set(CONF_TBL_PREFIX, tablePrefix); + setTableLayoutStrategy(new TablePrefixLayoutStrategy(tablePrefix)); //TODO: Should we change the layout strategy + } + + public Integer getBatchSize() { + String val = get(CONF_BATCH_SIZE); + if (val != null) { + return Integer.valueOf(val); + } + return null; + } + + public void setBatchSize(Long batchSize) { + Preconditions.checkNotNull(batchSize); + Preconditions.checkArgument(batchSize > 0, "Batch Size must be greater than 0"); + setLong(CONF_BATCH_SIZE, batchSize); + } + + public Long getOffset() { + String val = get(CONF_OFFSET); + if (val != null) { + return Long.valueOf(val); + } + return null; + } + + public void setOffset(Long offset) { + Preconditions.checkNotNull(offset); + Preconditions.checkArgument(offset >= 0, "offset must be positive"); + setLong(CONF_OFFSET, offset); + } + + public Long getLimit() { + String val = get(CONF_LIMIT); + if (val != null) { + return Long.valueOf(val); + } + return null; + } + + public void setLimit(Long limit) { + Preconditions.checkNotNull(limit); + Preconditions.checkArgument(limit >= 0, "limit must be positive"); + setLong(CONF_LIMIT, limit); + } + + + public Boolean isDisplayQueryPlan() { + return getBoolean(CONF_QUERYPLAN_FLAG, false); + } + + public void setDisplayQueryPlan(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(CONF_QUERYPLAN_FLAG, val); + } + + /** + * @return + * @deprecated + */ + @Deprecated + public String getAuth() { + return Joiner.on(",").join(getAuths()); + } + + /** + * @param auth + * @deprecated + */ + @Deprecated + public void setAuth(String auth) { + Preconditions.checkNotNull(auth); + setStrings(CONF_QUERY_AUTH, auth); + } + + public String[] getAuths() { + return getStrings(CONF_QUERY_AUTH, EMPTY_STR_ARR); + } + + public void setAuths(String... auths) { + setStrings(CONF_QUERY_AUTH, auths); + } + + public String getEmit() { + return get(CONF_RESULT_FORMAT); + } + + public void setEmit(String emit) { + Preconditions.checkNotNull(emit); + set(CONF_RESULT_FORMAT, emit); + } + + public String getCv() { + return get(CONF_CV); + } + + public void setCv(String cv) { + Preconditions.checkNotNull(cv); + set(CONF_CV, cv); + } + + + public Boolean isUseCompositeCardinality() { + return getBoolean(CONF_USE_COMPOSITE, true); + } + + public void setCompositeCardinality(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(CONF_USE_COMPOSITE, val); + } + + + public Boolean isStatsPushEmptyRdftypeDown() { + return getBoolean(STATS_PUSH_EMPTY_RDFTYPE_DOWN, true); + } + + public void setStatsPushEmptyRdftypeDown(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(STATS_PUSH_EMPTY_RDFTYPE_DOWN, val); + } + + public Boolean isInferInverseOf() { + return getBoolean(INFER_INCLUDE_INVERSEOF, true); + } + + public void setInferInverseOf(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(INFER_INCLUDE_INVERSEOF, val); + } + + public Boolean isInferSubClassOf() { + return getBoolean(INFER_INCLUDE_SUBCLASSOF, true); + } + + public void setInferSubClassOf(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(INFER_INCLUDE_SUBCLASSOF, val); + } + + public Boolean isInferSubPropertyOf() { + return getBoolean(INFER_INCLUDE_SUBPROPOF, true); + } + + public void setInferSubPropertyOf(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(INFER_INCLUDE_SUBPROPOF, val); + } + + public Boolean isInferSymmetricProperty() { + return getBoolean(INFER_INCLUDE_SYMMPROP, true); + } + + public void setInferSymmetricProperty(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(INFER_INCLUDE_SYMMPROP, val); + } + + public Boolean isInferTransitiveProperty() { + return getBoolean(INFER_INCLUDE_TRANSITIVEPROP, true); + } + + public void setInferTransitiveProperty(Boolean val) { + Preconditions.checkNotNull(val); + setBoolean(INFER_INCLUDE_TRANSITIVEPROP, val); + } + + public void setRdfEvalStatsDaoClass(Class<? extends RdfEvalStatsDAO> rdfEvalStatsDaoClass) { + Preconditions.checkNotNull(rdfEvalStatsDaoClass); + setClass(RDF_EVAL_STATS_DAO_CLASS, rdfEvalStatsDaoClass, RdfEvalStatsDAO.class); + } + + public Class<? extends RdfEvalStatsDAO> getRdfEvalStatsDaoClass() { + return getClass(RDF_EVAL_STATS_DAO_CLASS, null, RdfEvalStatsDAO.class); + } + + + public void setPcjTables(List<String> indexTables) { + Preconditions.checkNotNull(indexTables); + setStrings(CONF_PCJ_TABLES, indexTables.toArray(new String[]{})); + } + + + public List<String> getPcjTables() { + List<String> pcjTables = Lists.newArrayList(); + String[] tables = getStrings(CONF_PCJ_TABLES); + if(tables == null) { + return pcjTables; + } + for(String table: tables) { + Preconditions.checkNotNull(table); + pcjTables.add(table); + } + return pcjTables; + } + + + public void setPcjOptimizer(Class<? extends QueryOptimizer> optimizer) { + Preconditions.checkNotNull(optimizer); + setClass(CONF_PCJ_OPTIMIZER, optimizer, QueryOptimizer.class); + } + + public Class<QueryOptimizer> getPcjOptimizer() { + Class<? extends QueryOptimizer> opt = getClass(CONF_PCJ_OPTIMIZER, null, QueryOptimizer.class); + if (opt != null) { + Preconditions.checkArgument(QueryOptimizer.class.isAssignableFrom(opt)); + return (Class<QueryOptimizer>) opt; + } else { + return null; + } + + } + + + public void setOptimizers(List<Class<? extends QueryOptimizer>> optimizers) { + Preconditions.checkNotNull(optimizers); + List<String> strs = Lists.newArrayList(); + for (Class ai : optimizers){ + Preconditions.checkNotNull(ai); + strs.add(ai.getName()); + } + + setStrings(CONF_OPTIMIZERS, strs.toArray(new String[]{})); + } + + public List<Class<QueryOptimizer>> getOptimizers() { + List<Class<QueryOptimizer>> opts = Lists.newArrayList(); + for (Class<?> clazz : getClasses(CONF_OPTIMIZERS)){ + Preconditions.checkArgument(QueryOptimizer.class.isAssignableFrom(clazz)); + opts.add((Class<QueryOptimizer>) clazz); + } + + return opts; + } + + + + public String getRegexSubject() { + return get(REGEX_SUBJECT); + } + + public void setRegexSubject(String regexSubject) { + Preconditions.checkNotNull(regexSubject); + set(REGEX_SUBJECT, regexSubject); + } + + public String getRegexPredicate() { + return get(REGEX_PREDICATE); + } + + public void setRegexPredicate(String regex) { + Preconditions.checkNotNull(regex); + set(REGEX_PREDICATE, regex); + } + + public String getRegexObject() { + return get(REGEX_OBJECT); + } + + public void setRegexObject(String regex) { + Preconditions.checkNotNull(regex); + set(REGEX_OBJECT, regex); + } +}