Skip to content

Commit 5f7f2ca

Browse files
RELEASE 2021.1
1 parent 316229a commit 5f7f2ca

37 files changed

Lines changed: 1628 additions & 305 deletions

doc/InterferenceManual.pdf

81.5 KB
Binary file not shown.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>su.interference</groupId>
99
<artifactId>interference</artifactId>
10-
<version>2020.3</version>
10+
<version>2021.1</version>
1111
<packaging>jar</packaging>
1212

1313
<name>interference</name>
Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
/**
2-
The MIT License (MIT)
3-
4-
Copyright (c) 2010-2019 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.proxy;
26-
27-
import java.lang.reflect.InvocationTargetException;
28-
29-
/**
30-
* @author Yuriy Glotanov
31-
* @since 1.0
32-
*/
33-
34-
public interface GenericResult {
35-
Object getValueByName(String name) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException;
36-
}
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.api;
26+
27+
import java.lang.reflect.InvocationTargetException;
28+
29+
/**
30+
* @author Yuriy Glotanov
31+
* @since 1.0
32+
*/
33+
34+
public interface GenericResult {
35+
Object getValueByName(String name) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException;
36+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public class Config {
119119
public final int CLEANUP_PROTECTION_THR = 1000;
120120
public final int IX_CLEANUP_PROTECTION_THR = 2000;
121121
public final int HEAP_USE_THR_DATA = 60;
122-
public final int HEAP_USE_THR_INDX = 70;
122+
public final int HEAP_USE_THR_INDX = 60;
123123
public final int HEAP_USE_THR_TEMP = 40;
124124
public final int HEAP_USE_THR_UNDO = 50;
125125

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

Lines changed: 58 additions & 7 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
@@ -70,7 +70,9 @@ public class DataChunk implements Chunk {
7070
private UndoChunk uc;
7171
private FrameData uframe;
7272
private boolean terminate;
73-
private final CustomSerializer sr = new CustomSerializer();
73+
private boolean external;
74+
private static final CustomSerializer sr = new CustomSerializer();
75+
private static final CustomSerializer sr_ = new CustomSerializer(true);
7476

7577
//returns datacolumn set
7678
public ValueSet getDcs() {
@@ -154,7 +156,7 @@ private ValueSet getDcsFromBytes() {
154156
if (Modifier.isPrivate(m)) {
155157
cs[i].setAccessible(true);
156158
}
157-
dcs.getValueSet()[i] = sr.deserialize(data, cs[i]);
159+
dcs.getValueSet()[i] = this.external ? sr_.deserialize(data, cs[i]) : sr.deserialize(data, cs[i]);
158160
if (a != null) {
159161
id = (Comparable) dcs.getValueSet()[i];
160162
}
@@ -170,6 +172,16 @@ private ValueSet getDcsFromBytes() {
170172
}
171173
}
172174

175+
public GenericObject getGenericObject() {
176+
final ValueSet vs = getDcs();
177+
final Field[] cs = t.getFields();
178+
final Map<String, Object> vmap = new HashMap();
179+
for (int i=0; i<cs.length; i++) {
180+
vmap.put(cs[i].getName(), vs.getValueSet()[i]);
181+
}
182+
return new GenericObject(vmap);
183+
}
184+
173185
public UndoChunk getUndoChunk() {
174186
if (header==null) {
175187
return null;
@@ -238,11 +250,11 @@ public byte[] getSerializedId (Session s) throws InvocationTargetException, NoSu
238250
if (t.isNoTran()) {
239251
final Method z = t.getIdmethod();
240252
id = (Comparable) z.invoke(entity, null);
241-
serializedId = sr.serialize(idf.getType().getName(), id);
253+
serializedId = this.external ? sr_.serialize(idf.getType().getName(), id) : sr.serialize(idf.getType().getName(), id);
242254
} else {
243255
final Method z = t.getIdmethod_();
244256
id = (Comparable) z.invoke(entity, new Object[]{s});
245-
serializedId = sr.serialize(idf.getType().getName(), id);
257+
serializedId = this.external ? sr_.serialize(idf.getType().getName(), id) : sr.serialize(idf.getType().getName(), id);
246258
}
247259
}
248260

@@ -278,7 +290,7 @@ public DataChunk (ValueSet vs, Session s, RowId r, Table t) throws ClassNotFound
278290
final ByteString res = new ByteString();
279291
final Field[] f = t.getFields();
280292
for (int i=0; i<f.length; i++) {
281-
byte[] b = sr.serialize(f[i].getType().getName(), vs.getValueSet()[i]);
293+
byte[] b = this.external ? sr_.serialize(f[i].getType().getName(), vs.getValueSet()[i]) : sr.serialize(f[i].getType().getName(), vs.getValueSet()[i]);
282294
if (b==null) { b = new byte[]{}; } //stub for reflection convert null fields to byte[] object in DataRecord
283295
if (Types.isVarType(f[i])) {
284296
res.addBytesFromInt(b.length);
@@ -331,6 +343,15 @@ public DataChunk (Object o, Session s, Table t) {
331343
this(o, s, null, t);
332344
}
333345

346+
//serializer INSERT ONLY!!! (with generate Id value)
347+
public DataChunk (Object o, Session s, Table t, boolean external) {
348+
this.entity = o;
349+
this.t = t;
350+
this.state = NORMAL_STATE;
351+
this.external = external;
352+
this.header = new RowHeader(null, null, getChunk().length, false);
353+
}
354+
334355
//serializer INSERT ONLY!!! (with generate Id value) - rowid for index chunk
335356
public DataChunk (Object o, Session s, RowId r, Table t) {
336357
this.entity = o;
@@ -357,6 +378,15 @@ public DataChunk (byte[] b, Table t, RowHeader h, DataChunk source) {
357378
this.t = t;
358379
}
359380

381+
//constructor ONLY for external client deserializer
382+
public DataChunk (byte[] b, Table t, boolean external) {
383+
this.chunk = b;
384+
this.t = t;
385+
this.state = INIT_STATE;
386+
this.external = external;
387+
this.header = new RowHeader(null, null, getChunk().length, false);
388+
}
389+
360390
public byte[] getChunk () {
361391
if (state == INIT_STATE) {
362392
return chunk;
@@ -543,6 +573,27 @@ public Object getStandaloneEntity() {
543573
return null;
544574
}
545575

576+
public Object getClientStandaloneEntity() {
577+
try {
578+
final ValueSet dcs = getDcs();
579+
final Object o = t.getInstance(); //returns empty instance
580+
final Field[] cs = t.getFields();
581+
for (int i=0; i<cs.length; i++) {
582+
final int m = cs[i].getModifiers();
583+
if (Modifier.isPrivate(m)) {
584+
cs[i].setAccessible(true);
585+
}
586+
if (dcs.getValueSet()[i]!=null) {
587+
cs[i].set(o, dcs.getValueSet()[i]);
588+
}
589+
}
590+
return o;
591+
} catch (Exception e) {
592+
e.printStackTrace();
593+
}
594+
return null;
595+
}
596+
546597
//for bootstrap system / not use table objects
547598
public Object getEntity (Class c, Object[] params) {
548599
SystemEntity ca = (SystemEntity)c.getAnnotation(SystemEntity.class);
@@ -665,7 +716,7 @@ public DataChunk restore(UndoChunk uc) throws Exception {
665716
private byte[] getBytes(Field f, Object o) throws IllegalAccessException, UnsupportedEncodingException, ClassNotFoundException, InternalException, InstantiationException {
666717
final String t = f.getType().getName();
667718
final Object fo = f.get(o);
668-
return sr.serialize(t, fo);
719+
return this.external ? sr_.serialize(t, fo) : sr.serialize(t, fo);
669720
}
670721

671722
private int getLen(Field f, Object o) throws IllegalAccessException, UnsupportedEncodingException, ClassNotFoundException, InternalException, InstantiationException {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
import su.interference.api.GenericResult;
28+
29+
import java.io.Serializable;
30+
import java.util.Map;
31+
32+
/**
33+
* @author Yuriy Glotanov
34+
* @since 1.0
35+
*/
36+
37+
public class GenericObject implements Serializable, GenericResult {
38+
private final Map<String, Object> vmap;
39+
40+
protected GenericObject(Map<String, Object> vmap) {
41+
this.vmap = vmap;
42+
}
43+
44+
public Object getValueByName(String name) {
45+
return vmap.get(name);
46+
}
47+
}

0 commit comments

Comments
 (0)