protected Map<Object, Object> deserializeQueryParameters(final byte[] paramBuffer, ORecordSerializer serializer) { if (paramBuffer == null || paramBuffer.length == 0) return Collections.emptyMap(); final ODocument param = new ODocument(); serializer.fromStream(paramBuffer, param, null); param.setFieldType("params", OType.EMBEDDEDMAP); final Map<String, Object> params = param.rawField("params"); final Map<Object, Object> result = new HashMap<Object, Object>(); for (Entry<String, Object> p : params.entrySet()) { if (Character.isDigit(p.getKey().charAt(0))) result.put(Integer.parseInt(p.getKey()), p.getValue()); else result.put(p.getKey(), p.getValue()); } return result; }
@Override public Set<String> getPropertyNames() { checkForLoading(); if (_status == ORecordElement.STATUS.LOADED && _source != null && ODatabaseRecordThreadLocal.instance().isDefined() && !ODatabaseRecordThreadLocal.instance().get().isClosed()) { // DESERIALIZE FIELD NAMES ONLY (SUPPORTED ONLY BY BINARY SERIALIZER) final String[] fieldNames = _recordFormat.getFieldNamesRoot(this, _source); if (fieldNames != null) { Set<String> result = new HashSet<>(); Collections.addAll(result, fieldNames); return result; } } checkForFields(); if (_fields == null || _fields.size() == 0) return Collections.EMPTY_SET; return _fields.entrySet().stream().filter(s -> s.getValue().exist()).map(Entry::getKey).collect(Collectors.toSet()); }
public OQueryOperatorMinorEquals() { super("<=", 5, false); ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); }
public byte[] toStream() { if (_source == null) _source = _recordFormat.toStream(this, false); invokeListenerEvent(ORecordListener.EVENT.MARSHALL); return _source; }
protected ODatabaseDocumentEmbedded internalCreate(OrientDBConfig config, OAbstractPaginatedStorage storage) { try { storage.create(config.getConfigurations()); } catch (IOException e) { throw OException.wrapException(new ODatabaseException("Error on database creation"), e); } ORecordSerializer serializer = ORecordSerializerFactory.instance().getDefaultRecordSerializer(); if (serializer.toString().equals("ORecordDocument2csv")) throw new ODatabaseException("Impossible to create the database with ORecordDocument2csv serializer"); storage.setRecordSerializer(serializer.toString(), serializer.getCurrentVersion()); // since 2.1 newly created databases use strict SQL validation by default storage.setProperty(OStatement.CUSTOM_STRICT_SQL, "true"); // No need to close final ODatabaseDocumentEmbedded embedded = factory.newInstance(storage); embedded.setSerializer(serializer); embedded.internalCreate(config); return embedded; }
public <RET extends ORecord> RET executeSaveEmptyRecord(ORecord record, String clusterName) { ORecordId rid = (ORecordId) record.getIdentity(); assert rid.isNew(); ORecordInternal.onBeforeIdentityChanged(record); int id = assignAndCheckCluster(record, clusterName); clusterName = getClusterNameById(id); checkSecurity(ORule.ResourceGeneric.CLUSTER, ORole.PERMISSION_CREATE, clusterName); byte[] content = getSerializer().writeClassOnly(record); final OStorageOperationResult<OPhysicalPosition> ppos = getStorage() .createRecord(rid, content, record.getVersion(), recordType, OPERATION_MODE.SYNCHRONOUS.ordinal(), null); ORecordInternal.setVersion(record, ppos.getResult().recordVersion); ((ORecordId) record.getIdentity()).copyFrom(rid); ORecordInternal.onAfterIdentityChanged(record); return (RET) record; }
if (serializer == null) throw new ODatabaseException("RecordSerializer with name '" + serializeName + "' not found "); if (getStorage().getConfiguration().getRecordSerializerVersion() > serializer.getMinSupportedVersion()) throw new ODatabaseException("Persistent record serializer version is not support by the current implementation");
protected byte[] toStream(final boolean iOnlyDelta) { STATUS prev = _status; _status = STATUS.MARSHALLING; try { if (_source == null) _source = _recordFormat.toStream(this, iOnlyDelta); } finally { _status = prev; } invokeListenerEvent(ORecordListener.EVENT.MARSHALL); return _source; }
public OQueryOperatorMinor() { super("<", 5, false); ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); }
@Override public void writeExternal(ObjectOutput stream) throws IOException { ORecordSerializer serializer = ORecordSerializerFactory.instance().getFormat(ORecordSerializerNetwork.NAME); final byte[] idBuffer = _recordId.toStream(); stream.writeInt(-1); stream.writeInt(idBuffer.length); stream.write(idBuffer); stream.writeInt(_recordVersion); final byte[] content = serializer.toStream(this, false); stream.writeInt(content.length); stream.write(content); stream.writeBoolean(_dirty); stream.writeObject(serializer.toString()); }
_recordFormat.fromStream(_source, this, iFields); } finally { _status = ORecordElement.STATUS.LOADED;
/** * Returns the set of field names. */ public String[] fieldNames() { checkForLoading(); if (_status == ORecordElement.STATUS.LOADED && _source != null && ODatabaseRecordThreadLocal.instance().isDefined() && !ODatabaseRecordThreadLocal.instance().get().isClosed()) { // DESERIALIZE FIELD NAMES ONLY (SUPPORTED ONLY BY BINARY SERIALIZER) final String[] fieldNames = _recordFormat.getFieldNamesRoot(this, _source); if (fieldNames != null) return fieldNames; } checkForFields(); if (_fields == null || _fields.size() == 0) return EMPTY_STRINGS; final List<String> names = new ArrayList<>(_fields.size()); for (Entry<String, ODocumentEntry> entry : _fields.entrySet()) { if (entry.getValue().exist()) names.add(entry.getKey()); } return names.toArray(new String[names.size()]); }
public OQueryOperatorMajorEquals() { super(">=", 5, false); ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); }
@Override public void readExternal(ObjectInput stream) throws IOException, ClassNotFoundException { int i = stream.readInt(); int size; if (i < 0) size = stream.readInt(); else size = i; final byte[] idBuffer = new byte[size]; stream.readFully(idBuffer); _recordId.fromStream(idBuffer); _recordVersion = stream.readInt(); final int len = stream.readInt(); final byte[] content = new byte[len]; stream.readFully(content); _dirty = stream.readBoolean(); ORecordSerializer serializer = _recordFormat; if (i < 0) { final String str = (String) stream.readObject(); // TODO: WHEN TO USE THE SERIALIZER? serializer = ORecordSerializerFactory.instance().getFormat(str); } _status = ORecordElement.STATUS.UNMARSHALLING; try { serializer.fromStream(content, this, null); } finally { _status = ORecordElement.STATUS.LOADED; } }
public OQueryOperatorNotEquals() { super("<>", 5, false); ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); }
final ODocument param = new ODocument(); if (serializer != null) serializer.fromStream(paramBuffer, param, null); else param.fromStream(paramBuffer); final ODocument param = new ODocument(); if (serializer != null) serializer.fromStream(paramBuffer, param, null); else param.fromStream(paramBuffer);
public OQueryOperatorNotEquals2() { super("!=", 5, false); ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); }
public OQueryOperatorEquals() { super("=", 5, false); ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); }
public OQueryOperatorMajor() { super(">", 5, false); ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().getIfDefined(); if (db != null) binaryEvaluate = db.getSerializer().getSupportBinaryEvaluate(); }