Skip to content

Commit 97d6a97

Browse files
Merge pull request #67 from yuriy-glotanov/2021.1
RELEASE 2025.1
2 parents 0d75652 + df14d74 commit 97d6a97

30 files changed

+1499
-307
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
# interference open cluster
22

33
##### pure-java opensource distributed database platform
4-
(c) 2010 - 2021 head systems, ltd
4+
(c) 2010 - 2025 head systems, ltd
55

6-
current revision: release 2021.1
6+
current revision: release 2025.1
77
for detailed information see doc/InterferenceManual.pdf
88

9-
contacts: info@interference.su
9+
contacts: ioc@ioc.digital
1010
##### https://github.com/interference-project/interference
1111
##### http://ioc.digital
1212

13+
##### Donate:
14+
15+
##### http://ioc.digital/donate.html
16+
17+
Thanks for all who cares.
18+
1319

1420
## Concepts & features
1521

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

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

1313
<name>interference</name>
@@ -68,7 +68,7 @@
6868
<dependency>
6969
<groupId>ch.qos.logback</groupId>
7070
<artifactId>logback-classic</artifactId>
71-
<version>1.2.3</version>
71+
<version>1.2.13</version>
7272
</dependency>
7373
<dependency>
7474
<groupId>org.slf4j</groupId>

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2021 head systems, ltd
4+
Copyright (c) 2010-2025 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,6 +24,8 @@ this software and associated documentation files (the "Software"), to deal in
2424

2525
package su.interference.core;
2626

27+
import su.interference.persistent.UndoChunk;
28+
2729
import java.util.*;
2830

