Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions engine/src/main/java/com/arcadedb/GlobalConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ public Object call(final Object value) {
"Default datetime implementation to use on deserialization. By default java.util.Date is used, but the following are supported: java.util.Calendar, java.time.LocalDateTime, java.time.ZonedDateTime",
Class.class, java.util.Date.class),

DATE_TIME_PRECISION("arcadedb.dateTimePrecision",
"Precision to use with Datetime types on deserialization. Check the level of precision supported by your OS/JVM. By default is 'millisecond'. Supported are: 'millisecond', 'microsecond' and 'nanosecond'",
String.class, "millisecond"),

DATE_TIME_FORMAT("arcadedb.dateTimeFormat", "Default date time format using Java SimpleDateFormat syntax", String.class, "yyyy-MM-dd HH:mm:ss"),

TX_WAL("arcadedb.txWAL", "Uses the WAL", Boolean.class, true),
Expand Down
16 changes: 6 additions & 10 deletions engine/src/main/java/com/arcadedb/database/MutableDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.arcadedb.schema.Property;
import com.arcadedb.schema.Type;
import com.arcadedb.serializer.json.JSONObject;
import com.arcadedb.utility.DateUtils;

import java.util.*;

Expand Down Expand Up @@ -380,17 +379,14 @@ protected Object convertValueToSchemaType(final String name, final Object value,
if (property != null)
try {
final Type propType = property.getType();
Class javaImplementation = propType.getDefaultJavaType();
if (propType == Type.DATE) {

final Class javaImplementation;
if (propType == Type.DATE)
javaImplementation = database.getSerializer().getDateImplementation();
if (DateUtils.getPrecisionLevel(value.getClass()) > DateUtils.getPrecisionLevel(javaImplementation))
javaImplementation = value.getClass();
}
if (propType == Type.DATETIME) {
else if (propType == Type.DATETIME)
javaImplementation = database.getSerializer().getDateTimeImplementation();
if (DateUtils.getPrecisionLevel(value.getClass()) > DateUtils.getPrecisionLevel(javaImplementation))
javaImplementation = value.getClass();
}
else
javaImplementation = propType.getDefaultJavaType();

return Type.convert(database, value, javaImplementation, property);
} catch (final Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public MutableEdgeSegment(final DatabaseInternal database, final int bufferSize)
buffer.putByte(0, RECORD_TYPE);
buffer.putInt(Binary.BYTE_SERIALIZED_SIZE, CONTENT_START_POSITION);
buffer.position(Binary.BYTE_SERIALIZED_SIZE + Binary.INT_SERIALIZED_SIZE);
database.getSerializer().serializeValue(database, buffer, BinaryTypes.TYPE_RID, NULL_RID, null); // NEXT
database.getSerializer().serializeValue(database, buffer, BinaryTypes.TYPE_RID, NULL_RID); // NEXT
}

@Override
Expand All @@ -82,8 +82,8 @@ public byte getRecordType() {
@Override
public boolean add(final RID edgeRID, final RID vertexRID) {
final Binary ridSerialized = database.getContext().getTemporaryBuffer1();
database.getSerializer().serializeValue(database, ridSerialized, BinaryTypes.TYPE_COMPRESSED_RID, edgeRID, null);
database.getSerializer().serializeValue(database, ridSerialized, BinaryTypes.TYPE_COMPRESSED_RID, vertexRID, null);
database.getSerializer().serializeValue(database, ridSerialized, BinaryTypes.TYPE_COMPRESSED_RID, edgeRID);
database.getSerializer().serializeValue(database, ridSerialized, BinaryTypes.TYPE_COMPRESSED_RID, vertexRID);

final int used = getUsed();

Expand Down Expand Up @@ -317,7 +317,7 @@ public void setPrevious(final EdgeSegment previous) {
if (nextRID == null)
throw new IllegalArgumentException("Next chunk is not persistent");
buffer.position(Binary.BYTE_SERIALIZED_SIZE + Binary.INT_SERIALIZED_SIZE);
database.getSerializer().serializeValue(database, buffer, BinaryTypes.TYPE_RID, nextRID, null); // NEXT
database.getSerializer().serializeValue(database, buffer, BinaryTypes.TYPE_RID, nextRID); // NEXT
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,13 @@ public void put(final K key, final RID value) {
chunk.putInt(hash * Binary.INT_SERIALIZED_SIZE, chunk.position());

// WRITE THE KEY FIRST
serializer.serializeValue(database, chunk, keyBinaryType, key, null);
serializer.serializeValue(database, chunk, keyBinaryType, key);

// LEAVE AN INT AS EMPTY SLOT FOR THE NEXT KEY
chunk.putInt(0);

// WRITE THE VALUE
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, value, null);
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, value);

++totalUsedSlots;

Expand Down Expand Up @@ -228,13 +228,13 @@ public void put(final K key, final RID value) {
final int entryPosition = chunk.position();

// WRITE THE KEY FIRST
serializer.serializeValue(database, chunk, keyBinaryType, key, null);
serializer.serializeValue(database, chunk, keyBinaryType, key);

// LEAVE AN INT AS EMPTY SLOT FOR THE NEXT KEY
chunk.putInt(0);

// WRITE THE VALUE
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, value, null);
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, value);

// WRITE THIS ENTRY POSITION TO THE PREVIOUS NEXT POSITION FIELD
chunk.putInt(lastNextPos, entryPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void put(final RID key, final RID edgeRID, final RID vertexRID) {
// WRITE -> RID|INT|INT|RID|RID

// WRITE THE KEY FIRST
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, key, null);
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, key);

// LEAVE AN INT AS EMPTY SLOT FOR THE NEXT KEY
chunk.putInt(0);
Expand All @@ -265,8 +265,8 @@ public void put(final RID key, final RID edgeRID, final RID vertexRID) {
chunk.putInt(0);

// WRITE THE VALUE
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, edgeRID, null);
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, vertexRID, null);
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, edgeRID);
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, vertexRID);

