/** * Compares instances node by node * <p> * Derived implementations may wish to override this and substitute native * tuple based comparisons * </p> * * @param other * Instance to compare with */ @Override public int compareTo(AbstractNodeTupleWritable<T> 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; }
/** * Compares instances node by node * <p> * Derived implementations may wish to override this and substitute native * tuple based comparisons * </p> * * @param other * Instance to compare with */ @Override public int compareTo(AbstractNodeTupleWritable<T> 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 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); } }
@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); } }