Skip to content
Closed
Show file tree
Hide file tree
Changes from 24 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
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 @@ -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 @@ -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
4 changes: 2 additions & 2 deletions engine/src/main/java/com/arcadedb/engine/DatabaseChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ public Map<String, Object> check() {
for (RID rid : (Collection<RID>) result.get("corruptedRecords"))
affectedBuckets.add(rid.getBucketId());

final Set<Index> affectedIndexes = new HashSet<Index>();
final Set<Index> affectedIndexes = new HashSet<>();
for (Index index : database.getSchema().getIndexes())
if (affectedBuckets.contains(index.getAssociatedBucketId()))
affectedIndexes.add(index);

final Set<String> rebuildIndexes = affectedIndexes.stream().map(x -> x.getName()).collect(Collectors.toSet());
final Set<String> rebuildIndexes = affectedIndexes.stream().map(Index::getName).collect(Collectors.toSet());
result.put("rebuiltIndexes", rebuildIndexes);

if (verboseLevel > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void close(final boolean drop) {
final File dir = new File(database.getDatabasePath());
File[] walFiles = dir.listFiles((dir1, name) -> name.endsWith(".wal"));
if (walFiles != null) {
Arrays.asList(walFiles).stream().forEach(File::delete);
Arrays.forEach(File::delete);
walFiles = dir.listFiles((dir1, name) -> name.endsWith(".wal"));
}

Expand Down
2 changes: 1 addition & 1 deletion engine/src/main/java/com/arcadedb/graph/GraphEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ public boolean isVertexConnectedTo(final VertexInternal vertex, final Identifiab
if (edgeType == null)
throw new IllegalArgumentException("Edge type is null");

final int[] bucketFilter = vertex.getDatabase().getSchema().getType(edgeType).getBuckets(true).stream().mapToInt(x -> x.getId()).toArray();
final int[] bucketFilter = vertex.getDatabase().getSchema().getType(edgeType).getBuckets(true).stream().mapToInt(Bucket::getId).toArray();

if (direction == Vertex.DIRECTION.OUT || direction == Vertex.DIRECTION.BOTH) {
final EdgeLinkedList outEdges = getEdgeHeadChunk(vertex, Vertex.DIRECTION.OUT);
Expand Down
11 changes: 5 additions & 6 deletions engine/src/main/java/com/arcadedb/graph/ImmutableEdge.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public Object get(final String propertyName) {

public synchronized MutableEdge modify() {
final Record recordInCache = database.getTransaction().getRecordFromCache(rid);
if (recordInCache != null && recordInCache != this && recordInCache instanceof MutableEdge)
if (recordInCache != this && recordInCache instanceof MutableEdge)
return (MutableEdge) recordInCache;

checkForLazyLoading();
Expand Down Expand Up @@ -133,10 +133,9 @@ protected boolean checkForLazyLoading() {

@Override
public synchronized String toString() {
final StringBuilder buffer = new StringBuilder();
buffer.append(out.toString());
buffer.append("<->");
buffer.append(in.toString());
return buffer.toString();
String buffer = out.toString() +
"<->" +
in.toString();
return buffer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ public synchronized JSONObject toJSON() {

@Override
public synchronized String toString() {
final StringBuilder buffer = new StringBuilder();
buffer.append(out.toString());
buffer.append("<->");
buffer.append(in.toString());
return buffer.toString();
String buffer = out.toString() +
"<->" +
in.toString();
return buffer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,8 @@ public void put(final RID key, final RID edgeRID, final RID vertexRID) {
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, edgeRID);
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, vertexRID);

if (previousEntryPos > 0)
// THIS IS THE 3RD OR MAJOR ENTRY. APPEND THE POSITION OF THE PREVIOUS ENTRY
chunk.putInt(previousEntryPos);
else
chunk.putInt(0);
chunk.putInt(Math.max(previousEntryPos, 0));

chunk.putInt(previousEntryOffset, newEntryPosition);
++totalEntries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public byte[] getKeyTypes() {
}

private void initCursors() {
cursorsNextValues = new ArrayList<Identifiable>(cursors.size());
cursorsNextValues = new ArrayList<>(cursors.size());
for (int i = 0; i < cursors.size(); ++i) {
cursorsNextValues.add(null);

Expand Down
4 changes: 2 additions & 2 deletions engine/src/main/java/com/arcadedb/index/TypeIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ public String getName() {
public Map<String, Long> getStats() {
checkIsValid();
final Map<String, Long> stats = new HashMap<>();
for (Index index : indexesOnBuckets)
stats.putAll(((IndexInternal) index).getStats());
for (IndexInternal index : indexesOnBuckets)
stats.putAll(index.getStats());
return stats;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,10 @@ public IndexCursor get(final Object[] keys, final int limit) {
list.add(new IndexCursorEntry(keys, entry.getKey(), entry.getValue().get()));

if (list.size() > 1)
Collections.sort(list, new Comparator<IndexCursorEntry>() {
@Override
public int compare(final IndexCursorEntry o1, final IndexCursorEntry o2) {
list.sort((o1, o2) -> {
if (o1.score == o2.score)
return 0;
return 0;
return o1.score < o2.score ? -1 : 1;
}
});

return new TempIndexCursor(list);
Expand Down Expand Up @@ -309,29 +306,23 @@ public List<String> analyzeText(final Analyzer analyzer, final Object[] text) {
final List<String> tokens = new ArrayList<>();

for (Object t : text) {
final TokenStream tokenizer = analyzer.tokenStream("contents", t.toString());
try {
tokenizer.reset();
final CharTermAttribute termAttribute = tokenizer.getAttribute(CharTermAttribute.class);

try {
while (tokenizer.incrementToken()) {
String token = termAttribute.toString();
tokens.add(token);
}

try (TokenStream tokenizer = analyzer.tokenStream("contents", t.toString())) {
tokenizer.reset();
final CharTermAttribute termAttribute = tokenizer.getAttribute(CharTermAttribute.class);

try {
while (tokenizer.incrementToken()) {
String token = termAttribute.toString();
tokens.add(token);
}

} catch (IOException e) {
throw new IndexException("Error on analyzing text", e);
}
} catch (IOException e) {
throw new IndexException("Error on analyzing text", e);
throw new IndexException("Error on tokenizer", e);
}
} catch (IOException e) {
throw new IndexException("Error on tokenizer", e);
} finally {
try {
tokenizer.close();
} catch (IOException e) {
// IGNORE IT
}
}
// IGNORE IT
}
return tokens;
}
Expand Down
12 changes: 6 additions & 6 deletions engine/src/main/java/com/arcadedb/log/DefaultLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class DefaultLogger implements Logger {
private static final String DEFAULT_LOG = "com.arcadedb";
private static final String ENV_INSTALL_CUSTOM_FORMATTER = "arcadedb.installCustomFormatter";
private static final DefaultLogger instance = new DefaultLogger();
private final ConcurrentMap<String, java.util.logging.Logger> loggersCache = new ConcurrentHashMap<String, java.util.logging.Logger>();
private final ConcurrentMap<String, java.util.logging.Logger> loggersCache = new ConcurrentHashMap<>();

public DefaultLogger() {
installCustomFormatter();
Expand Down Expand Up @@ -103,15 +103,16 @@ else if (requester != null)
}
}

if (log == null) {
boolean argumentsNullCheck = arg1 != null || arg2 != null || arg3 != null || arg4 != null || arg5 != null || arg6 != null || arg7 != null || arg8 != null || arg9 != null
|| arg10 != null || arg11 != null || arg12 != null || arg13 != null || arg14 != null || arg15 != null || arg16 != null || arg17 != null;
if (log == null) {
if (context != null)
message = "<" + context + "> " + message;

// USE SYSERR
try {
String msg = message;
if (arg1 != null || arg2 != null || arg3 != null || arg4 != null || arg5 != null || arg6 != null || arg7 != null || arg8 != null || arg9 != null
|| arg10 != null || arg11 != null || arg12 != null || arg13 != null || arg14 != null || arg15 != null || arg16 != null || arg17 != null)
if (argumentsNullCheck)
msg = String.format(message, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17);

System.err.println(msg);
Expand All @@ -129,8 +130,7 @@ else if (requester != null)
message = "<" + context + "> " + message;

String msg = message;
if (arg1 != null || arg2 != null || arg3 != null || arg4 != null || arg5 != null || arg6 != null || arg7 != null || arg8 != null || arg9 != null
|| arg10 != null || arg11 != null || arg12 != null || arg13 != null || arg14 != null || arg15 != null || arg16 != null || arg17 != null)
if (argumentsNullCheck)
msg = String.format(message, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17);

if (exception != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected void fetchNextEntryPoints(CommandContext ctx, int nRecords) {
((ResultInternal) item).setMetadata("$depth", 0);

List stack = new ArrayList();
item.getIdentity().ifPresent(x -> stack.add(x));
item.getIdentity().ifPresent(stack::add);
((ResultInternal) item).setMetadata("$stack", stack);

List<Identifiable> path = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public DeleteEdgeExecutionPlanner(DeleteEdgeStatement stm) {
this.rids = new ArrayList<>();
rids.add(stm.getRid().copy());
} else {
this.rids = stm.getRids() == null ? null : stm.getRids().stream().map(x -> x.copy()).collect(Collectors.toList());
this.rids = stm.getRids() == null ? null : stm.getRids().stream().map(Rid::copy).collect(Collectors.toList());
}

this.leftExpression = stm.getLeftExpression() == null ? null : stm.getLeftExpression().copy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected void fetchNextEntryPoints(final CommandContext ctx, final int nRecords
((ResultInternal) item).setMetadata("$depth", 0);

final List stack = new ArrayList();
item.getIdentity().ifPresent(x -> stack.add(x));
item.getIdentity().ifPresent(stack::add);
((ResultInternal) item).setMetadata("$stack", stack);

final List<Identifiable> path = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void sendTimeout() {

@Override
public void close() {
prev.ifPresent(x -> x.close());
prev.ifPresent(ExecutionStepInternal::close);
}

@Override
Expand Down
Loading