Return-Path:
X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io
Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io
Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183])
by cust-asf2.ponee.io (Postfix) with ESMTP id DF4A9200ABD
for ; Sat, 14 May 2016 19:22:02 +0200 (CEST)
Received: by cust-asf.ponee.io (Postfix)
id DDE97160969; Sat, 14 May 2016 17:22:02 +0000 (UTC)
Delivered-To: archive-asf-public@cust-asf.ponee.io
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by cust-asf.ponee.io (Postfix) with SMTP id E82FE160A28
for ; Sat, 14 May 2016 19:21:59 +0200 (CEST)
Received: (qmail 70110 invoked by uid 500); 14 May 2016 17:21:59 -0000
Mailing-List: contact commits-help@jena.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: dev@jena.apache.org
Delivered-To: mailing list commits@jena.apache.org
Received: (qmail 69612 invoked by uid 99); 14 May 2016 17:21:58 -0000
Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23)
by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 May 2016 17:21:58 +0000
Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33)
id 80D9ADFDC3; Sat, 14 May 2016 17:21:58 +0000 (UTC)
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
From: andy@apache.org
To: commits@jena.apache.org
Date: Sat, 14 May 2016 17:22:15 -0000
Message-Id:
In-Reply-To: <0d5fd73530a64f2aa49b81d0adb874d2@git.apache.org>
References: <0d5fd73530a64f2aa49b81d0adb874d2@git.apache.org>
X-Mailer: ASF-Git Admin Mailer
Subject: [19/40] jena git commit: Fix line endings
archived-at: Sat, 14 May 2016 17:22:03 -0000
http://git-wip-us.apache.org/repos/asf/jena/blob/d6ae87fd/jena-csv/src/test/java/org/apache/jena/propertytable/impl/PropertyTableArrayImplTest.java
----------------------------------------------------------------------
diff --git a/jena-csv/src/test/java/org/apache/jena/propertytable/impl/PropertyTableArrayImplTest.java b/jena-csv/src/test/java/org/apache/jena/propertytable/impl/PropertyTableArrayImplTest.java
index ba1ca2d..fe5fa55 100644
--- a/jena-csv/src/test/java/org/apache/jena/propertytable/impl/PropertyTableArrayImplTest.java
+++ b/jena-csv/src/test/java/org/apache/jena/propertytable/impl/PropertyTableArrayImplTest.java
@@ -1,84 +1,84 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.propertytable.impl;
-
-import org.apache.jena.propertytable.AbstractPropertyTableTest;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Tests for PropertyTableArrayImpl
- *
- */
-public class PropertyTableArrayImplTest extends AbstractPropertyTableTest{
-
- private static int rowNum = 10;
- private static int columnNum = 10 ;
-
- @Before
- public void setUp() {
- table = new PropertyTableArrayImpl(rowNum, columnNum);
- table2 = new PropertyTableArrayImpl(rowNum, columnNum);
- row = table.createRow(rowSubject);
-
- }
-
- @After
- public void tearDown() {
- table = null;
- table2 = null;
- row = null;
- }
-
- @Test
- public void testColumnOutofBounds1() {
- for (int i=0;i
- * The binary encoding of this base implementation is just a variable integer
- * indicating the number of nodes present followed by the binary encodings of
- * the {@link NodeWritable} instances. Derived implementations may wish to
- * override the {@link #readFields(DataInput)} and {@link #write(DataOutput)}
- * methods in order to use more specialised encodings.
- *
- *
- * @param
- * Tuple type
- */
-public abstract class AbstractNodeTupleWritable implements WritableComparable> {
-
- private T tuple;
-
- /**
- * Creates a new empty instance
- */
- protected AbstractNodeTupleWritable() {
- this(null);
- }
-
- /**
- * Creates a new instance with the given value
- *
- * @param tuple
- * Tuple value
- */
- protected AbstractNodeTupleWritable(T tuple) {
- this.tuple = tuple;
- }
-
- /**
- * Gets the tuple
- *
- * @return Tuple
- */
- public T get() {
- return this.tuple;
- }
-
- /**
- * Sets the tuple
- *
- * @param tuple
- * Tuple
- */
- public void set(T tuple) {
- this.tuple = tuple;
- }
-
- @Override
- public void readFields(DataInput input) throws IOException {
- // Determine how many nodes
- int size = WritableUtils.readVInt(input);
- Node[] ns = new Node[size];
-
- NodeWritable nw = new NodeWritable();
- for (int i = 0; i < ns.length; i++) {
- nw.readFields(input);
- ns[i] = nw.get();
- }
-
- // Load the tuple
- this.tuple = this.createTuple(ns);
- }
-
- /**
- * Creates the actual tuple type from an array of nodes
- *
- * @param ns
- * Nodes
- * @return Tuple
- */
- protected abstract T createTuple(Node[] ns);
-
- @Override
- public void write(DataOutput output) throws IOException {
- // Determine how many nodes
- Node[] ns = this.createNodes(this.tuple);
- WritableUtils.writeVInt(output, ns.length);
-
- // Write out nodes
- NodeWritable nw = new NodeWritable();
- for (int i = 0; i < ns.length; i++) {
- nw.set(ns[i]);
- nw.write(output);
- }
- }
-
- /**
- * Sets the tuple value
- *
- * Intended only for internal use i.e. when a derived implementation
- * overrides {@link #readFields(DataInput)} and needs to set the tuple value
- * directly i.e. when a derived implementation is using a custom encoding
- * scheme
- *
- *
- * @param tuple
- * Tuple
- */
- protected final void setInternal(T tuple) {
- this.tuple = tuple;
- }
-
- /**
- * Converts the actual tuple type into an array of nodes
- *
- * @param tuple
- * Tuples
- * @return Nodes
- */
- protected abstract Node[] createNodes(T tuple);
-
- /**
- * Compares instances node by node
- *
- * Derived implementations may wish to override this and substitute native
- * tuple based comparisons
- *
- *
- * @param other
- * Instance to compare with
- */
- @Override
- public int compareTo(AbstractNodeTupleWritable other) {
- Node[] ns = this.createNodes(this.tuple);
- Node[] otherNs = this.createNodes(other.tuple);
-
- if (ns.length < otherNs.length) {
- return -1;
- } else if (ns.length > otherNs.length) {
- return 1;
- }
- // Compare node by node
- for (int i = 0; i < ns.length; i++) {
- int c = NodeUtils.compareRDFTerms(ns[i], otherNs[i]);
- if (c != 0)
- return c;
- }
- return 0;
- }
-
- @Override
- public String toString() {
- return this.get().toString();
- }
-
- @Override
- public int hashCode() {
- return this.get().hashCode();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof AbstractNodeTupleWritable))
- return false;
- return this.compareTo((AbstractNodeTupleWritable) other) == 0;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.types;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.hadoop.io.WritableComparable;
+import org.apache.hadoop.io.WritableUtils;
+import org.apache.jena.graph.Node ;
+import org.apache.jena.sparql.util.NodeUtils ;
+
+/**
+ * A abstract general purpose writable where the actual class represented is
+ * composed of a number of {@link Node} instances
+ *
+ * The binary encoding of this base implementation is just a variable integer
+ * indicating the number of nodes present followed by the binary encodings of
+ * the {@link NodeWritable} instances. Derived implementations may wish to
+ * override the {@link #readFields(DataInput)} and {@link #write(DataOutput)}
+ * methods in order to use more specialised encodings.
+ *
+ *
+ * @param
+ * Tuple type
+ */
+public abstract class AbstractNodeTupleWritable implements WritableComparable> {
+
+ private T tuple;
+
+ /**
+ * Creates a new empty instance
+ */
+ protected AbstractNodeTupleWritable() {
+ this(null);
+ }
+
+ /**
+ * Creates a new instance with the given value
+ *
+ * @param tuple
+ * Tuple value
+ */
+ protected AbstractNodeTupleWritable(T tuple) {
+ this.tuple = tuple;
+ }
+
+ /**
+ * Gets the tuple
+ *
+ * @return Tuple
+ */
+ public T get() {
+ return this.tuple;
+ }
+
+ /**
+ * Sets the tuple
+ *
+ * @param tuple
+ * Tuple
+ */
+ public void set(T tuple) {
+ this.tuple = tuple;
+ }
+
+ @Override
+ public void readFields(DataInput input) throws IOException {
+ // Determine how many nodes
+ int size = WritableUtils.readVInt(input);
+ Node[] ns = new Node[size];
+
+ NodeWritable nw = new NodeWritable();
+ for (int i = 0; i < ns.length; i++) {
+ nw.readFields(input);
+ ns[i] = nw.get();
+ }
+
+ // Load the tuple
+ this.tuple = this.createTuple(ns);
+ }
+
+ /**
+ * Creates the actual tuple type from an array of nodes
+ *
+ * @param ns
+ * Nodes
+ * @return Tuple
+ */
+ protected abstract T createTuple(Node[] ns);
+
+ @Override
+ public void write(DataOutput output) throws IOException {
+ // Determine how many nodes
+ Node[] ns = this.createNodes(this.tuple);
+ WritableUtils.writeVInt(output, ns.length);
+
+ // Write out nodes
+ NodeWritable nw = new NodeWritable();
+ for (int i = 0; i < ns.length; i++) {
+ nw.set(ns[i]);
+ nw.write(output);
+ }
+ }
+
+ /**
+ * Sets the tuple value
+ *
+ * Intended only for internal use i.e. when a derived implementation
+ * overrides {@link #readFields(DataInput)} and needs to set the tuple value
+ * directly i.e. when a derived implementation is using a custom encoding
+ * scheme
+ *
+ *
+ * @param tuple
+ * Tuple
+ */
+ protected final void setInternal(T tuple) {
+ this.tuple = tuple;
+ }
+
+ /**
+ * Converts the actual tuple type into an array of nodes
+ *
+ * @param tuple
+ * Tuples
+ * @return Nodes
+ */
+ protected abstract Node[] createNodes(T tuple);
+
+ /**
+ * Compares instances node by node
+ *
+ * Derived implementations may wish to override this and substitute native
+ * tuple based comparisons
+ *
+ *
+ * @param other
+ * Instance to compare with
+ */
+ @Override
+ public int compareTo(AbstractNodeTupleWritable other) {
+ Node[] ns = this.createNodes(this.tuple);
+ Node[] otherNs = this.createNodes(other.tuple);
+
+ if (ns.length < otherNs.length) {
+ return -1;
+ } else if (ns.length > otherNs.length) {
+ return 1;
+ }
+ // Compare node by node
+ for (int i = 0; i < ns.length; i++) {
+ int c = NodeUtils.compareRDFTerms(ns[i], otherNs[i]);
+ if (c != 0)
+ return c;
+ }
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return this.get().toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return this.get().hashCode();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof AbstractNodeTupleWritable))
+ return false;
+ return this.compareTo((AbstractNodeTupleWritable) other) == 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/d6ae87fd/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/CharacteristicSetWritable.java
----------------------------------------------------------------------
diff --git a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/CharacteristicSetWritable.java b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/CharacteristicSetWritable.java
index 4a29ec4..39599fa 100644
--- a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/CharacteristicSetWritable.java
+++ b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/CharacteristicSetWritable.java
@@ -1,21 +1,21 @@
-/*
- * 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.
- */
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.apache.jena.hadoop.rdf.types;
import java.io.DataInput;
@@ -24,12 +24,12 @@ import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
-
+
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableUtils;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.graph.NodeFactory ;
+import org.apache.jena.graph.Node ;
+import org.apache.jena.graph.NodeFactory ;
/**
* Represents a characteristic set which is comprised of a count of nodes for
http://git-wip-us.apache.org/repos/asf/jena/blob/d6ae87fd/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/CharacteristicWritable.java
----------------------------------------------------------------------
diff --git a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/CharacteristicWritable.java b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/CharacteristicWritable.java
index cfb9606..9fc8a08 100644
--- a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/CharacteristicWritable.java
+++ b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/CharacteristicWritable.java
@@ -1,30 +1,30 @@
-/*
- * 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.
- */
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.apache.jena.hadoop.rdf.types;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
-
+
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.WritableComparable;
-import org.apache.jena.graph.Node ;
+import org.apache.jena.graph.Node ;
/**
* Represents a characteristic for a single node and contains the node and a
http://git-wip-us.apache.org/repos/asf/jena/blob/d6ae87fd/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/NodeTupleWritable.java
----------------------------------------------------------------------
diff --git a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/NodeTupleWritable.java b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/NodeTupleWritable.java
index 9bf7309..d65860b 100644
--- a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/NodeTupleWritable.java
+++ b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/NodeTupleWritable.java
@@ -1,29 +1,29 @@
-/*
- * 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.
- */
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.apache.jena.hadoop.rdf.types;
-import java.io.DataInput;
-import java.io.IOException;
-
-import org.apache.jena.atlas.lib.tuple.Tuple ;
-import org.apache.jena.atlas.lib.tuple.TupleFactory ;
-import org.apache.jena.graph.Node ;
+import java.io.DataInput;
+import java.io.IOException;
+
+import org.apache.jena.atlas.lib.tuple.Tuple ;
+import org.apache.jena.atlas.lib.tuple.TupleFactory ;
+import org.apache.jena.graph.Node ;
/**
* A writable RDF tuple
@@ -75,9 +75,9 @@ public class NodeTupleWritable extends AbstractNodeTupleWritable> {
}
@Override
- protected Node[] createNodes(Tuple tuple) {
+ protected Node[] createNodes(Tuple tuple) {
Node n[] = new Node[tuple.len()] ;
- tuple.copyInto(n);
+ tuple.copyInto(n);
return n ;
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/d6ae87fd/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/NodeWritable.java
----------------------------------------------------------------------
diff --git a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/NodeWritable.java b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/NodeWritable.java
index 2316ae9..7b21b26 100644
--- a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/NodeWritable.java
+++ b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/NodeWritable.java
@@ -1,188 +1,188 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.hadoop.rdf.types;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.hadoop.io.WritableComparable;
-import org.apache.hadoop.io.WritableComparator;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.hadoop.rdf.types.comparators.SimpleBinaryComparator;
-import org.apache.jena.hadoop.rdf.types.converters.ThriftConverter;
-import org.apache.jena.riot.thrift.TRDF;
-import org.apache.jena.riot.thrift.ThriftConvert;
-import org.apache.jena.riot.thrift.wire.RDF_Term;
-import org.apache.jena.sparql.util.NodeUtils ;
-import org.apache.thrift.TException;
-
-/**
- * A writable for {@link Node} instances
- *
- * This uses RDF Thrift
- * for the binary encoding of terms. The in-memory storage for this type is both
- * a {@link Node} and a {@link RDF_Term} with lazy conversion between the two
- * forms as necessary.
- *
- */
-public class NodeWritable implements WritableComparable {
-
- static {
- WritableComparator.define(NodeWritable.class, new SimpleBinaryComparator());
- }
-
- private Node node;
- private RDF_Term term = new RDF_Term();
-
- /**
- * Creates an empty writable
- */
- public NodeWritable() {
- this(null);
- }
-
- /**
- * Creates a new instance from the given input
- *
- * @param input
- * Input
- * @return New instance
- * @throws IOException
- */
- public static NodeWritable read(DataInput input) throws IOException {
- NodeWritable nw = new NodeWritable();
- nw.readFields(input);
- return nw;
- }
-
- /**
- * Creates a new writable with the given value
- *
- * @param n
- * Node
- */
- public NodeWritable(Node n) {
- this.set(n);
- }
-
- /**
- * Gets the node
- *
- * @return Node
- */
- public Node get() {
- // We may not have yet loaded the node
- if (this.node == null) {
- // If term is set to undefined then node is supposed to be null
- if (this.term.isSet() && !this.term.isSetUndefined()) {
- this.node = ThriftConvert.convert(this.term);
- }
- }
- return this.node;
- }
-
- /**
- * Sets the node
- *
- * @param n
- * Node
- */
- public void set(Node n) {
- this.node = n;
- // Clear the term for now
- // We only convert the Node to a term as and when we want to write it
- // out in order to not waste effort if the value is never written out
- this.term.clear();
- }
-
- @Override
- public void readFields(DataInput input) throws IOException {
- // Clear previous value
- this.node = null;
- this.term.clear();
-
- // Read in the new value
- int termLength = input.readInt();
- byte[] buffer = new byte[termLength];
- input.readFully(buffer);
- try {
- ThriftConverter.fromBytes(buffer, this.term);
- } catch (TException e) {
- throw new IOException(e);
- }
-
- // Note that we don't convert it back into a Node at this time
- }
-
- @Override
- public void write(DataOutput output) throws IOException {
- // May not yet have prepared the Thrift term
- if (!this.term.isSet()) {
- if (this.node == null) {
- this.term.setUndefined(TRDF.UNDEF);
- } else {
- ThriftConvert.toThrift(this.node, null, this.term, false);
- }
- }
-
- // Write out the Thrift term
- byte[] buffer;
- try {
- buffer = ThriftConverter.toBytes(this.term);
- } catch (TException e) {
- throw new IOException(e);
- }
- output.writeInt(buffer.length);
- output.write(buffer);
- }
-
- @Override
- public int compareTo(NodeWritable other) {
- // Use get() rather than accessing the field directly because the node
- // field is lazily instantiated from the Thrift term
- return NodeUtils.compareRDFTerms(this.get(), other.get());
- }
-
- @Override
- public String toString() {
- // Use get() rather than accessing the field directly because the node
- // field is lazily instantiated from the Thrift term
- Node n = this.get();
- if (n == null)
- return "";
- return n.toString();
- }
-
- @Override
- public int hashCode() {
- // Use get() rather than accessing the field directly because the node
- // field is lazily instantiated from the Thrift term
- Node n = this.get();
- return n != null ? this.get().hashCode() : 0;
- }
-
- @Override
- public boolean equals(Object other) {
- if (!(other instanceof NodeWritable))
- return false;
- return this.compareTo((NodeWritable) other) == 0;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.types;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.hadoop.io.WritableComparable;
+import org.apache.hadoop.io.WritableComparator;
+import org.apache.jena.graph.Node ;
+import org.apache.jena.hadoop.rdf.types.comparators.SimpleBinaryComparator;
+import org.apache.jena.hadoop.rdf.types.converters.ThriftConverter;
+import org.apache.jena.riot.thrift.TRDF;
+import org.apache.jena.riot.thrift.ThriftConvert;
+import org.apache.jena.riot.thrift.wire.RDF_Term;
+import org.apache.jena.sparql.util.NodeUtils ;
+import org.apache.thrift.TException;
+
+/**
+ * A writable for {@link Node} instances
+ *
+ * This uses RDF Thrift
+ * for the binary encoding of terms. The in-memory storage for this type is both
+ * a {@link Node} and a {@link RDF_Term} with lazy conversion between the two
+ * forms as necessary.
+ *
+ */
+public class NodeWritable implements WritableComparable {
+
+ static {
+ WritableComparator.define(NodeWritable.class, new SimpleBinaryComparator());
+ }
+
+ private Node node;
+ private RDF_Term term = new RDF_Term();
+
+ /**
+ * Creates an empty writable
+ */
+ public NodeWritable() {
+ this(null);
+ }
+
+ /**
+ * Creates a new instance from the given input
+ *
+ * @param input
+ * Input
+ * @return New instance
+ * @throws IOException
+ */
+ public static NodeWritable read(DataInput input) throws IOException {
+ NodeWritable nw = new NodeWritable();
+ nw.readFields(input);
+ return nw;
+ }
+
+ /**
+ * Creates a new writable with the given value
+ *
+ * @param n
+ * Node
+ */
+ public NodeWritable(Node n) {
+ this.set(n);
+ }
+
+ /**
+ * Gets the node
+ *
+ * @return Node
+ */
+ public Node get() {
+ // We may not have yet loaded the node
+ if (this.node == null) {
+ // If term is set to undefined then node is supposed to be null
+ if (this.term.isSet() && !this.term.isSetUndefined()) {
+ this.node = ThriftConvert.convert(this.term);
+ }
+ }
+ return this.node;
+ }
+
+ /**
+ * Sets the node
+ *
+ * @param n
+ * Node
+ */
+ public void set(Node n) {
+ this.node = n;
+ // Clear the term for now
+ // We only convert the Node to a term as and when we want to write it
+ // out in order to not waste effort if the value is never written out
+ this.term.clear();
+ }
+
+ @Override
+ public void readFields(DataInput input) throws IOException {
+ // Clear previous value
+ this.node = null;
+ this.term.clear();
+
+ // Read in the new value
+ int termLength = input.readInt();
+ byte[] buffer = new byte[termLength];
+ input.readFully(buffer);
+ try {
+ ThriftConverter.fromBytes(buffer, this.term);
+ } catch (TException e) {
+ throw new IOException(e);
+ }
+
+ // Note that we don't convert it back into a Node at this time
+ }
+
+ @Override
+ public void write(DataOutput output) throws IOException {
+ // May not yet have prepared the Thrift term
+ if (!this.term.isSet()) {
+ if (this.node == null) {
+ this.term.setUndefined(TRDF.UNDEF);
+ } else {
+ ThriftConvert.toThrift(this.node, null, this.term, false);
+ }
+ }
+
+ // Write out the Thrift term
+ byte[] buffer;
+ try {
+ buffer = ThriftConverter.toBytes(this.term);
+ } catch (TException e) {
+ throw new IOException(e);
+ }
+ output.writeInt(buffer.length);
+ output.write(buffer);
+ }
+
+ @Override
+ public int compareTo(NodeWritable other) {
+ // Use get() rather than accessing the field directly because the node
+ // field is lazily instantiated from the Thrift term
+ return NodeUtils.compareRDFTerms(this.get(), other.get());
+ }
+
+ @Override
+ public String toString() {
+ // Use get() rather than accessing the field directly because the node
+ // field is lazily instantiated from the Thrift term
+ Node n = this.get();
+ if (n == null)
+ return "";
+ return n.toString();
+ }
+
+ @Override
+ public int hashCode() {
+ // Use get() rather than accessing the field directly because the node
+ // field is lazily instantiated from the Thrift term
+ Node n = this.get();
+ return n != null ? this.get().hashCode() : 0;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (!(other instanceof NodeWritable))
+ return false;
+ return this.compareTo((NodeWritable) other) == 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/d6ae87fd/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/QuadWritable.java
----------------------------------------------------------------------
diff --git a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/QuadWritable.java b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/QuadWritable.java
index e862c04..31f9645 100644
--- a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/QuadWritable.java
+++ b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/QuadWritable.java
@@ -1,135 +1,135 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.hadoop.rdf.types;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.hadoop.io.WritableComparator;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.hadoop.rdf.types.comparators.SimpleBinaryComparator;
-import org.apache.jena.hadoop.rdf.types.converters.ThriftConverter;
-import org.apache.jena.riot.thrift.ThriftConvert;
-import org.apache.jena.riot.thrift.wire.RDF_Quad;
-import org.apache.jena.sparql.core.Quad ;
-import org.apache.thrift.TException;
-
-/**
- * A writable quad
- */
-public class QuadWritable extends AbstractNodeTupleWritable {
-
- static {
- WritableComparator.define(QuadWritable.class, new SimpleBinaryComparator());
- }
-
- private RDF_Quad quad = new RDF_Quad();
-
- /**
- * Creates a new empty instance
- */
- public QuadWritable() {
- this(null);
- }
-
- /**
- * Creates a new instance with the given value
- *
- * @param q
- * Quad
- */
- public QuadWritable(Quad q) {
- super(q);
- }
-
- /**
- * Creates a new instance from the given input
- *
- * @param input
- * Input
- * @return New instance
- * @throws IOException
- */
- public static QuadWritable read(DataInput input) throws IOException {
- QuadWritable q = new QuadWritable();
- q.readFields(input);
- return q;
- }
-
- @Override
- public void set(Quad tuple) {
- super.set(tuple);
- this.quad.clear();
- }
-
- @Override
- public void readFields(DataInput input) throws IOException {
- this.quad.clear();
- int tripleLength = input.readInt();
- byte[] buffer = new byte[tripleLength];
- input.readFully(buffer);
- try {
- ThriftConverter.fromBytes(buffer, this.quad);
- } catch (TException e) {
- throw new IOException(e);
- }
- this.setInternal(new Quad(ThriftConvert.convert(this.quad.getG()), ThriftConvert.convert(this.quad.getS()),
- ThriftConvert.convert(this.quad.getP()), ThriftConvert.convert(this.quad.getO())));
- }
-
- @Override
- public void write(DataOutput output) throws IOException {
- if (this.get() == null)
- throw new IOException(
- "Null quads cannot be written using this class, consider using NodeTupleWritable instead");
-
- // May not have yet prepared the Thrift triple
- if (!this.quad.isSetS()) {
- Quad tuple = this.get();
- this.quad.setG(ThriftConvert.convert(tuple.getGraph(), false));
- this.quad.setS(ThriftConvert.convert(tuple.getSubject(), false));
- this.quad.setP(ThriftConvert.convert(tuple.getPredicate(), false));
- this.quad.setO(ThriftConvert.convert(tuple.getObject(), false));
- }
-
- byte[] buffer;
- try {
- buffer = ThriftConverter.toBytes(this.quad);
- } catch (TException e) {
- throw new IOException(e);
- }
- output.writeInt(buffer.length);
- output.write(buffer);
- }
-
- @Override
- protected Quad createTuple(Node[] ns) {
- if (ns.length != 4)
- throw new IllegalArgumentException(String.format(
- "Incorrect number of nodes to form a quad - got %d but expected 4", ns.length));
- return new Quad(ns[0], ns[1], ns[2], ns[3]);
- }
-
- @Override
- protected Node[] createNodes(Quad tuple) {
- return new Node[] { tuple.getGraph(), tuple.getSubject(), tuple.getPredicate(), tuple.getObject() };
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.types;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.hadoop.io.WritableComparator;
+import org.apache.jena.graph.Node ;
+import org.apache.jena.hadoop.rdf.types.comparators.SimpleBinaryComparator;
+import org.apache.jena.hadoop.rdf.types.converters.ThriftConverter;
+import org.apache.jena.riot.thrift.ThriftConvert;
+import org.apache.jena.riot.thrift.wire.RDF_Quad;
+import org.apache.jena.sparql.core.Quad ;
+import org.apache.thrift.TException;
+
+/**
+ * A writable quad
+ */
+public class QuadWritable extends AbstractNodeTupleWritable {
+
+ static {
+ WritableComparator.define(QuadWritable.class, new SimpleBinaryComparator());
+ }
+
+ private RDF_Quad quad = new RDF_Quad();
+
+ /**
+ * Creates a new empty instance
+ */
+ public QuadWritable() {
+ this(null);
+ }
+
+ /**
+ * Creates a new instance with the given value
+ *
+ * @param q
+ * Quad
+ */
+ public QuadWritable(Quad q) {
+ super(q);
+ }
+
+ /**
+ * Creates a new instance from the given input
+ *
+ * @param input
+ * Input
+ * @return New instance
+ * @throws IOException
+ */
+ public static QuadWritable read(DataInput input) throws IOException {
+ QuadWritable q = new QuadWritable();
+ q.readFields(input);
+ return q;
+ }
+
+ @Override
+ public void set(Quad tuple) {
+ super.set(tuple);
+ this.quad.clear();
+ }
+
+ @Override
+ public void readFields(DataInput input) throws IOException {
+ this.quad.clear();
+ int tripleLength = input.readInt();
+ byte[] buffer = new byte[tripleLength];
+ input.readFully(buffer);
+ try {
+ ThriftConverter.fromBytes(buffer, this.quad);
+ } catch (TException e) {
+ throw new IOException(e);
+ }
+ this.setInternal(new Quad(ThriftConvert.convert(this.quad.getG()), ThriftConvert.convert(this.quad.getS()),
+ ThriftConvert.convert(this.quad.getP()), ThriftConvert.convert(this.quad.getO())));
+ }
+
+ @Override
+ public void write(DataOutput output) throws IOException {
+ if (this.get() == null)
+ throw new IOException(
+ "Null quads cannot be written using this class, consider using NodeTupleWritable instead");
+
+ // May not have yet prepared the Thrift triple
+ if (!this.quad.isSetS()) {
+ Quad tuple = this.get();
+ this.quad.setG(ThriftConvert.convert(tuple.getGraph(), false));
+ this.quad.setS(ThriftConvert.convert(tuple.getSubject(), false));
+ this.quad.setP(ThriftConvert.convert(tuple.getPredicate(), false));
+ this.quad.setO(ThriftConvert.convert(tuple.getObject(), false));
+ }
+
+ byte[] buffer;
+ try {
+ buffer = ThriftConverter.toBytes(this.quad);
+ } catch (TException e) {
+ throw new IOException(e);
+ }
+ output.writeInt(buffer.length);
+ output.write(buffer);
+ }
+
+ @Override
+ protected Quad createTuple(Node[] ns) {
+ if (ns.length != 4)
+ throw new IllegalArgumentException(String.format(
+ "Incorrect number of nodes to form a quad - got %d but expected 4", ns.length));
+ return new Quad(ns[0], ns[1], ns[2], ns[3]);
+ }
+
+ @Override
+ protected Node[] createNodes(Quad tuple) {
+ return new Node[] { tuple.getGraph(), tuple.getSubject(), tuple.getPredicate(), tuple.getObject() };
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/d6ae87fd/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/TripleWritable.java
----------------------------------------------------------------------
diff --git a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/TripleWritable.java b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/TripleWritable.java
index 2457bb7..ba81b66 100644
--- a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/TripleWritable.java
+++ b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/TripleWritable.java
@@ -1,137 +1,137 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.hadoop.rdf.types;
-
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.hadoop.io.WritableComparator;
-import org.apache.jena.graph.Node ;
-import org.apache.jena.graph.Triple ;
-import org.apache.jena.hadoop.rdf.types.comparators.SimpleBinaryComparator;
-import org.apache.jena.hadoop.rdf.types.converters.ThriftConverter;
-import org.apache.jena.riot.thrift.ThriftConvert;
-import org.apache.jena.riot.thrift.wire.RDF_Triple;
-import org.apache.thrift.TException;
-
-/**
- * A writable triple
- *
- *
- *
- */
-public class TripleWritable extends AbstractNodeTupleWritable {
-
- static {
- WritableComparator.define(TripleWritable.class, new SimpleBinaryComparator());
- }
-
- private RDF_Triple triple = new RDF_Triple();
-
- /**
- * Creates a new instance using the default NTriples node formatter
- */
- public TripleWritable() {
- this(null);
- }
-
- /**
- * Creates a new instance with a given value that uses a specific node
- * formatter
- *
- * @param t
- * Triple
- */
- public TripleWritable(Triple t) {
- super(t);
- }
-
- /**
- * Creates a new instance from the given input
- *
- * @param input
- * Input
- * @return New instance
- * @throws IOException
- */
- public static TripleWritable read(DataInput input) throws IOException {
- TripleWritable t = new TripleWritable();
- t.readFields(input);
- return t;
- }
-
- @Override
- public void set(Triple tuple) {
- super.set(tuple);
- this.triple.clear();
- }
-
- @Override
- public void readFields(DataInput input) throws IOException {
- this.triple.clear();
- int tripleLength = input.readInt();
- byte[] buffer = new byte[tripleLength];
- input.readFully(buffer);
- try {
- ThriftConverter.fromBytes(buffer, this.triple);
- } catch (TException e) {
- throw new IOException(e);
- }
- this.setInternal(new Triple(ThriftConvert.convert(this.triple.getS()),
- ThriftConvert.convert(this.triple.getP()), ThriftConvert.convert(this.triple.getO())));
- }
-
- @Override
- public void write(DataOutput output) throws IOException {
- if (this.get() == null)
- throw new IOException(
- "Null triples cannot be written using this class, consider using NodeTupleWritable instead");
-
- // May not have yet prepared the Thrift triple
- if (!this.triple.isSetS()) {
- Triple tuple = this.get();
- this.triple.setS(ThriftConvert.convert(tuple.getSubject(), false));
- this.triple.setP(ThriftConvert.convert(tuple.getPredicate(), false));
- this.triple.setO(ThriftConvert.convert(tuple.getObject(), false));
- }
-
- byte[] buffer;
- try {
- buffer = ThriftConverter.toBytes(this.triple);
- } catch (TException e) {
- throw new IOException(e);
- }
- output.writeInt(buffer.length);
- output.write(buffer);
- }
-
- @Override
- protected Triple createTuple(Node[] ns) {
- if (ns.length != 3)
- throw new IllegalArgumentException(String.format(
- "Incorrect number of nodes to form a triple - got %d but expected 3", ns.length));
- return new Triple(ns[0], ns[1], ns[2]);
- }
-
- @Override
- protected Node[] createNodes(Triple tuple) {
- return new Node[] { tuple.getSubject(), tuple.getPredicate(), tuple.getObject() };
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.types;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.hadoop.io.WritableComparator;
+import org.apache.jena.graph.Node ;
+import org.apache.jena.graph.Triple ;
+import org.apache.jena.hadoop.rdf.types.comparators.SimpleBinaryComparator;
+import org.apache.jena.hadoop.rdf.types.converters.ThriftConverter;
+import org.apache.jena.riot.thrift.ThriftConvert;
+import org.apache.jena.riot.thrift.wire.RDF_Triple;
+import org.apache.thrift.TException;
+
+/**
+ * A writable triple
+ *
+ *
+ *
+ */
+public class TripleWritable extends AbstractNodeTupleWritable {
+
+ static {
+ WritableComparator.define(TripleWritable.class, new SimpleBinaryComparator());
+ }
+
+ private RDF_Triple triple = new RDF_Triple();
+
+ /**
+ * Creates a new instance using the default NTriples node formatter
+ */
+ public TripleWritable() {
+ this(null);
+ }
+
+ /**
+ * Creates a new instance with a given value that uses a specific node
+ * formatter
+ *
+ * @param t
+ * Triple
+ */
+ public TripleWritable(Triple t) {
+ super(t);
+ }
+
+ /**
+ * Creates a new instance from the given input
+ *
+ * @param input
+ * Input
+ * @return New instance
+ * @throws IOException
+ */
+ public static TripleWritable read(DataInput input) throws IOException {
+ TripleWritable t = new TripleWritable();
+ t.readFields(input);
+ return t;
+ }
+
+ @Override
+ public void set(Triple tuple) {
+ super.set(tuple);
+ this.triple.clear();
+ }
+
+ @Override
+ public void readFields(DataInput input) throws IOException {
+ this.triple.clear();
+ int tripleLength = input.readInt();
+ byte[] buffer = new byte[tripleLength];
+ input.readFully(buffer);
+ try {
+ ThriftConverter.fromBytes(buffer, this.triple);
+ } catch (TException e) {
+ throw new IOException(e);
+ }
+ this.setInternal(new Triple(ThriftConvert.convert(this.triple.getS()),
+ ThriftConvert.convert(this.triple.getP()), ThriftConvert.convert(this.triple.getO())));
+ }
+
+ @Override
+ public void write(DataOutput output) throws IOException {
+ if (this.get() == null)
+ throw new IOException(
+ "Null triples cannot be written using this class, consider using NodeTupleWritable instead");
+
+ // May not have yet prepared the Thrift triple
+ if (!this.triple.isSetS()) {
+ Triple tuple = this.get();
+ this.triple.setS(ThriftConvert.convert(tuple.getSubject(), false));
+ this.triple.setP(ThriftConvert.convert(tuple.getPredicate(), false));
+ this.triple.setO(ThriftConvert.convert(tuple.getObject(), false));
+ }
+
+ byte[] buffer;
+ try {
+ buffer = ThriftConverter.toBytes(this.triple);
+ } catch (TException e) {
+ throw new IOException(e);
+ }
+ output.writeInt(buffer.length);
+ output.write(buffer);
+ }
+
+ @Override
+ protected Triple createTuple(Node[] ns) {
+ if (ns.length != 3)
+ throw new IllegalArgumentException(String.format(
+ "Incorrect number of nodes to form a triple - got %d but expected 3", ns.length));
+ return new Triple(ns[0], ns[1], ns[2]);
+ }
+
+ @Override
+ protected Node[] createNodes(Triple tuple) {
+ return new Node[] { tuple.getSubject(), tuple.getPredicate(), tuple.getObject() };
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/d6ae87fd/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/comparators/SimpleBinaryComparator.java
----------------------------------------------------------------------
diff --git a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/comparators/SimpleBinaryComparator.java b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/comparators/SimpleBinaryComparator.java
index 6c46714..cc2924d 100644
--- a/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/comparators/SimpleBinaryComparator.java
+++ b/jena-elephas/jena-elephas-common/src/main/java/org/apache/jena/hadoop/rdf/types/comparators/SimpleBinaryComparator.java
@@ -1,34 +1,34 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.hadoop.rdf.types.comparators;
-
-import org.apache.hadoop.io.WritableComparator;
-
-/**
- * A general purpose comparator that may be used with any types which can be
- * compared directly on their binary encodings
- */
-public class SimpleBinaryComparator extends WritableComparator {
-
- @Override
- public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
- return WritableComparator.compareBytes(b1, s1, l1, b2, s2, l2);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.hadoop.rdf.types.comparators;
+
+import org.apache.hadoop.io.WritableComparator;
+
+/**
+ * A general purpose comparator that may be used with any types which can be
+ * compared directly on their binary encodings
+ */
+public class SimpleBinaryComparator extends WritableComparator {
+
+ @Override
+ public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
+ return WritableComparator.compareBytes(b1, s1, l1, b2, s2, l2);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/d6ae87fd/jena-elephas/jena-elephas-common/src/test/java/org/apache/jena/hadoop/rdf/io/types/CharacteristicTests.java
----------------------------------------------------------------------
diff --git a/jena-elephas/jena-elephas-common/src/test/java/org/apache/jena/hadoop/rdf/io/types/CharacteristicTests.java b/jena-elephas/jena-elephas-common/src/test/java/org/apache/jena/hadoop/rdf/io/types/CharacteristicTests.java
index aded8c4..5edff0f 100644
--- a/jena-elephas/jena-elephas-common/src/test/java/org/apache/jena/hadoop/rdf/io/types/CharacteristicTests.java
+++ b/jena-elephas/jena-elephas-common/src/test/java/org/apache/jena/hadoop/rdf/io/types/CharacteristicTests.java
@@ -1,21 +1,21 @@
-/*
- * 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.
- */
-
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package org.apache.jena.hadoop.rdf.io.types;
import java.io.ByteArrayInputStream;
@@ -24,11 +24,11 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Iterator;
-
-import org.apache.jena.graph.Node ;
-import org.apache.jena.graph.NodeFactory ;
-import org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable;
-import org.apache.jena.hadoop.rdf.types.CharacteristicWritable;
+
+import org.apache.jena.graph.Node ;
+import org.apache.jena.graph.NodeFactory ;
+import org.apache.jena.hadoop.rdf.types.CharacteristicSetWritable;
+import org.apache.jena.hadoop.rdf.types.CharacteristicWritable;
import org.junit.Assert;
import org.junit.Test;