Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a3c6ee0
Redundant condition: "(o == null || !(o instanceof X))" is always th…
Jan 27, 2022
ca7beac
Updated dependency ?
Jan 27, 2022
df54488
Redundant condition: "(o == null || !(o instanceof X))" is always th…
Jan 27, 2022
49bafa3
Replace loop with Arrays.fill
Jan 27, 2022
e227a94
Use Math.min/max
Jan 27, 2022
8cd75af
Replace duplicate code.
Jan 27, 2022
9dd0c6a
Replace duplicate code.
Jan 27, 2022
2bc79d7
Redundant null check, can never be NULL. Error?
Jan 27, 2022
1dca191
Optional API
Jan 27, 2022
c1934e8
Redundant explicit array creation.
Jan 27, 2022
f3eaf59
Unnecessary String.length()
Jan 27, 2022
7357a84
Redundant cast removed.
Jan 27, 2022
9f67cf9
Simplified stream usage.
Jan 27, 2022
dbe682c
Use String instead
Jan 27, 2022
72157ed
Improved type declaration avoids class casts.
Jan 27, 2022
0659287
Use empty <> instead.
Jan 27, 2022
db489c3
Collapse catch blocks.
Jan 27, 2022
3bfed20
Use modern try with resource management
Jan 27, 2022
e42243c
Replace with lambda.
Jan 27, 2022
2ca93b1
Use List.sort(...)
Jan 27, 2022
7f8e26a
Use Comparator.comparing
Jan 27, 2022
3342a8c
Replace lambda with method reference (better readability)
Jan 27, 2022
cd4b7de
Replace lambda with method reference (better readability)
Jan 27, 2022
2b52cad
Use modern Map api.
Jan 27, 2022
dcf0340
Use expression lambda.
Jan 27, 2022
e54888f
Use enhanced for loop
Jan 27, 2022
48bbe80
Remove unnecessary boxing.
Jan 27, 2022
8162b8e
Remove unnecessary unboxing.
Jan 27, 2022
7c9b7ac
USe contains(...)
Jan 27, 2022
bf6ecec
Use modern, enhanced for-loop.
Jan 27, 2022
acb0f9b
Inner class can be static
Jan 27, 2022
696a0bf
Use parametrized constructor.
Jan 27, 2022
5e0e1fe
Use System.arraycopy
Jan 27, 2022
6699e15
Use Collections.addAll
Jan 27, 2022
d85d84e
Replace unpredictable constructor call
Jan 27, 2022
590b02f
Fixed compile error
Jan 27, 2022
67cd45e
Undo 'redundant cast removed'
Jan 27, 2022
c40f373
Fixed compile error.
Jan 27, 2022
cbf2864
Fixed compile error.
Jan 27, 2022
651976b
Undo 'Redundant cast removed'.
Jan 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions console/src/main/java/com/arcadedb/console/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,11 @@ public Console(final boolean interactive) throws IOException {

lineReader.getHistory().save();

} catch (UserInterruptException e) {
return;
} catch (EndOfFileException e) {
} catch (UserInterruptException | EndOfFileException e) {
return;
}

try {
try {
if (!parse(line, false))
return;
} catch (Exception e) {
Expand Down Expand Up @@ -205,10 +203,7 @@ else if (line.startsWith("set"))
}

return true;
} catch (IOException e) {
outputError(e);
throw e;
} catch (RuntimeException e) {
} catch (IOException | RuntimeException e) {
outputError(e);
throw e;
}
Expand Down
10 changes: 5 additions & 5 deletions console/src/test/java/com/arcadedb/console/ConsoleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void testCreateClass() throws IOException {
Assertions.assertTrue(console.parse("create document type Person", false));

final StringBuilder buffer = new StringBuilder();
console.setOutput(output -> buffer.append(output));
console.setOutput(buffer::append);
Assertions.assertTrue(console.parse("info types", false));
Assertions.assertTrue(buffer.toString().contains("Person"));
}
Expand All @@ -79,7 +79,7 @@ public void testInsertAndSelectRecord() throws IOException {
Assertions.assertTrue(console.parse("insert into Person set name = 'Jay', lastname='Miner'", false));

final StringBuilder buffer = new StringBuilder();
console.setOutput(output -> buffer.append(output));
console.setOutput(buffer::append);
Assertions.assertTrue(console.parse("select from Person", false));
Assertions.assertTrue(buffer.toString().contains("Jay"));
}
Expand All @@ -93,15 +93,15 @@ public void testInsertAndRollback() throws IOException {
Assertions.assertTrue(console.parse("rollback", false));

final StringBuilder buffer = new StringBuilder();
console.setOutput(output -> buffer.append(output));
console.setOutput(buffer::append);
Assertions.assertTrue(console.parse("select from Person", false));
Assertions.assertFalse(buffer.toString().contains("Jay"));
}

