Skip to content

Commit f10070e

Browse files
author
chengyitian
committed
Merge remote-tracking branch 'origin/release130' into release130
2 parents 7530d46 + 4832ce5 commit f10070e

File tree

5 files changed

+206
-69
lines changed

5 files changed

+206
-69
lines changed

src/com/xxdb/data/BasicMonth.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.xxdb.io.ExtendedDataInput;
44

55
import java.io.IOException;
6+
import java.time.DateTimeException;
67
import java.time.Month;
78
import java.time.YearMonth;
89
import java.time.format.DateTimeFormatter;
@@ -19,6 +20,8 @@ public class BasicMonth extends BasicInt{
1920

2021
public BasicMonth(int year, Month month){
2122
super(year * 12 + month.getValue()-1);
23+
if (getInt() < 0)
24+
throw new DateTimeException(String.format("year %d is invalid, it must be non-negative integer", year));
2225
}
2326
public BasicMonth(Calendar calendar){
2427
super((calendar.get(Calendar.YEAR)) * 12 + calendar.get(Calendar.MONTH));
@@ -33,6 +36,8 @@ public BasicMonth(ExtendedDataInput in) throws IOException {
3336

3437
protected BasicMonth(int value){
3538
super(value);
39+
if (getInt() < 0)
40+
throw new DateTimeException(String.format("number %d is invalid, it must be non-negative integer", getInt()));
3641
}
3742

3843

test/com/xxdb/MultithreadedTableWriterTest.java

Lines changed: 175 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,13 +1910,11 @@ public void test_insert_arrayVector_different_length()throws Exception {
19101910
}
19111911

19121912
@Test(timeout = 120000)
1913-
public void test_insert_arrayVector_int()throws Exception {
1914-
1913+
public void test_insert_arrayVector_int_Integer()throws Exception {
19151914
StringBuilder sb = new StringBuilder();
19161915
sb.append("t = table(1000:0, `int`arrayv," +
19171916
"[INT,INT[]]);" +
19181917
"share t as t1;");
1919-
19201918
conn.run(sb.toString());
19211919
mutithreadTableWriter_ = new MultithreadedTableWriter(HOST, PORT, "admin", "123456",
19221920
"", "t1", false, false,null,1, 1,
@@ -1935,9 +1933,33 @@ public void test_insert_arrayVector_int()throws Exception {
19351933
}
19361934
conn.run("undef(`t1,SHARED)");
19371935
}
1936+
@Test(timeout = 120000)
1937+
public void test_insert_arrayVector_int_int()throws Exception {
1938+
StringBuilder sb = new StringBuilder();
1939+
sb.append("t = table(1000:0, `int`arrayv," +
1940+
"[INT,INT[]]);" +
1941+
"share t as t1;");
1942+
conn.run(sb.toString());
1943+
mutithreadTableWriter_ = new MultithreadedTableWriter(HOST, PORT, "admin", "123456",
1944+
"", "t1", false, false,null,1, 1,
1945+
1, "int");
1946+
for (int i=0;i<10;i++) {
1947+
ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( 1,new int[]{1, i});
1948+
assertEquals("code= info=",pErrorInfo.toString());
1949+
}
1950+
mutithreadTableWriter_.waitForThreadCompletion();
1951+
// conn.run(String.format("insert into t1 values('%s',%s)",1,"1232"));
1952+
BasicTable bt= (BasicTable) conn.run("select * from t1;");
1953+
assertEquals(10,bt.rows());
1954+
for (int i=0;i<10;i++) {
1955+
assertEquals(1, ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(0)).getNumber());
1956+
assertEquals(i, ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(1)).getNumber());
1957+
}
1958+
conn.run("undef(`t1,SHARED)");
1959+
}
19381960

19391961
@Test(timeout = 60000)
1940-
public void test_insert_arrayVector_char()throws Exception {
1962+
public void test_insert_arrayVector_char_Byte()throws Exception {
19411963

19421964
StringBuilder sb = new StringBuilder();
19431965
sb.append("t = table(1000:0, `int`arrayv," +
@@ -1961,9 +1983,33 @@ public void test_insert_arrayVector_char()throws Exception {
19611983
}
19621984
conn.run("undef(`t1,SHARED)");
19631985
}
1986+
@Test(timeout = 60000)
1987+
public void test_insert_arrayVector_char_byte()throws Exception {
1988+
1989+
StringBuilder sb = new StringBuilder();
1990+
sb.append("t = table(1000:0, `int`arrayv," +
1991+
"[INT,CHAR[]]);" +
1992+
"share t as t1;");
19641993

1994+
conn.run(sb.toString());
1995+
mutithreadTableWriter_ = new MultithreadedTableWriter(HOST, PORT, "admin", "123456",
1996+
"", "t1", false, false,null,1, 1,
1997+
1, "int");
1998+
for (int i=0;i<10;i++) {
1999+
ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( 1,new byte[]{'a','3'});
2000+
assertEquals("code= info=",pErrorInfo.toString());
2001+
}
2002+
mutithreadTableWriter_.waitForThreadCompletion();
2003+
// conn.run(String.format("insert into t1 values('%s',%s)",1,"1232"));
2004+
BasicTable bt= (BasicTable) conn.run("select * from t1;");
2005+
assertEquals(10,bt.rows());
2006+
for (int i=0;i<10;i++) {
2007+
assertEquals("['a','3']", ((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).getString());
2008+
}
2009+
conn.run("undef(`t1,SHARED)");
2010+
}
19652011
@Test(timeout = 120000)
1966-
public void test_insert_arrayVector_bool()throws Exception {
2012+
public void test_insert_arrayVector_bool_Boolean()throws Exception {
19672013

19682014
StringBuilder sb = new StringBuilder();
19692015
sb.append("t = table(1000:0, `int`arrayv," +
@@ -1987,9 +2033,34 @@ public void test_insert_arrayVector_bool()throws Exception {
19872033
assertEquals("false", ((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(1).getString());
19882034
}
19892035
}
2036+
@Test(timeout = 120000)
2037+
public void test_insert_arrayVector_bool_bool()throws Exception {
2038+
2039+
StringBuilder sb = new StringBuilder();
2040+
sb.append("t = table(1000:0, `int`arrayv," +
2041+
"[INT,BOOL[]]);" +
2042+
"share t as t1;");
2043+
2044+
conn.run(sb.toString());
2045+
mutithreadTableWriter_ = new MultithreadedTableWriter(HOST, PORT, "admin", "123456",
2046+
"", "t1", false, false,null,1, 1,
2047+
1, "int");
2048+
for (int i=0;i<10;i++) {
2049+
ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( 1,new boolean[]{true,false});
2050+
assertEquals("code= info=",pErrorInfo.toString());
2051+
}
2052+
mutithreadTableWriter_.waitForThreadCompletion();
2053+
// conn.run(String.format("insert into t1 values('%s',%s)",1,"1232"));
2054+
BasicTable bt= (BasicTable) conn.run("select * from t1;");
2055+
assertEquals(10,bt.rows());
2056+
for (int i=0;i<10;i++) {
2057+
assertEquals("true",((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(0).getString());
2058+
assertEquals("false", ((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(1).getString());
2059+
}
2060+
}
19902061

19912062
@Test(timeout = 120000)
1992-
public void test_insert_arrayVector_long()throws Exception {
2063+
public void test_insert_arrayVector_long_Long()throws Exception {
19932064

19942065
StringBuilder sb = new StringBuilder();
19952066
sb.append("t = table(1000:0, `int`arrayv," +
@@ -2013,9 +2084,34 @@ public void test_insert_arrayVector_long()throws Exception {
20132084
assertEquals(Long.valueOf(i), ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(1)).getNumber());
20142085
}
20152086
}
2087+
@Test(timeout = 120000)
2088+
public void test_insert_arrayVector_long_long()throws Exception {
2089+
2090+
StringBuilder sb = new StringBuilder();
2091+
sb.append("t = table(1000:0, `int`arrayv," +
2092+
"[INT,LONG[]]);" +
2093+
"share t as t1;");
2094+
int time=1024;
2095+
conn.run(sb.toString());
2096+
mutithreadTableWriter_ = new MultithreadedTableWriter(HOST, PORT, "admin", "123456",
2097+
"", "t1", false, false,null,1, 1,
2098+
1, "arrayv");
2099+
for (int i=0;i<time;i++) {
2100+
ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( 1, new long[]{1l, (long)i});
2101+
assertEquals("code= info=",pErrorInfo.toString());
2102+
}
2103+
mutithreadTableWriter_.waitForThreadCompletion();
2104+
// conn.run(String.format("insert into t1 values('%s',%s)",1,"1232"));
2105+
BasicTable bt= (BasicTable) conn.run("select * from t1;");
2106+
assertEquals(time,bt.rows());
2107+
for (int i=0;i<time;i++) {
2108+
assertEquals(1l, ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(0)).getNumber());
2109+
assertEquals(Long.valueOf(i), ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(1)).getNumber());
2110+
}
2111+
}
20162112

20172113
@Test(timeout = 120000)
2018-
public void test_insert_arrayVector_short()throws Exception {
2114+
public void test_insert_arrayVector_short_Short()throws Exception {
20192115

20202116
StringBuilder sb = new StringBuilder();
20212117
sb.append("t = table(1000:0, `int`arrayv," +
@@ -2038,9 +2134,32 @@ public void test_insert_arrayVector_short()throws Exception {
20382134
assertEquals(Short.valueOf(""+i+""), ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(1)).getNumber());
20392135
}
20402136
}
2137+
@Test(timeout = 120000)
2138+
public void test_insert_arrayVector_short_short()throws Exception {
20412139

2140+
StringBuilder sb = new StringBuilder();
2141+
sb.append("t = table(1000:0, `int`arrayv," +
2142+
"[INT,SHORT[]]);" +
2143+
"share t as t1;");
2144+
int time=10240;
2145+
conn.run(sb.toString());
2146+
mutithreadTableWriter_ = new MultithreadedTableWriter(HOST, PORT, "admin", "123456",
2147+
"", "t1", false, false,null,1, 1,
2148+
1, "arrayv");
2149+
for (short i=0;i<time;i++) {
2150+
ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( 1, new short[]{1,i});
2151+
assertEquals("code= info=",pErrorInfo.toString());
2152+
}
2153+
mutithreadTableWriter_.waitForThreadCompletion();
2154+
BasicTable bt= (BasicTable) conn.run("select * from t1;");
2155+
assertEquals(time,bt.rows());
2156+
for (int i=0;i<time;i++) {
2157+
assertEquals(Short.valueOf("1"), ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(0)).getNumber());
2158+
assertEquals(Short.valueOf(""+i+""), ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(1)).getNumber());
2159+
}
2160+
}
20422161
@Test(timeout = 120000)
2043-
public void test_insert_arrayVector_float()throws Exception {
2162+
public void test_insert_arrayVector_float_Float()throws Exception {
20442163

20452164
StringBuilder sb = new StringBuilder();
20462165
sb.append("t = table(1000:0, `int`arrayv," +
@@ -2063,9 +2182,32 @@ public void test_insert_arrayVector_float()throws Exception {
20632182
assertEquals(Float.valueOf(i), ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(1)).getNumber());
20642183
}
20652184
}
2185+
@Test(timeout = 120000)
2186+
public void test_insert_arrayVector_float_float()throws Exception {
2187+
StringBuilder sb = new StringBuilder();
2188+
sb.append("t = table(1000:0, `int`arrayv," +
2189+
"[INT,FLOAT[]]);" +
2190+
"share t as t1;");
2191+
int time=10240;
2192+
conn.run(sb.toString());
2193+
mutithreadTableWriter_ = new MultithreadedTableWriter(HOST, PORT, "admin", "123456",
2194+
"", "t1", false, false,null,1, 1,
2195+
1, "arrayv");
2196+
for (short i=0;i<time;i++) {
2197+
ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( 1, new float[]{0.0f,(float)i});
2198+
assertEquals("code= info=",pErrorInfo.toString());
2199+
}
2200+
mutithreadTableWriter_.waitForThreadCompletion();
2201+
BasicTable bt= (BasicTable) conn.run("select * from t1;");
2202+
assertEquals(time,bt.rows());
2203+
for (int i=0;i<time;i++) {
2204+
assertEquals(0.0f, ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(0)).getNumber());
2205+
assertEquals(Float.valueOf(i), ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(1)).getNumber());
2206+
}
2207+
}
20662208

20672209
@Test(timeout = 120000)
2068-
public void test_insert_arrayVector_double()throws Exception {
2210+
public void test_insert_arrayVector_double_Double()throws Exception {
20692211

20702212
StringBuilder sb = new StringBuilder();
20712213
sb.append("t = table(1000:0, `int`arrayv," +
@@ -2088,6 +2230,30 @@ public void test_insert_arrayVector_double()throws Exception {
20882230
assertEquals(Double.valueOf(i-10), ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(1)).getNumber());
20892231
}
20902232
}
2233+
@Test(timeout = 120000)
2234+
public void test_insert_arrayVector_double_double()throws Exception {
2235+
2236+
StringBuilder sb = new StringBuilder();
2237+
sb.append("t = table(1000:0, `int`arrayv," +
2238+
"[INT,DOUBLE[]]);" +
2239+
"share t as t1;");
2240+
int time=10240;
2241+
conn.run(sb.toString());
2242+
mutithreadTableWriter_ = new MultithreadedTableWriter(HOST, PORT, "admin", "123456",
2243+
"", "t1", false, false,null,1, 1,
2244+
1, "arrayv");
2245+
for (short i=0;i<time;i++) {
2246+
ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( 1, new double[]{(double)0,(double)(i-10)});
2247+
assertEquals("code= info=",pErrorInfo.toString());
2248+
}
2249+
mutithreadTableWriter_.waitForThreadCompletion();
2250+
BasicTable bt= (BasicTable) conn.run("select * from t1;");
2251+
assertEquals(time,bt.rows());
2252+
for (int i=0;i<time;i++) {
2253+
assertEquals(Double.valueOf(0), ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(0)).getNumber());
2254+
assertEquals(Double.valueOf(i-10), ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(1)).getNumber());
2255+
}
2256+
}
20912257

20922258
@Test(timeout = 120000)
20932259
public void test_insert_arrayVector_date_month()throws Exception {

test/com/xxdb/MutithreadTableWriterTest.java

Lines changed: 0 additions & 60 deletions
This file was deleted.

test/com/xxdb/data/TimeTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,9 @@ public void test_Special_time_datehour (){
445445
public void test_Special_time_timestamp(){
446446
LocalDateTime dt = LocalDateTime.of(2022,1,31,2,2,2,4000000);
447447
BasicTimestamp date = new BasicTimestamp(dt);
448+
LocalDateTime dt1 = LocalDateTime.of(2023,9,18,14,51,24,000);
449+
BasicTimestamp date1 = new BasicTimestamp(dt1);
450+
System.out.println(date1.getLong());
448451
String [] lt=dt.toString().split("\\-");
449452
assertEquals(lt[0]+"."+lt[1]+"."+lt[2],date.getString());
450453
dt = LocalDateTime.of(2022,2,28,2,2,2,4000000);
@@ -682,6 +685,16 @@ public void test_BasicMinute() throws Exception {
682685
BasicMinute nt3 = new BasicMinute(100);
683686
System.out.println(nt3.getString());
684687
assertEquals("01:40m",nt3.getString());
688+
}
689+
@Test
690+
public void test_BasicMonth_negative() throws Exception {
691+
String re = null;
692+
try{
693+
BasicMonth nt1 = new BasicMonth(-5);
694+
}catch(Exception e){
695+
re = e.getMessage();
696+
}
697+
assertEquals("number -5 is invalid, it must be non-negative integer",re);
685698

686699
}
687700
@Test

test/com/xxdb/streaming/reverse/PollingClientReverseTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,5 +659,18 @@ protected boolean doReconnect(Site site) {
659659
MyPollingClient mpl = new MyPollingClient(HOST,10086);
660660
assertFalse(mpl.doReconnect(null));
661661
}
662+
@Test
663+
public void test_PollingClient_no_parameter() throws IOException {
664+
client = new PollingClient();
665+
TopicPoller poller1 = client.subscribe(HOST,PORT,"Trades1","subTread1",true);
666+
ArrayList<IMessage> msg1;
667+
conn.run("n=1;t=table(1..n as tag,now()+1..n as ts,rand(100.0,n) as data);" +
668+
"Trades1.append!(t)");
669+
msg1 = poller1.poll(100);
670+
assertEquals(1, msg1.size());
671+
BasicTable bt = (BasicTable) conn.run("getStreamingStat().pubTables;");
672+
System.out.println(bt.getString());
673+
client.unsubscribe(HOST,PORT,"Trades1","subTread1");
674+
}
662675

663676
}

0 commit comments

Comments
 (0)