++totalUsedSlots;

Expand All @@ -289,8 +289,8 @@ public void put(final RID key, final RID edgeRID, final RID vertexRID) {

// WRITE -> RID|RID|INT

serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, edgeRID, null);
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, vertexRID, null);
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
Expand All @@ -317,7 +317,7 @@ public void put(final RID key, final RID edgeRID, final RID vertexRID) {
final int entryPosition = chunk.position();

// WRITE THE KEY FIRST
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, key, null);
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, key);

// LEAVE AN INT AS EMPTY SLOT FOR THE NEXT KEY
chunk.putInt(0);
Expand All @@ -326,8 +326,8 @@ public void put(final RID key, final RID edgeRID, final RID vertexRID) {
chunk.putInt(0);

// WRITE THE VALUE
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, edgeRID, null);
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, vertexRID, null);
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, edgeRID);
serializer.serializeValue(database, chunk, BinaryTypes.TYPE_COMPRESSED_RID, vertexRID);

// WRITE THIS ENTRY POSITION TO THE PREVIOUS NEXT POSITION FIELD
chunk.putInt(lastNextPos, entryPosition);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,19 +433,19 @@ else if (result > 0)

private void writeEntryValues(final Binary buffer, final Object[] values) {
// WRITE NUMBER OF VALUES
serializer.serializeValue(database, buffer, BinaryTypes.TYPE_INT, values.length, null);
serializer.serializeValue(database, buffer, BinaryTypes.TYPE_INT, values.length);

// WRITE VALUES
for (int i = 0; i < values.length; ++i)
serializer.serializeValue(database, buffer, valueType, values[i], null);
serializer.serializeValue(database, buffer, valueType, values[i]);
}

private void writeEntryValue(final Binary buffer, final Object value) {
// WRITE NUMBER OF VALUES
serializer.serializeValue(database, buffer, BinaryTypes.TYPE_INT, 1, null);
serializer.serializeValue(database, buffer, BinaryTypes.TYPE_INT, 1);

// WRITE VALUES
serializer.serializeValue(database, buffer, valueType, value, null);
serializer.serializeValue(database, buffer, valueType, value);
}

