@Test public void testCompareTo() throws Exception { RyaStatementWritable rsw1 = new RyaStatementWritable(rs1, ryaContext); RyaStatementWritable rsw1b = new RyaStatementWritable(rs1b, null); RyaStatementWritable rsw2 = new RyaStatementWritable(rs2, null); RyaStatementWritable rswGraph = new RyaStatementWritable(rsCv, ryaContext); RyaStatementWritable rswCv = new RyaStatementWritable(rsCv, ryaContext); RyaStatementWritable rswQualifier = new RyaStatementWritable(rsQualifier, ryaContext); RyaStatementWritable rswTimestamp = new RyaStatementWritable(rsTimestamp, ryaContext); Assert.assertEquals("x.compareTo(x) should always return 0", 0, rsw1.compareTo(rsw1)); Assert.assertEquals("x.compareTo(x') where x and x' are equal should return 0", 0, rsw1.compareTo(rsw1b)); Assert.assertEquals("x.compareTo(x') where x and x' are equal should return 0", 0, rsw1b.compareTo(rsw1)); Assert.assertNotEquals("Statements with different named graphs are not equal", 0, rsw1.compareTo(rswGraph)); Assert.assertNotEquals("Statements with different column visibilities are not equal", 0, rsw1.compareTo(rswCv)); Assert.assertNotEquals("Statements with different column qualifiers are not equal", 0, rsw1.compareTo(rswQualifier)); Assert.assertNotEquals("Statements with different timestamps are not equal", 0, rsw1.compareTo(rswTimestamp)); Assert.assertEquals("compareTo in opposite directions should yield opposite signs", Integer.signum(rsw1.compareTo(rsw2))*-1, Integer.signum(rsw2.compareTo(rsw1))); int x = Integer.signum(rsw1.compareTo(rsw2)) + Integer.signum(rsw2.compareTo(rsw1b)) + Integer.signum(rsw1b.compareTo(rsw1)); Assert.assertNotEquals("compareTo cycle detected", 3, Math.abs(x)); expected.expect(NullPointerException.class); rsw1.compareTo(null); }
@Override public int compareTo(RyaStatementWritable other) { CompareToBuilder builder = new CompareToBuilder(); RyaStatement rsThis = this.getRyaStatement(); RyaStatement rsOther = other.getRyaStatement(); builder.append(rsThis == null, rsOther == null); if (rsThis != null && rsOther != null) { builder.append(rsThis.getSubject(), rsOther.getSubject()); builder.append(rsThis.getPredicate(), rsOther.getPredicate()); builder.append(rsThis.getObject(), rsOther.getObject()); builder.append(rsThis.getContext(), rsOther.getContext()); builder.append(rsThis.getQualifer(), rsOther.getQualifer()); builder.append(rsThis.getColumnVisibility(), rsOther.getColumnVisibility()); builder.append(rsThis.getValue(), rsOther.getValue()); builder.append(rsThis.getTimestamp(), rsOther.getTimestamp()); } return builder.toComparison(); }
RyaStatementWritable implements WritableComparable<RyaStatementWritable> { @Override public int compareTo(RyaStatementWritable other) { CompareToBuilder builder = new CompareToBuilder(); RyaStatement rsThis = this.getRyaStatement(); RyaStatement rsOther = other.getRyaStatement(); builder.append(rsThis == null, rsOther == null); if (rsThis != null && rsOther != null) { builder.append(rsThis.getSubject(), rsOther.getSubject()); builder.append(rsThis.getPredicate(), rsOther.getPredicate()); builder.append(rsThis.getObject(), rsOther.getObject()); builder.append(rsThis.getContext(), rsOther.getContext()); builder.append(rsThis.getQualifer(), rsOther.getQualifer()); builder.append(rsThis.getColumnVisibility(), rsOther.getColumnVisibility()); builder.append(rsThis.getValue(), rsOther.getValue()); builder.append(rsThis.getTimestamp(), rsOther.getTimestamp()); } return builder.toComparison(); } }
RyaStatementWritable implements WritableComparable<RyaStatementWritable> { @Override public int compareTo(RyaStatementWritable other) { CompareToBuilder builder = new CompareToBuilder(); RyaStatement rsThis = this.getRyaStatement(); RyaStatement rsOther = other.getRyaStatement(); builder.append(rsThis == null, rsOther == null); if (rsThis != null && rsOther != null) { builder.append(rsThis.getSubject(), rsOther.getSubject()); builder.append(rsThis.getPredicate(), rsOther.getPredicate()); builder.append(rsThis.getObject(), rsOther.getObject()); builder.append(rsThis.getContext(), rsOther.getContext()); builder.append(rsThis.getQualifer(), rsOther.getQualifer()); builder.append(rsThis.getColumnVisibility(), rsOther.getColumnVisibility()); builder.append(rsThis.getValue(), rsOther.getValue()); builder.append(rsThis.getTimestamp(), rsOther.getTimestamp()); } return builder.toComparison(); } RyaStatementWritable(Configuration conf);  RyaStatementWritable(RyaTripleContext ryaContext);  RyaStatementWritable();  RyaStatementWritable(RyaStatement ryaStatement, RyaTripleContext ryaContext); }
RyaStatementWritable implements WritableComparable<RyaStatementWritable> { @Override public int compareTo(RyaStatementWritable other) { CompareToBuilder builder = new CompareToBuilder(); RyaStatement rsThis = this.getRyaStatement(); RyaStatement rsOther = other.getRyaStatement(); builder.append(rsThis == null, rsOther == null); if (rsThis != null && rsOther != null) { builder.append(rsThis.getSubject(), rsOther.getSubject()); builder.append(rsThis.getPredicate(), rsOther.getPredicate()); builder.append(rsThis.getObject(), rsOther.getObject()); builder.append(rsThis.getContext(), rsOther.getContext()); builder.append(rsThis.getQualifer(), rsOther.getQualifer()); builder.append(rsThis.getColumnVisibility(), rsOther.getColumnVisibility()); builder.append(rsThis.getValue(), rsOther.getValue()); builder.append(rsThis.getTimestamp(), rsOther.getTimestamp()); } return builder.toComparison(); } RyaStatementWritable(Configuration conf);  RyaStatementWritable(RyaTripleContext ryaContext);  RyaStatementWritable();  RyaStatementWritable(RyaStatement ryaStatement, RyaTripleContext ryaContext); RyaStatement getRyaStatement(); void setRyaStatement(RyaStatement ryaStatement); @Override int compareTo(RyaStatementWritable other); @Override int hashCode(); @Override boolean equals(Object o); @Override void write(DataOutput dataOutput); @Override void readFields(DataInput dataInput); }
RyaStatementWritable implements WritableComparable<RyaStatementWritable> { @Override public int compareTo(RyaStatementWritable other) { CompareToBuilder builder = new CompareToBuilder(); RyaStatement rsThis = this.getRyaStatement(); RyaStatement rsOther = other.getRyaStatement(); builder.append(rsThis == null, rsOther == null); if (rsThis != null && rsOther != null) { builder.append(rsThis.getSubject(), rsOther.getSubject()); builder.append(rsThis.getPredicate(), rsOther.getPredicate()); builder.append(rsThis.getObject(), rsOther.getObject()); builder.append(rsThis.getContext(), rsOther.getContext()); builder.append(rsThis.getQualifer(), rsOther.getQualifer()); builder.append(rsThis.getColumnVisibility(), rsOther.getColumnVisibility()); builder.append(rsThis.getValue(), rsOther.getValue()); builder.append(rsThis.getTimestamp(), rsOther.getTimestamp()); } return builder.toComparison(); } RyaStatementWritable(Configuration conf);  RyaStatementWritable(RyaTripleContext ryaContext);  RyaStatementWritable();  RyaStatementWritable(RyaStatement ryaStatement, RyaTripleContext ryaContext); RyaStatement getRyaStatement(); void setRyaStatement(RyaStatement ryaStatement); @Override int compareTo(RyaStatementWritable other); @Override int hashCode(); @Override boolean equals(Object o); @Override void write(DataOutput dataOutput); @Override void readFields(DataInput dataInput);  }