@Test
public void testHelp() throws IOException {
final StringBuilder buffer = new StringBuilder();
console.setOutput(output -> buffer.append(output));
console.setOutput(buffer::append);
Assertions.assertTrue(console.parse("?", false));
Assertions.assertTrue(buffer.toString().contains("quit"));
}
Expand Down Expand Up @@ -130,7 +130,7 @@ public void testAllRecordTypes() throws IOException {
Assertions.assertTrue(console.parse("create edge E from (select from V where name ='Jay') to (select from V where name ='Elon')", false));

final StringBuilder buffer = new StringBuilder();
console.setOutput(output -> buffer.append(output));
console.setOutput(buffer::append);
Assertions.assertTrue(console.parse("select from D", false));
Assertions.assertTrue(buffer.toString().contains("Jay"));

Expand Down
2 changes: 1 addition & 1 deletion e2e/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<parent>
<groupId>com.arcadedb</groupId>
<artifactId>arcadedb-parent</artifactId>
<version>22.1.1-SNAPSHOT</version>
<version>22.1.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
18 changes: 5 additions & 13 deletions engine/src/main/java/com/arcadedb/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,12 @@ public class Constants {
private static final Properties properties = new Properties();

static {
final InputStream inputStream = Constants.class.getResourceAsStream("/com/arcadedb/arcadedb.properties");
try {
properties.load(inputStream);
} catch (IOException e) {
LogManager.instance().log(Constants.class, Level.SEVERE, "Failed to load ArcadeDB properties", e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException ignore) {
// Ignore
}
try (InputStream inputStream = Constants.class.getResourceAsStream("/com/arcadedb/arcadedb.properties")) {
properties.load(inputStream);
} catch (IOException e) {
LogManager.instance().log(Constants.class, Level.SEVERE, "Failed to load ArcadeDB properties", e);
}
}
// Ignore

}

Expand Down
8 changes: 4 additions & 4 deletions engine/src/main/java/com/arcadedb/ContextConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public boolean getValueAsBoolean(final GlobalConfiguration iConfig) {
final Object v = getValue(iConfig);
if (v == null)
return false;
return v instanceof Boolean ? ((Boolean) v).booleanValue() : Boolean.parseBoolean(v.toString());
return v instanceof Boolean ? (Boolean) v : Boolean.parseBoolean(v.toString());
}

public String getValueAsString(final String iName, final String iDefaultValue) {
Expand All @@ -179,21 +179,21 @@ public int getValueAsInteger(final GlobalConfiguration iConfig) {
final Object v = getValue(iConfig);
if (v == null)
return 0;
return v instanceof Integer ? ((Integer) v).intValue() : Integer.parseInt(v.toString());
return v instanceof Integer ? (Integer) v : Integer.parseInt(v.toString());
}

public long getValueAsLong(final GlobalConfiguration iConfig) {
final Object v = getValue(iConfig);
if (v == null)
return 0;
return v instanceof Long ? ((Long) v).longValue() : Long.parseLong(v.toString());
return v instanceof Long ? (Long) v : Long.parseLong(v.toString());
}

public float getValueAsFloat(final GlobalConfiguration iConfig) {
final Object v = getValue(iConfig);
if (v == null)
return 0;
return v instanceof Float ? ((Float) v).floatValue() : Float.parseFloat(v.toString());
return v instanceof Float ? (Float) v : Float.parseFloat(v.toString());
}

public int getContextSize() {
Expand Down
2 changes: 1 addition & 1 deletion engine/src/main/java/com/arcadedb/database/BaseRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void delete() {
public boolean equals(final Object o) {
if (this == o)
return true;
if (o == null || !(o instanceof Identifiable))
if (!(o instanceof Identifiable))
return false;

final RID pRID = ((Identifiable) o).getIdentity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,56 +116,53 @@ public boolean onBeforeCreate(final Record record) {
if (beforeCreateListeners.isEmpty())
return true;

for (int i = 0; i < beforeCreateListeners.size(); i++) {
if (!beforeCreateListeners.get(i).onBeforeCreate(record))
return false;
}
for (BeforeRecordCreateListener beforeCreateListener : beforeCreateListeners) {
if (!beforeCreateListener.onBeforeCreate(record))
return false;
}
return true;
}

public boolean onBeforeUpdate(final Record record) {
if (beforeUpdateListeners.isEmpty())
return true;

for (int i = 0; i < beforeUpdateListeners.size(); i++) {
if (!beforeUpdateListeners.get(i).onBeforeUpdate(record))
return false;
}
for (BeforeRecordUpdateListener beforeUpdateListener : beforeUpdateListeners) {
if (!beforeUpdateListener.onBeforeUpdate(record))
return false;
}
return true;
}

public boolean onBeforeDelete(final Record record) {
if (beforeDeleteListeners.isEmpty())
return true;

for (int i = 0; i < beforeDeleteListeners.size(); i++) {
if (!beforeDeleteListeners.get(i).onBeforeDelete(record))
return false;
}
for (BeforeRecordDeleteListener beforeDeleteListener : beforeDeleteListeners) {
if (!beforeDeleteListener.onBeforeDelete(record))
return false;
}
return true;
}

public void onAfterCreate(final Record record) {
if (afterCreateListeners.isEmpty())
return;

for (int i = 0; i < afterCreateListeners.size(); i++)
afterCreateListeners.get(i).onAfterCreate(record);
for (AfterRecordCreateListener afterCreateListener : afterCreateListeners) afterCreateListener.onAfterCreate(record);
}

public void onAfterUpdate(final Record record) {
if (afterUpdateListeners.isEmpty())
return;

for (int i = 0; i < afterUpdateListeners.size(); i++)
afterUpdateListeners.get(i).onAfterUpdate(record);
for (AfterRecordUpdateListener afterUpdateListener : afterUpdateListeners) afterUpdateListener.onAfterUpdate(record);
}

public void onAfterDelete(final Record record) {
if (afterDeleteListeners.isEmpty())
return;

for (int i = 0; i < afterDeleteListeners.size(); i++)
afterDeleteListeners.get(i).onAfterDelete(record);
for (AfterRecordDeleteListener afterDeleteListener : afterDeleteListeners) afterDeleteListener.onAfterDelete(record);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,8 @@ public DatabaseFactory setSecurity(final SecurityManager security) {
* Test only API
*/
public void registerCallback(final DatabaseInternal.CALLBACK_EVENT event, Callable<Void> callback) {
List<Callable<Void>> callbacks = this.callbacks.get(event);
if (callbacks == null) {
callbacks = new ArrayList<>();
this.callbacks.put(event, callbacks);
}
callbacks.add(callback);
List<Callable<Void>> callbacks = this.callbacks.computeIfAbsent(event, k -> new ArrayList<>());
callbacks.add(callback);
}

public static Database getActiveDatabaseInstance(final String databasePath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ public ResultSet query(final String language, final String query, final Map<Stri
public boolean equals(final Object o) {
if (this == o)
return true;
if (o == null || !(o instanceof Database))
if (!(o instanceof Database))
return false;

final Database other = (Database) o;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ private Object convertToJSONType(Object value) {
} else if (value instanceof Collection) {
final Collection c = (Collection) value;
final JSONArray array = new JSONArray();
for (Iterator it = c.iterator(); it.hasNext(); )
array.put(convertToJSONType(it.next()));
for (Object o : c) array.put(convertToJSONType(o));
value = array;
} else if (value instanceof Date)
value = ((Date) value).getTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ public boolean onBeforeCreate(final Record record) {
if (beforeCreateListeners.isEmpty())
return true;

for (int i = 0; i < beforeCreateListeners.size(); i++) {
if (!beforeCreateListeners.get(i).onBeforeCreate(record))
return false;
}
for (BeforeRecordCreateListener beforeCreateListener : beforeCreateListeners) {
if (!beforeCreateListener.onBeforeCreate(record))
return false;
}
}
return true;
}
Expand All @@ -151,10 +151,10 @@ public boolean onBeforeUpdate(final Record record) {
if (beforeUpdateListeners.isEmpty())
return true;

for (int i = 0; i < beforeUpdateListeners.size(); i++) {
if (!beforeUpdateListeners.get(i).onBeforeUpdate(record))
return false;
}
for (BeforeRecordUpdateListener beforeUpdateListener : beforeUpdateListeners) {
if (!beforeUpdateListener.onBeforeUpdate(record))
return false;
}
}
return true;
}
Expand All @@ -164,10 +164,10 @@ public boolean onBeforeDelete(final Record record) {
if (beforeDeleteListeners.isEmpty())
return true;

for (int i = 0; i < beforeDeleteListeners.size(); i++) {
if (!beforeDeleteListeners.get(i).onBeforeDelete(record))
return false;
}
for (BeforeRecordDeleteListener beforeDeleteListener : beforeDeleteListeners) {
if (!beforeDeleteListener.onBeforeDelete(record))
return false;
}
}
return true;
}
Expand All @@ -177,8 +177,7 @@ public void onAfterCreate(final Record record) {
if (afterCreateListeners.isEmpty())
return;

for (int i = 0; i < afterCreateListeners.size(); i++)
afterCreateListeners.get(i).onAfterCreate(record);
for (AfterRecordCreateListener afterCreateListener : afterCreateListeners) afterCreateListener.onAfterCreate(record);
}
}

Expand All @@ -187,8 +186,7 @@ public void onAfterUpdate(final Record record) {
if (afterUpdateListeners.isEmpty())
return;

for (int i = 0; i < afterUpdateListeners.size(); i++)
afterUpdateListeners.get(i).onAfterUpdate(record);
for (AfterRecordUpdateListener afterUpdateListener : afterUpdateListeners) afterUpdateListener.onAfterUpdate(record);
}
}

Expand All @@ -197,8 +195,7 @@ public void onAfterDelete(final Record record) {
if (afterDeleteListeners.isEmpty())
return;

for (int i = 0; i < afterDeleteListeners.size(); i++)
afterDeleteListeners.get(i).onAfterDelete(record);
for (AfterRecordDeleteListener afterDeleteListener : afterDeleteListeners) afterDeleteListener.onAfterDelete(record);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class TransactionContext implements Transaction {

public enum STATUS {INACTIVE, BEGUN, COMMIT_1ST_PHASE, COMMIT_2ND_PHASE}

public class TransactionPhase1 {
public static class TransactionPhase1 {
public final Binary result;
public final List<MutablePage> modifiedPages;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ public void addFilesToLock(final Set<Integer> modifiedFiles) {
for (Bucket b : buckets)
modifiedFiles.add(b.getId());

for (Index typeIndex : type.getAllIndexes(true))
for (Index idx : ((TypeIndex) typeIndex).getIndexesOnBuckets())
for (TypeIndex typeIndex : type.getAllIndexes(true))
for (Index idx : typeIndex.getIndexesOnBuckets())
modifiedFiles.add(((IndexInternal) idx).getFileId());
} else
modifiedFiles.add(index.getAssociatedBucketId());
Expand Down
Loading