-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add `ExprIpValue` and `IP` data type Signed-off-by: currantw <[email protected]> * Add support for casting (`cast(field_name to ip)`) and remove existing unused sorting syntax. Signed-off-by: currantw <[email protected]> * Update comparison logic to compare in IPv6 Signed-off-by: currantw <[email protected]> * Fix bug casting to IP Signed-off-by: currantw <[email protected]> * Fix failing tests Signed-off-by: currantw <[email protected]> * Assert that comparison only valid if same type, update tests accordingly Signed-off-by: currantw <[email protected]> * Add additional tests to increase code coverage Signed-off-by: currantw <[email protected]> * Integrate `cidrmatch` changes Signed-off-by: currantw <[email protected]> * Remove `OpenSearchIPType` data type Signed-off-by: currantw <[email protected]> * Fix more failing tests Signed-off-by: currantw <[email protected]> * Minor cleanup Signed-off-by: currantw <[email protected]> * Add new tests for IP data type to `SortCommandIT`, and update `weblogs` test data. Signed-off-by: currantw <[email protected]> * Fixing IT test failure. Signed-off-by: currantw <[email protected]> * Spotless and update test to sort in SQL Signed-off-by: currantw <[email protected]> * Fix broken link Signed-off-by: currantw <[email protected]> * Fix failing code coverage Signed-off-by: currantw <[email protected]> * Fix failing doctest Signed-off-by: currantw <[email protected]> * Fix failing `ip.rst` doctest Signed-off-by: currantw <[email protected]> * Fix test failure due to merge. Signed-off-by: currantw <[email protected]> * Fix spotless Signed-off-by: currantw <[email protected]> * Add missing `url` field Signed-off-by: currantw <[email protected]> * Address minor review comments. Signed-off-by: currantw <[email protected]> * Revert sort syntax changes Signed-off-by: currantw <[email protected]> * Minor doc update Signed-off-by: currantw <[email protected]> * FIx failing `ip.rst` doctest Signed-off-by: currantw <[email protected]> * Add `IPComparisonIT` tests for comparison operators, rename modules and weblogs test index to make plural for consistency. Signed-off-by: currantw <[email protected]> --------- Signed-off-by: currantw <[email protected]>
- Loading branch information
Showing
44 changed files
with
803 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
core/src/main/java/org/opensearch/sql/data/model/ExprIpValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.data.model; | ||
|
||
import inet.ipaddr.IPAddress; | ||
import org.opensearch.sql.data.type.ExprCoreType; | ||
import org.opensearch.sql.data.type.ExprType; | ||
import org.opensearch.sql.utils.IPUtils; | ||
|
||
/** Expression IP Address Value. */ | ||
public class ExprIpValue extends AbstractExprValue { | ||
private final IPAddress value; | ||
|
||
public ExprIpValue(String addressString) { | ||
value = IPUtils.toAddress(addressString); | ||
} | ||
|
||
@Override | ||
public String value() { | ||
return value.toCanonicalString(); | ||
} | ||
|
||
@Override | ||
public ExprType type() { | ||
return ExprCoreType.IP; | ||
} | ||
|
||
@Override | ||
public int compare(ExprValue other) { | ||
return IPUtils.compare(value, ((ExprIpValue) other).value); | ||
} | ||
|
||
@Override | ||
public boolean equal(ExprValue other) { | ||
return compare(other) == 0; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("IP %s", value()); | ||
} | ||
|
||
@Override | ||
public IPAddress ipValue() { | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.