forked from 4paradigm/OpenMLDB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support custom order in insert stmt (4paradigm#2075)
- Loading branch information
1 parent
b2762f9
commit 053c4e3
Showing
16 changed files
with
798 additions
and
558 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
120 changes: 120 additions & 0 deletions
120
java/openmldb-jdbc/src/main/java/com/_4paradigm/openmldb/common/Pair.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,120 @@ | ||
/* | ||
* Copyright 2021 4Paradigm | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com._4paradigm.openmldb.common; | ||
|
||
import java.io.Serializable; | ||
|
||
public class Pair<K, V> implements Serializable { | ||
|
||
/** | ||
* Key of this <code>Pair</code>. | ||
*/ | ||
private K key; | ||
|
||
/** | ||
* Gets the key for this pair. | ||
* | ||
* @return key for this pair | ||
*/ | ||
public K getKey() { | ||
return key; | ||
} | ||
|
||
/** | ||
* Value of this this <code>Pair</code>. | ||
*/ | ||
private V value; | ||
|
||
/** | ||
* Gets the value for this pair. | ||
* | ||
* @return value for this pair | ||
*/ | ||
public V getValue() { | ||
return value; | ||
} | ||
|
||
/** | ||
* Creates a new pair | ||
* | ||
* @param key The key for this pair | ||
* @param value The value to use for this pair | ||
*/ | ||
public Pair(K key, V value) { | ||
this.key = key; | ||
this.value = value; | ||
} | ||
|
||
/** | ||
* <p><code>String</code> representation of this | ||
* <code>Pair</code>.</p> | ||
* | ||
* <p>The default name/value delimiter '=' is always used.</p> | ||
* | ||
* @return <code>String</code> representation of this <code>Pair</code> | ||
*/ | ||
@Override | ||
public String toString() { | ||
return key + "=" + value; | ||
} | ||
|
||
/** | ||
* <p>Generate a hash code for this <code>Pair</code>.</p> | ||
* | ||
* <p>The hash code is calculated using both the name and | ||
* the value of the <code>Pair</code>.</p> | ||
* | ||
* @return hash code for this <code>Pair</code> | ||
*/ | ||
@Override | ||
public int hashCode() { | ||
// name's hashCode is multiplied by an arbitrary prime number (13) | ||
// in order to make sure there is a difference in the hashCode between | ||
// these two parameters: | ||
// name: a value: aa | ||
// name: aa value: a | ||
return key.hashCode() * 13 + (value == null ? 0 : value.hashCode()); | ||
} | ||
|
||
/** | ||
* <p>Test this <code>Pair</code> for equality with another | ||
* <code>Object</code>.</p> | ||
* | ||
* <p>If the <code>Object</code> to be tested is not a | ||
* <code>Pair</code> or is <code>null</code>, then this method | ||
* returns <code>false</code>.</p> | ||
* | ||
* <p>Two <code>Pair</code>s are considered equal if and only if | ||
* both the names and values are equal.</p> | ||
* | ||
* @param o the <code>Object</code> to test for | ||
* equality with this <code>Pair</code> | ||
* @return <code>true</code> if the given <code>Object</code> is | ||
* equal to this <code>Pair</code> else <code>false</code> | ||
*/ | ||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o instanceof Pair) { | ||
Pair pair = (Pair) o; | ||
if (key != null ? !key.equals(pair.key) : pair.key != null) return false; | ||
if (value != null ? !value.equals(pair.value) : pair.value != null) return false; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
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.