2931
/**
@@ -158,4 +160,15 @@ protected int getUsed() {
158160
return used;
159161
}
160162

163+
protected synchronized void getUCs(Map<Integer, UndoChunk> ucs, int file, long pointer) {
164+
for (Chunk udc : this.getChunks()) {
165+
UndoChunk uc = (UndoChunk) udc.getEntity();
166+
final long frameId = file + pointer;
167+
final long frameId_ = uc.getFile() + uc.getFrame();
168+
if (frameId == frameId_) {
169+
ucs.put(uc.getPtr(), uc);
170+
}
171+
}
172+
}
173+
161174
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2021 head systems, ltd
4+
Copyright (c) 2010-2025 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
@@ -92,6 +92,7 @@ public class Config {
9292
private static final int RETRIEVE_THREADS_AMOUNT_DEFAULT=8;
9393
private static final String CODEPAGE_DEFAULT="UTF8";
9494
private static final String DATEFORMAT_DEFAULT="dd.MM.yyyy";
95+
private static final String JSON_DATEFORMAT_DEFAULT="dd.MM.yyyy mm:HH:ss";
9596
// transport
9697
private static final int REMOTE_SYNC_TIMEOUT_DEFAULT = 60000;
9798
private static final int READ_BUFFER_SIZE_DEFAULT = 33554432;
@@ -126,6 +127,7 @@ public class Config {
126127
public final int RETRIEVE_THREADS_AMOUNT;
127128
public final String CODEPAGE;
128129
public final String DATEFORMAT;
130+
public final String JSON_DATEFORMAT = JSON_DATEFORMAT_DEFAULT;
129131
// transport
130132
public final int REMOTE_SYNC_TIMEOUT;
131133
public final int READ_BUFFER_SIZE;
@@ -143,6 +145,7 @@ public class Config {
143145
// internal
144146
public final int TEST_DISTRIBUTE_MODE = 1;
145147
public final int CHECK_AVAIL_FRAME_TIMEOUT = 3000;
148+
public final int CHECK_AVAIL_FRAME_ATTEMPTS = 1000000;
146149
// locks and processing
147150
public final boolean IGNORE_COMMAND_CHANNEL_FAILURES = true;
148151

@@ -158,12 +161,9 @@ public class Config {
158161

159162
public static final int[] bss = new int[]{4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288};
160163
private final static Logger logger = LoggerFactory.getLogger(Config.class);
161-
private static Config config;
164+
private final static Config config = new Config();
162165

163-
public static synchronized Config getConfig() {
164-
if (config==null) {
165-
config = new Config();
166-
}
166+
public static Config getConfig() {
167167
return config;
168168
}
169169

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

Lines changed: 8 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-2021 head systems, ltd
4+
Copyright (c) 2010-2025 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
@@ -819,27 +819,28 @@ public void setTerminate(boolean terminate) {
819819
this.terminate = terminate;
820820
}
821821

822-
public void setIc(DataChunk ic) {
822+
public synchronized void setIc(DataChunk ic) {
823823
final Table t_ = ic.t == null ? Instance.getInstance().getTableByName(ic.getEntity().getClass().getName()) : ic.t;
824824
this.ics.put(t_.getObjectId(), ic);
825825
}
826826

827-
public void clearIcs() {
827+
public synchronized void clearIcs() {
828828
this.ics.clear();
829829
}
830830

831-
protected void cleanUpIcs() {
831+
protected synchronized void cleanUpIcs() {
832832
for (Map.Entry<Integer, DataChunk> entry : this.ics.entrySet()) {
833833
final IndexChunk ic = (IndexChunk) entry.getValue().getEntity();
834834
ic.setDataChunk(null);
835835
}
836836
}
837837

838-
public DataChunk getIc(IndexDescript ids, Session s) throws Exception {
838+
public synchronized DataChunk getIc(IndexDescript ids, Session s) throws Exception {
839839
final DataChunk ic = this.ics.get(ids.getIndex().getObjectId());
840840
if (ic == null) {
841841
final ValueSet key = this.getValueByColumnName(ids.getColumns(), s);
842-
final DataChunk ic_ = ids.getIndex().getObjectByKey(key, s);
842+
final DataChunk ic_ = ids.isUnique() ? ids.getIndex().getObjectByKey(key, s) :
843+
ids.getIndex().getObjectByKey(key, this.getHeader().getFPtr(), this.getHeader().getPtr(), s);
843844
if (ic_ != null) {
844845
this.ics.put(ids.getIndex().getObjectId(), ic_);
845846
return ic_;
@@ -850,7 +851,7 @@ public DataChunk getIc(IndexDescript ids, Session s) throws Exception {
850851
return ic;
851852
}
852853

853-
public DataChunk getIcForUpdate(IndexDescript ids, Session s, LLT llt) throws Exception {
854+
public synchronized DataChunk getIcForUpdate(IndexDescript ids, Session s, LLT llt) throws Exception {
854855
final DataChunk ic = getIc(ids, s);
855856
llt.add(ic.getFrameData().getFrame());
856857
this.ics.remove(ids.getIndex().getObjectId());

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2021 head systems, ltd
4+
Copyright (c) 2010-2025 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
@@ -54,14 +54,7 @@ public DataFrame(int file, long pointer, int size, FrameData bd, Table t, Class
5454
Map<Integer, UndoChunk> ucs = new HashMap<>();
5555
for (FrameData uframe : uframes) {
5656
final DataFrame uf = uframe.getDataFrame();
57-
for (Chunk udc : uf.getChunks()) {
58-
UndoChunk uc = (UndoChunk) udc.getEntity();
59-
final long frameId = file + pointer;
60-
final long frameId_ = uc.getFile() + uc.getFrame();
61-
if (frameId == frameId_) {
62-
ucs.put(uc.getPtr(), uc);
63-
}
64-
}
57+
uf.data.getUCs(ucs, file, pointer);
6558
}
6659

6760
int ptr = FRAME_HEADER_SIZE;

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2021 head systems, ltd
4+
Copyright (c) 2010-2025 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
@@ -294,13 +294,14 @@ public synchronized byte[] getFrame() throws InvalidFrame {
294294
final long sync = LLT.getSyncId();
295295

296296
if (Config.getConfig().SYNC_LOCK_ENABLE||sync==0) {
297+
Map<byte[], byte[]> cmap = new HashMap<>();
297298
for (Chunk c : data.getChunks()) {
298299
final byte[] chunk_ = c.getChunk();
299300
c.getHeader().setLen(chunk_.length);
300-
res2.append(c.getHeader().getHeader());
301-
res2.append(chunk_);
301+
cmap.put(c.getHeader().getHeader(), chunk_);
302302
used = used + c.getBytesAmount();
303303
}
304+
res2.append(cmap);
304305
} else {
305306
if (sync==0) {
306307
throw new InvalidFrame();
@@ -562,7 +563,7 @@ public ArrayList<Chunk> getFrameChunks (Session s) {
562563
return res;
563564
}
564565

565-
public synchronized void rollbackTransaction(Transaction tran, ArrayList<FrameData> ubs, Session s) throws Exception {
566+
public synchronized void rollbackTransaction(Transaction tran, List<FrameData> ubs, Session s) throws Exception {
566567
data.check();
567568
final LLT llt = LLT.getLLT();
568569
llt.add(this);

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

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
The MIT License (MIT)
33
4-
Copyright (c) 2010-2021 head systems, ltd
4+
Copyright (c) 2010-2025 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
@@ -61,21 +61,14 @@ public IndexFrame() {
6161
this.terminate = true;
6262
}
6363

64-
public IndexFrame(int file, long pointer, int size, FrameData bd, Table t, Class c, List<FrameData> uframes) throws Exception {
64+
public IndexFrame(int file, long pointer, int size, FrameData bd, Table t, Class c, List<FrameData> uframes, boolean dcinit) throws Exception {
6565
super(null, file, pointer, size, bd, t, c);
6666
this.terminate = false;
6767

6868
Map<Integer, UndoChunk> ucs = new HashMap<>();
6969
for (FrameData uframe : uframes) {
7070
final DataFrame uf = uframe.getDataFrame();
71-
for (Chunk udc : uf.getChunks()) {
72-
UndoChunk uc = (UndoChunk) udc.getEntity();
73-
final long frameId = file + pointer;
74-
final long frameId_ = uc.getFile() + uc.getFrame();
75-
if (frameId == frameId_) {
76-
ucs.put(uc.getPtr(), uc);
77-
}
78-
}
71+
uf.data.getUCs(ucs, file, pointer);
7972
}
8073

8174
int ptr = FRAME_HEADER_SIZE;
@@ -86,7 +79,7 @@ public IndexFrame(int file, long pointer, int size, FrameData bd, Table t, Class
8679
if ((h.getPtr()>0)&&(h.getLen()>0)) {
8780
final DataChunk dc = new DataChunk(bs.substring(ptr, ptr+INDEX_HEADER_SIZE+h.getLen()), this.getFile(), this.getPointer(), INDEX_HEADER_SIZE, this.getDataObject(), this.getEntityClass());
8881
if (this.getType()==INDEX_FRAME_LEAF) {
89-
if (INITIALIZE_DURING_CONSTRUCT == 1) {
82+
if (dcinit) {
9083
final IndexChunk ib = (IndexChunk) dc.getEntity();
9184
}
9285
}
@@ -139,7 +132,7 @@ public IndexFrame(byte[] b, int file, long pointer, Map<Long, Long> imap, Map<Lo
139132
}
140133

141134
@Override
142-
public synchronized void rollbackTransaction(Transaction tran, ArrayList<FrameData> ubs, Session s) throws Exception {
135+
public synchronized void rollbackTransaction(Transaction tran, List<FrameData> ubs, Session s) throws Exception {
143136
data.check();
144137
final LLT llt = LLT.getLLT();
145138
llt.add(this);
@@ -394,6 +387,46 @@ public synchronized List<DataChunk> getObjectsByKey(ValueSet key, Session s) thr
394387
return r;
395388
}
396389

390+
//return unique element by ptr - for non-unique indexes
391+
public synchronized List<DataChunk> getObjectsByKey(ValueSet key, long frameptr, int ptr, Session s) throws InternalException {
392+
final List<DataChunk> r = new ArrayList<>();
393+
final long tr = s.getTransaction().getTransId();
394+
final long mtran = s.getTransaction().getMTran();
395+
for (Chunk ie : this.data.getChunks()) {
396+
if (((DataChunk)ie).getDcs().equals(key)) {
397+
if (((DataChunk)ie).getHeader().getState() == Header.RECORD_NORMAL_STATE) {
398+
if (((DataChunk) ie).getUndoChunk() != null && ((DataChunk) ie).getHeader().getTran().getCid() == 0) { //updated chunk in live transaction
399+
if (((DataChunk) ie).getHeader().getFramePtr() == frameptr && ((DataChunk) ie).getHeader().getFramePtrRowId().getRowPointer() == ptr) {
400+
r.add((DataChunk) ie);
401+
}
402+
} else {
403+
if (((DataChunk) ie).getHeader().getTran() == null || s.isStream()) {
404+
if (((DataChunk) ie).getHeader().getFramePtr() == frameptr && ((DataChunk) ie).getHeader().getFramePtrRowId().getRowPointer() == ptr) {
405+
r.add((DataChunk) ie);
406+
}
407+
} else {
408+
if ((tr == ((DataChunk) ie).getHeader().getTran().getTransId()) || (((DataChunk) ie).getHeader().getTran().getCid() > 0 && ((DataChunk) ie).getHeader().getTran().getCid() <= mtran)) {
409+
if (((DataChunk) ie).getHeader().getFramePtr() == frameptr && ((DataChunk) ie).getHeader().getFramePtrRowId().getRowPointer() == ptr) {
410+
r.add((DataChunk) ie);
411+
}
412+
}
413+
}
414+
}
415+
}
416+
if (((DataChunk)ie).getHeader().getState() == Header.RECORD_DELETED_STATE) {
417+
if (((DataChunk)ie).getHeader().getTran()!=null) {
418+
if ((tr != ((DataChunk)ie).getHeader().getTran().getTransId()) && (((DataChunk)ie).getHeader().getTran().getCid() == 0 || ((DataChunk)ie).getHeader().getTran().getCid() > mtran)) {
419+
if (((DataChunk) ie).getHeader().getFramePtr() == frameptr && ((DataChunk) ie).getHeader().getFramePtrRowId().getRowPointer() == ptr) {
420+
r.add((DataChunk) ie);
421+
}
422+
}
423+
}
424+
}
425+
}
426+
}
427+
return r;
428+
}
429+
397430
public synchronized int removeObjects(ValueSet key, Object o) throws InternalException {
398431
int len = 0;
399432
ArrayList<Integer> d = new ArrayList<Integer>();

0 commit comments

Comments
 (0)