Skip to content

Commit

Permalink
refactors to Java 17
Browse files Browse the repository at this point in the history
  • Loading branch information
vmzakharov committed Apr 9, 2024
1 parent d208335 commit 58f34d4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ else if (thatItem == null)
@Override
public boolean equals(Object o)
{
if (o instanceof DfTuple)
if (o instanceof DfTuple dfTuple)
{
DfTuple dfTuple = (DfTuple) o;
return Arrays.equals(this.items, dfTuple.items);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public ProjectionExpr(ListIterable<Expression> newProjectionElements, Expression
for (int i = 0; i < this.projectionElements.size(); i++)
{
Expression element = this.projectionElements.get(i);
if (element instanceof AliasExpr)
if (element instanceof AliasExpr aliasExpr)
{
this.elementNames.add(((AliasExpr) element).getAlias());
this.projectionExpressions.add(((AliasExpr) element).getExpression());
this.elementNames.add(aliasExpr.getAlias());
this.projectionExpressions.add(aliasExpr.getExpression());
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ default void checkSameTypeForComparison(Value other)
.with("className", this.getClass().getSimpleName()).getUnsupported();
}

if (!other.isVoid() && (this.getClass() != other.getClass()))
if (!other.isVoid() && (this.getType() != other.getType()))
{
throw exceptionByKey("DSL_COMPARE_INCOMPATIBLE")
.with("className", this.getClass().getSimpleName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,32 @@ public void expressionSortIsStable()
,
df);
}

@Test
public void sortByBoolean()
{
DataFrame df = new DataFrame("DF")
.addStringColumn("Foo").addLongColumn("Bar")
.addRow("2", -1)
.addRow("3", 2)
.addRow("4", -3)
.addRow("5", 9)
.addRow("6", 1)
.addRow("1", 0)
;

df.sortByExpression("Bar > 0", DESC);

DataFrameUtil.assertEquals(new DataFrame("DF")
.addStringColumn("Foo").addLongColumn("Bar")
.addRow("3", 2)
.addRow("5", 9)
.addRow("6", 1)
.addRow("2", -1)
.addRow("4", -3)
.addRow("1", 0)
,
df
);
}
}

0 comments on commit 58f34d4

Please sign in to comment.