Skip to content

Commit 03caa18

Browse files
Merge pull request #69 from yuriy-glotanov/2025.1
RELEASE 2025.1
2 parents 5c8bedb + e80ac29 commit 03caa18

3 files changed

Lines changed: 37 additions & 19 deletions

File tree

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

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -291,25 +291,36 @@ public synchronized ValueSet sort() throws InternalException {
291291

292292
//accepted only to node element lists
293293
//for unique indexes
294-
public synchronized DataChunk getChildElementPtr(ValueSet value) throws InternalException {
295-
//todo if (!this.sorted) {
296-
this.sort();
297-
//}
298-
for (Chunk ie : this.data.getChunks()) {
299-
if (((DataChunk)ie).getDcs().compareTo(value)>=0) {
300-
return ((DataChunk)ie); //known as ptr for node element
294+
public synchronized DataChunk getChildElementPtr(ValueSet key) {
295+
this.sort();
296+
List<Chunk> chunks = (List) this.data.getChunks();
297+
298+
int low = 0;
299+
int high = chunks.size() - 1;
300+
301+
DataChunk result = null;
302+
while (low <= high) {
303+
int mid = (low + high) >>> 1;
304+
Comparable midVal = chunks.get(mid).getDcs();
305+
int cmp = midVal.compareTo(key);
306+
307+
if (cmp < 0) {
308+
low = mid + 1;
309+
} else if (cmp > 0) {
310+
result = (DataChunk) chunks.get(mid);
311+
high = mid - 1;
312+
} else {
313+
return (DataChunk) chunks.get(mid);
301314
}
302315
}
303-
return null;
316+
return result;
304317
}
305318

306319
//accepted only to node element lists
307320
//for non-unique indexes
308321
public synchronized ArrayList<Long> getChildElementsPtr(ValueSet value) throws InternalException {
309-
//todo if (!this.sorted) {
310-
this.sort();
311-
//}
312-
ArrayList<Long> r = new ArrayList<Long>();
322+
this.sort();
323+
ArrayList<Long> r = new ArrayList<>();
313324
for (Chunk ie : this.data.getChunks()) {
314325
if (((DataChunk)ie).getDcs().compareTo(value) == 0) {
315326
r.add (((DataChunk)ie).getHeader().getFramePtr()); //known as ptr for node element

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,16 @@ public String getCodePage() throws ClassNotFoundException, InternalException, In
292292
return Config.getConfig().CODEPAGE;
293293
}
294294

295-
public String getDateFormat() throws ClassNotFoundException, InternalException, InstantiationException, IllegalAccessException {
296-
if (systemState==SYSTEM_STATE_UP) {
297-
return Storage.getStorage().getDateFormat();
295+
public String getDateFormat() {
296+
try {
297+
if (systemState == SYSTEM_STATE_UP) {
298+
return Storage.getStorage().getDateFormat();
299+
}
300+
} catch (Exception e) {
301+
logger.error("Exception occured during Instance.getDateFormat", e);
302+
} finally {
303+
return Config.getConfig().DATEFORMAT;
298304
}
299-
return Config.getConfig().DATEFORMAT;
300305
}
301306

302307
public String getLocalhost() {

src/main/java/su/interference/serialize/CustomSerializer.java

Lines changed: 5 additions & 3 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
@@ -53,6 +53,9 @@ public class CustomSerializer implements SerializerApi {
5353

5454
private byte[] b = new byte[]{};
5555
private final boolean external;
56+
private static SimpleDateFormat df = new SimpleDateFormat(Instance.getInstance() == null ? Config.getConfig().DATEFORMAT : Instance.getInstance().getDateFormat());
57+
private static SimpleDateFormat extdf = new SimpleDateFormat(Config.getConfig().DATEFORMAT);
58+
5659

5760
public CustomSerializer() {
5861
this.external = false;
@@ -286,8 +289,7 @@ public Object deserialize (String v, String t) throws UnsupportedEncodingExcepti
286289
case (t_double):
287290
return Double.parseDouble(v);
288291
case (t_date):
289-
SimpleDateFormat df = new SimpleDateFormat(this.external ? Config.getConfig().DATEFORMAT : Instance.getInstance() == null ? Config.getConfig().DATEFORMAT : Instance.getInstance().getDateFormat());
290-
return df.parse(v);
292+
return this.external ? extdf.parse(v) : df.parse(v);
291293
case (t_string):
292294
return v;
293295
}

0 commit comments

Comments
 (0)