protected RID[] readEntryValues(final Binary buffer) {
Expand Down Expand Up @@ -568,7 +568,7 @@ private void writeKeys(final Binary buffer, final Object[] keys) {
else {
// WRITE 1 + THE ACTUAL VALUE
buffer.putByte((byte) 1);
serializer.serializeValue(database, buffer, binaryKeyTypes[i], value, null);
serializer.serializeValue(database, buffer, binaryKeyTypes[i], value);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ else if (ioResult instanceof Instant)
else if (ioResult instanceof Date) {
if (targetPrecision == ChronoUnit.MILLIS)
return ioResult;
return DateUtils.dateTime(iContext.getDatabase(), ((Date) ioResult).getTime(), LocalDateTime.class, targetPrecision);
return DateUtils.dateTime(iContext.getDatabase(), ((Date) ioResult).getTime(), ChronoUnit.MILLIS, LocalDateTime.class, targetPrecision);
} else if (ioResult instanceof Calendar) {
if (targetPrecision == ChronoUnit.MILLIS)
return ioResult;
return DateUtils.dateTime(iContext.getDatabase(), ((Calendar) ioResult).getTimeInMillis(), LocalDateTime.class, targetPrecision);
return DateUtils.dateTime(iContext.getDatabase(), ((Calendar) ioResult).getTimeInMillis(), ChronoUnit.MILLIS, LocalDateTime.class, targetPrecision);
}

throw new CommandExecutionException("Error on changing precision for unsupported type '" + ioResult.getClass() + "'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ private Result executeSimpleAlter(final Identifier settingName, final Expression
} catch (ClassNotFoundException e) {
throw new DatabaseOperationException("Invalid datetime implementation '" + finalValue + "'", e);
}
} else if ("arcadedb.dateTimePrecision".equals(settingNameAsString)) {
finalValue = FileUtils.getStringContent(settingValue);
ctx.getDatabase().getSerializer().setDateTimePrecision(finalValue.toString());
}

db.getConfiguration().setValue(cfg, finalValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ public ResultSet executeDDL(final CommandContext ctx) {
if ("default".equals(setting)) {
oldValue = property.getDefaultValue();
property.setDefaultValue(finalValue);
} else if ("precision".equals(setting)) {
oldValue = property.getPrecision();
property.setPrecision(finalValue.toString());
} else {
throw new CommandExecutionException("Setting '" + setting + "' not supported");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ public Object setOnProperty(final Property internalProp, final CommandContext ct
internalProp.setMax("" + attrValue);
} else if (attrName.equalsIgnoreCase("min")) {
internalProp.setMin("" + attrValue);
} else if (attrName.equalsIgnoreCase("precision")) {
internalProp.setPrecision("" + attrValue);
} else if (attrName.equalsIgnoreCase("default")) {
if (this.settingValue == null)
throw new CommandExecutionException("Default value not set");
Expand Down
2 changes: 0 additions & 2 deletions engine/src/main/java/com/arcadedb/schema/DocumentType.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,6 @@ public Property createProperty(final String propName, final JSONObject prop) {
p.setMin(prop.getString("min"));
if (prop.has("regexp"))
p.setRegexp(prop.getString("regexp"));
if (prop.has("precision"))
p.setPrecision(prop.getString("precision"));

p.custom.clear();
if (prop.has("custom"))
Expand Down
39 changes: 7 additions & 32 deletions engine/src/main/java/com/arcadedb/schema/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,22 @@

import com.arcadedb.index.Index;
import com.arcadedb.serializer.json.JSONObject;
import com.arcadedb.utility.DateUtils;

import java.time.temporal.*;
import java.util.*;

public class Property {
private final DocumentType owner;
private final String name;
private final Type type;
private final int id;
protected final Map<String, Object> custom = new HashMap<>();
protected final Map<String, Object> custom = new HashMap<>();
private Object defaultValue;
private boolean readonly = false;
private boolean mandatory = false;
private boolean notNull = false;
private String max = null;
private String min = null;
private String regexp = null;
private String precision = null;
private ChronoUnit dateTimePrecision = null;
private boolean readonly = false;
private boolean mandatory = false;
private boolean notNull = false;
private String max = null;
private String min = null;
private String regexp = null;

public Property(final DocumentType owner, final String name, final Type type) {
this.owner = owner;
Expand Down Expand Up @@ -189,25 +185,6 @@ public String getRegexp() {
return regexp;
}

public String getPrecision() {
return precision;
}

public Property setPrecision(final String precision) {
final boolean changed = !Objects.equals(this.precision, precision);
if (changed) {
this.precision = precision;
if (type == Type.DATETIME)
dateTimePrecision = DateUtils.parsePrecision(precision);
owner.getSchema().getEmbedded().saveConfiguration();
}
return this;
}

public ChronoUnit getDateTimePrecision() {
return dateTimePrecision;
}

public Set<String> getCustomKeys() {
return Collections.unmodifiableSet(custom.keySet());
}
Expand Down Expand Up @@ -237,8 +214,6 @@ public JSONObject toJSON() {
json.put("min", min);
if (regexp != null)
json.put("regexp", regexp);
if (precision != null)
json.put("precision", precision);

json.put("custom", new JSONObject(custom));

Expand Down
Loading