Skip to content

Commit d640a7e

Browse files
RELEASE 2021.1 hotfix patch 05.09
1 parent 68840ad commit d640a7e

23 files changed

Lines changed: 776 additions & 393 deletions

src/main/java/su/interference/core/DataChunk.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,18 @@ public GenericObject getGenericObject() {
180180
return new GenericObject(vmap);
181181
}
182182

183+
@Override
184+
public String toString() {
185+
final ValueSet vs = getDcs();
186+
final Field[] cs = t.getFields();
187+
final Map<String, Object> vmap = new HashMap();
188+
String s = "";
189+
for (int i=0; i<cs.length; i++) {
190+
s = s + cs[i].getName() + "=" + vs.getValueSet()[i] + " ";
191+
}
192+
return s;
193+
}
194+
183195
public UndoChunk getUndoChunk() {
184196
if (header==null) {
185197
return null;
Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2020 head systems, ltd
4+
Copyright (c) 2010-2021 head systems, ltd
55
66
Permission is hereby granted, free of charge, to any person obtaining a copy of
77
this software and associated documentation files (the "Software"), to deal in
@@ -24,51 +24,80 @@ this software and associated documentation files (the "Software"), to deal in
2424

2525
package su.interference.core;
2626

27+
import su.interference.persistent.FrameData;
28+
import su.interference.persistent.Session;
29+
2730
import java.util.List;
31+
import java.util.concurrent.LinkedBlockingQueue;
2832

2933
/**
3034
* @author Yuriy Glotanov
3135
* @since 1.0
3236
*/
3337

3438
public class IndexContainer {
35-
private final List<IndexFrame> frameList;
36-
private int fptr;
37-
private int cptr;
39+
private final LinkedBlockingQueue<FrameData> frameQueue;
40+
private final Session s;
41+
private volatile int cptr;
42+
private volatile List<Chunk> current;
43+
private volatile boolean started;
44+
private volatile boolean terminated;
3845

39-
public IndexContainer(List<IndexFrame> frameList) {
40-
this.frameList = frameList;
41-
fptr = 0;
46+
public IndexContainer(LinkedBlockingQueue<FrameData> frameQueue, Session s) {
47+
this.frameQueue = frameQueue;
48+
this.s = s;
4249
cptr = 0;
4350
}
4451

45-
public void reset() {
46-
fptr = 0;
47-
cptr = 0;
48-
}
49-
50-
public Chunk next() {
51-
if (frameList.size() == fptr) {
52+
public Chunk next() throws Exception {
53+
if (terminated) {
5254
return null;
5355
}
56+
5457
cptr++;
55-
if (frameList.get(fptr).data.size() == cptr) {
56-
fptr++;
58+
59+
if (current != null && current.size() == cptr) {
60+
FrameData current_ = frameQueue.take();
5761
cptr = 0;
62+
if (current_.getObjectId() == 0 && current_.getFrameId() == 0) {
63+
terminated = true;
64+
return null;
65+
}
66+
IndexFrame current__ = current_.getIndexFrame();
67+
current__.sort();
68+
current = current__.getFrameChunks(s);
5869
}
59-
if (frameList.size() == fptr) {
60-
return null;
61-
}
62-
return frameList.get(fptr).data.get(cptr);
70+
71+
return current.get(cptr);
6372
}
6473

65-
public Chunk get() {
66-
if (frameList.size() == 0 || frameList.size() == fptr) {
74+
public Chunk get() throws Exception {
75+
if (terminated) {
6776
return null;
6877
}
69-
if (frameList.get(fptr).data.size() == 0) {
78+
79+
if (!started) {
80+
FrameData current_ = frameQueue.take();
81+
started = true;
82+
83+
if (current_.getObjectId() == 0 && current_.getFrameId() == 0) {
84+
terminated = true;
85+
return null;
86+
}
87+
88+
IndexFrame current__ = current_.getIndexFrame();
89+
current__.sort();
90+
current = current__.getFrameChunks(s);
91+
}
92+
93+
if (current.size() == 0) {
7094
return null;
7195
}
72-
return frameList.get(fptr).data.get(cptr);
96+
97+
return current.get(cptr);
98+
}
99+
100+
public LinkedBlockingQueue<FrameData> getFrameQueue() {
101+
return frameQueue;
73102
}
74103
}

src/main/java/su/interference/core/IndexDescript.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class IndexDescript {
4747
private final String[] columns;
4848
private final Field[] fields;
4949
private final boolean unique;
50+
private boolean accepted;
5051

5152
public IndexDescript(Table t, String name, String columns, boolean unique) throws InternalException {
5253
this.t = t;
@@ -78,6 +79,16 @@ public IndexDescript(Table t, String name, String columns, boolean unique) throw
7879
this.unique = unique;
7980
}
8081

82+
public IndexDescript(IndexDescript indexDescript) {
83+
this.t = indexDescript.t;
84+
this.index = indexDescript.index;
85+
this.name = indexDescript.name;
86+
this.className = indexDescript.className;
87+
this.columns = indexDescript.columns;
88+
this.fields = indexDescript.fields;
89+
this.unique = indexDescript.unique;
90+
}
91+
8192
public String getName() {
8293
return name;
8394
}
@@ -101,4 +112,12 @@ public Table getIndex() {
101112
public boolean isUnique() {
102113
return unique;
103114
}
115+
116+
public boolean isAccepted() {
117+
return accepted;
118+
}
119+
120+
public void accept() {
121+
this.accepted = true;
122+
}
104123
}

src/main/java/su/interference/core/Instance.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ this software and associated documentation files (the "Software"), to deal in
4949
public class Instance implements Interference {
5050

5151
public static final String RELEASE = "2021.1";
52-
// public static final int SYSTEM_VERSION = 20210412;
53-
public static final int SYSTEM_VERSION = 20210718;
52+
public static final int SYSTEM_VERSION = 20210905;
5453

5554
public static final String DATA_FILE = "datafile";
5655
public static final String INDX_FILE = "indxfile";
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
The MIT License (MIT)
3+
4+
Copyright (c) 2010-2021 head systems, ltd
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of
7+
this software and associated documentation files (the "Software"), to deal in
8+
the Software without restriction, including without limitation the rights to
9+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10+
the Software, and to permit persons to whom the Software is furnished to do so,
11+
subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
23+
*/
24+
25+
package su.interference.core;
26+
27+
/**
28+
* @author Yuriy Glotanov
29+
* @since 1.0
30+
*/
31+
32+
public interface ManagedRunnable extends Runnable {
33+
void stop();
34+
}

src/main/java/su/interference/core/Types.java

Lines changed: 45 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -64,76 +64,68 @@ public static boolean sqlCheck (String t1, String t2) {
6464
&& (t2.equals(p_float) || t2.equals(t_float) || t2.equals(p_double) || t2.equals(t_double));
6565
}
6666

67-
public static synchronized int getTypeLength(String type, int l) {
68-
if (type.equals(p_byte)) {
69-
return 1;
70-
} else if (type.equals(p_char)) {
71-
return 2;
72-
} else if (type.equals(p_int)) {
73-
return 4;
74-
} else if (type.equals(p_long)) {
75-
return 8;
76-
} else if (type.equals(p_float)) {
77-
return 4;
78-
} else if (type.equals(p_double)) {
79-
return 8;
80-
} else if (type.equals(t_byte)) {
81-
return 2;
82-
} else if (type.equals(t_int)) {
83-
return 5;
84-
} else if (type.equals(c_int)) {
85-
return 5;
86-
} else if (type.equals(t_long)) {
87-
return 9;
88-
} else if (type.equals(c_long)) {
89-
return 9;
90-
} else if (type.equals(t_float)) {
91-
return 5;
92-
} else if (type.equals(t_double)) {
93-
return 9;
94-
} else if (type.equals(t_date)) {
95-
return 9;
67+
public static int getTypeLength(String type) {
68+
switch (type) {
69+
case p_byte:
70+
return 1;
71+
case p_char:
72+
case t_byte:
73+
return 2;
74+
case p_int:
75+
case p_float:
76+
return 4;
77+
case p_long:
78+
case p_double:
79+
return 8;
80+
case t_int:
81+
case c_int:
82+
case t_float:
83+
return 5;
84+
case t_long:
85+
case c_long:
86+
case t_double:
87+
case t_date:
88+
return 9;
89+
default:
90+
return 0;
9691
}
97-
return 0;
9892
}
9993

100-
public static synchronized int getLength (Field f) {
94+
public static int getLength (Field f) {
10195
String type = f.getType().getName();
102-
return getTypeLength(type, 0);
96+
return getTypeLength(type);
10397
}
10498

105-
public static synchronized boolean isVarType (String type) {
106-
return getTypeLength(type, 0) == 0;
99+
public static boolean isVarType (String type) {
100+
return getTypeLength(type) == 0;
107101
}
108102

109-
public static synchronized boolean isVarType (Field f) {
110-
String type = f.getType().getName();
111-
return isVarType(type);
103+
public static boolean isVarType (Field f) {
104+
return isVarType(f.getType().getName());
112105
}
113106

114-
public static synchronized boolean isObjType (Field f) {
107+
public static boolean isObjType (Field f) {
115108
return f.getType().getName().equals("java.lang.Object") || f.getType().getName().equals("su.interference.transport.TransportMessage") ||
116109
f.getType().getName().equals("su.interference.transport.TransportEvent") || f.getType().getName().equals("su.interference.transport.TransportCallback") ||
117110
f.getType().getName().equals("su.interference.transport.TransportCallback") || f.getType().getName().equals("su.interference.transport.EventResult") ||
118111
f.getType().getName().equals("su.interference.sql.FrameApiJoin");
119112
}
120113

121-
public static synchronized boolean isPrimitiveType (String type) {
122-
if (type.equals("byte")) {
123-
return true;
124-
} else if (type.equals("char")) {
125-
return true;
126-
} else if (type.equals("int")) {
127-
return true;
128-
} else if (type.equals("long")) {
129-
return true;
130-
} else if (type.equals("float")) {
131-
return true;
132-
} else return type.equals("double");
114+
public static boolean isPrimitiveType (String type) {
115+
switch (type) {
116+
case p_byte:
117+
case p_char:
118+
case p_int:
119+
case p_long:
120+
case p_float:
121+
case p_double:
122+
return true;
123+
default:
124+
return false;
125+
}
133126
}
134127

135-
public static synchronized boolean isPrimitiveType (Field f) {
136-
String type = f.getType().getName();
137-
return isPrimitiveType(type);
128+
public static boolean isPrimitiveType (Field f) {
129+
return isPrimitiveType(f.getType().getName());
138130
}
139131
}

0 commit comments

Comments
 (0)