/** * Gets whether the set contains a characteristic for the given predicate * * @param n * Predicate * @return True if contained in the set, false otherwise */ public boolean hasCharacteristic(Node n) { return this.hasCharacteristic(new NodeWritable(n)); }
@Override public boolean equals(Object other) { if (!(other instanceof NodeWritable)) return false; return this.compareTo((NodeWritable) other) == 0; } }
/** * 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; }
@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 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 a new writable with the given value * * @param n * Node */ public NodeWritable(Node n) { this.set(n); }
@Override public void readFields(DataInput input) throws IOException { this.node.readFields(input); this.count.readFields(input); }
@Override public int hashCode() { return this.node.hashCode(); }
@Override public String toString() { return "(" + this.node.toString() + ", " + this.count.toString() + ")"; }
@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); }
@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); } }
/** * 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); }
@Override public void readFields(DataInput input) throws IOException { this.node.readFields(input); this.count.readFields(input); }
@Override public int hashCode() { return this.node.hashCode(); }
@Override public String toString() { return "(" + this.node.toString() + ", " + this.count.toString() + ")"; }
@Override protected NodeWritable selectKey(Quad quad) { return new NodeWritable(quad.getGraph()); } }
/** * Creates a characteristic writable with the given node and count * * @param n * Node * @param count * Count */ public CharacteristicWritable(Node n, long count) { this.node.set(n); this.count.set(count); }