signature:
public class OSchemaProxyObject { /** * Generate / updates the SchemaClass and properties from given Class < ? > .
 * @ param iClass : - the Class < ? > to generate */
public synchronized void generateSchema ( final Class < ? > iClass , ODatabaseDocument database ) { } }

implementation:
if ( iClass == null || iClass . isInterface ( ) || iClass . isPrimitive ( ) || iClass . isEnum ( ) || iClass . isAnonymousClass ( ) ) return ; OObjectEntitySerializer . registerClass ( iClass ) ; OClass schema = database . getMetadata ( ) . getSchema ( ) . getClass ( iClass ) ; if ( schema == null ) { generateOClass ( iClass , database ) ; } List < String > fields = OObjectEntitySerializer . getClassFields ( iClass ) ; if ( fields != null ) for ( String field : fields ) { if ( schema . existsProperty ( field ) ) continue ; if ( OObjectEntitySerializer . isVersionField ( iClass , field ) || OObjectEntitySerializer . isIdField ( iClass , field ) ) continue ; Field f = OObjectEntitySerializer . getField ( field , iClass ) ; if ( f . getType ( ) . equals ( Object . class ) || f . getType ( ) . equals ( ODocument . class ) || OBlob . class . isAssignableFrom ( f . getType ( ) ) ) { continue ; } OType t = OObjectEntitySerializer . getTypeByClass ( iClass , field , f ) ; if ( t == OType . CUSTOM ) { OEntityManager entityManager = OEntityManager . getEntityManagerByDatabaseURL ( database . getURL ( ) ) ; // if the target type is registered as entity , it should be linked instead of custom / serialized
if ( entityManager . getEntityClass ( f . getType ( ) . getSimpleName ( ) ) != null ) { t = OType . LINK ; } } if ( t == null ) { if ( f . getType ( ) . isEnum ( ) ) t = OType . STRING ; else { t = OType . LINK ; } } switch ( t ) { case LINK : Class < ? > linkedClazz = OObjectEntitySerializer . getSpecifiedLinkedType ( f ) ; if ( linkedClazz == null ) linkedClazz = f . getType ( ) ; generateLinkProperty ( database , schema , field , t , linkedClazz ) ; break ; case LINKLIST : case LINKMAP : case LINKSET : linkedClazz = OObjectEntitySerializer . getSpecifiedMultiLinkedType ( f ) ; if ( linkedClazz == null ) linkedClazz = OReflectionHelper . getGenericMultivalueType ( f ) ; if ( linkedClazz != null ) generateLinkProperty ( database , schema , field , t , linkedClazz ) ; break ; case EMBEDDED : linkedClazz = f . getType ( ) ; if ( linkedClazz == null || linkedClazz . equals ( Object . class ) || linkedClazz . equals ( ODocument . class ) || OBlob . class . isAssignableFrom ( f . getType ( ) ) ) { continue ; } else { generateLinkProperty ( database , schema , field , t , linkedClazz ) ; } break ; case EMBEDDEDLIST : case EMBEDDEDSET : case EMBEDDEDMAP : linkedClazz = OReflectionHelper . getGenericMultivalueType ( f ) ; if ( linkedClazz == null || linkedClazz . equals ( Object . class ) || linkedClazz . equals ( ODocument . class ) || OBlob . class . isAssignableFrom ( f . getType ( ) ) ) { continue ; } else { if ( OReflectionHelper . isJavaType ( linkedClazz ) ) { schema . createProperty ( field , t , OType . getTypeByClass ( linkedClazz ) ) ; } else if ( linkedClazz . isEnum ( ) ) { schema . createProperty ( field , t , OType . STRING ) ; } else { generateLinkProperty ( database , schema , field , t , linkedClazz ) ; } } break ; default : schema . createProperty ( field , t ) ; break ; } }


signature:
public class OSchemaProxyObject { /** * Checks if all registered entities has schema generated , if not it generates it */
public synchronized void synchronizeSchema ( ) { } }

implementation:
OObjectDatabaseTx database = ( ( OObjectDatabaseTx ) ODatabaseRecordThreadLocal . instance ( ) . get ( ) . getDatabaseOwner ( ) ) ; Collection < Class < ? > > registeredEntities = database . getEntityManager ( ) . getRegisteredEntities ( ) ; boolean automaticSchemaGeneration = database . isAutomaticSchemaGeneration ( ) ; boolean reloadSchema = false ; for ( Class < ? > iClass : registeredEntities ) { if ( Proxy . class . isAssignableFrom ( iClass ) || iClass . isEnum ( ) || OReflectionHelper . isJavaType ( iClass ) || iClass . isAnonymousClass ( ) ) return ; if ( ! database . getMetadata ( ) . getSchema ( ) . existsClass ( iClass . getSimpleName ( ) ) ) { database . getMetadata ( ) . getSchema ( ) . createClass ( iClass . getSimpleName ( ) ) ; reloadSchema = true ; } for ( Class < ? > currentClass = iClass ; currentClass != Object . class ; ) { if ( automaticSchemaGeneration && ! currentClass . equals ( Object . class ) && ! currentClass . equals ( ODocument . class ) ) { ( ( OSchemaProxyObject ) database . getMetadata ( ) . getSchema ( ) ) . generateSchema ( currentClass , database . getUnderlying ( ) ) ; } String iClassName = currentClass . getSimpleName ( ) ; currentClass = currentClass . getSuperclass ( ) ; if ( currentClass == null || currentClass . equals ( ODocument . class ) ) // POJO EXTENDS ODOCUMENT : SPECIAL CASE : AVOID TO CONSIDER
// ODOCUMENT FIELDS
currentClass = Object . class ; if ( database != null && ! database . isClosed ( ) && ! currentClass . equals ( Object . class ) ) { OClass oSuperClass ; OClass currentOClass = database . getMetadata ( ) . getSchema ( ) . getClass ( iClassName ) ; if ( ! database . getMetadata ( ) . getSchema ( ) . existsClass ( currentClass . getSimpleName ( ) ) ) { oSuperClass = database . getMetadata ( ) . getSchema ( ) . createClass ( currentClass . getSimpleName ( ) ) ; reloadSchema = true ; } else { oSuperClass = database . getMetadata ( ) . getSchema ( ) . getClass ( currentClass . getSimpleName ( ) ) ; reloadSchema = true ; } if ( ! currentOClass . getSuperClasses ( ) . contains ( oSuperClass ) ) { currentOClass . setSuperClasses ( Arrays . asList ( oSuperClass ) ) ; reloadSchema = true ; } } } } if ( database != null && ! database . isClosed ( ) && reloadSchema ) { database . getMetadata ( ) . getSchema ( ) . reload ( ) ; }


signature:
public class OAbstractProfiler { /** * Updates the metric metadata . */
protected void updateMetadata ( final String iName , final String iDescription , final METRIC_TYPE iType ) { } }

implementation: if ( iDescription != null && dictionary . putIfAbsent ( iName , iDescription ) == null ) types . put ( iName , iType ) ;


signature:
public class ORecordIteratorClusters { /** * Return the element at the current position and move forward the cursor to the next position available .
 * @ return the next record found , otherwise the NoSuchElementException exception is thrown when no more records are found . */
@ SuppressWarnings ( "unchecked" ) public REC next ( ) { } }

implementation:
checkDirection ( true ) ; if ( currentRecord != null ) try { // RETURN LAST LOADED RECORD
return ( REC ) currentRecord ; } finally { currentRecord = null ; } ORecord record ; // MOVE FORWARD IN THE CURRENT CLUSTER
while ( hasNext ( ) ) { if ( currentRecord != null ) try { // RETURN LAST LOADED RECORD
return ( REC ) currentRecord ; } finally { currentRecord = null ; } record = getTransactionEntry ( ) ; if ( record == null ) record = readCurrentRecord ( null , + 1 ) ; if ( record != null ) // FOUND
if ( include ( record ) ) return ( REC ) record ; } record = getTransactionEntry ( ) ; if ( record != null ) return ( REC ) record ; throw new NoSuchElementException ( "Direction: forward, last position was: " + current + ", range: " + beginRange + "-" + endRange ) ;


signature:
public class ORecordIteratorClusters { /** * Return the element at the current position and move backward the cursor to the previous position available .
 * @ return the previous record found , otherwise the NoSuchElementException exception is thrown when no more records are found . */
@ SuppressWarnings ( "unchecked" ) @ Override public REC previous ( ) { } }

implementation:
checkDirection ( false ) ; if ( currentRecord != null ) try { // RETURN LAST LOADED RECORD
return ( REC ) currentRecord ; } finally { currentRecord = null ; } ORecord record = getRecord ( ) ; // MOVE BACKWARD IN THE CURRENT CLUSTER
while ( hasPrevious ( ) ) { if ( currentRecord != null ) try { // RETURN LAST LOADED RECORD
return ( REC ) currentRecord ; } finally { currentRecord = null ; } record = getTransactionEntry ( ) ; if ( record == null ) record = readCurrentRecord ( null , - 1 ) ; if ( record != null ) // FOUND
if ( include ( record ) ) return ( REC ) record ; } record = getTransactionEntry ( ) ; if ( record != null ) return ( REC ) record ; return null ;


signature:
public class ORecordIteratorClusters { /** * Move the iterator to the begin of the range . If no range was specified move to the first record of the cluster .
 * @ return The object itself */
@ Override public ORecordIteratorClusters < REC > begin ( ) { } }

implementation: if ( clusterIds . length == 0 ) return this ; browsedRecords = 0 ; currentClusterIdx = 0 ; current . setClusterId ( clusterIds [ currentClusterIdx ] ) ; updateClusterRange ( ) ; resetCurrentPosition ( ) ; nextPosition ( ) ; final ORecord record = getRecord ( ) ; currentRecord = readCurrentRecord ( record , 0 ) ; if ( currentRecord != null && ! include ( currentRecord ) ) { currentRecord = null ; hasNext ( ) ; } return this ;


signature:
public class ORecordIteratorClusters { /** * Move the iterator to the end of the range . If no range was specified move to the last record of the cluster .
 * @ return The object itself */
@ Override public ORecordIteratorClusters < REC > last ( ) { } }

implementation: if ( clusterIds . length == 0 ) return this ; browsedRecords = 0 ; currentClusterIdx = clusterIds . length - 1 ; updateClusterRange ( ) ; current . setClusterId ( clusterIds [ currentClusterIdx ] ) ; resetCurrentPosition ( ) ; prevPosition ( ) ; final ORecord record = getRecord ( ) ; currentRecord = readCurrentRecord ( record , 0 ) ; if ( currentRecord != null && ! include ( currentRecord ) ) { currentRecord = null ; hasPrevious ( ) ; } return this ;


signature:
public class ORecordIteratorClusters { /** * Tell to the iterator that the upper limit must be checked at every cycle . Useful when concurrent deletes or additions change
 * the size of the cluster while you ' re browsing it . Default is false .
 * @ param iLiveUpdated True to activate it , otherwise false ( default )
 * @ see # isLiveUpdated ( ) */
@ Override public ORecordIteratorClusters < REC > setLiveUpdated ( boolean iLiveUpdated ) { } }

implementation: super . setLiveUpdated ( iLiveUpdated ) ; if ( iLiveUpdated ) { firstClusterEntry = 0 ; lastClusterEntry = Long . MAX_VALUE ; } else { updateClusterRange ( ) ; } return this ;


signature:
public class OCommandExecutorSQLCreateEdge { /** * Execute the command and return the ODocument object created . */
public Object execute ( final Map < Object , Object > iArgs ) { } }

implementation:
if ( clazz == null ) throw new OCommandExecutionException ( "Cannot execute the command because it has not been parsed yet" ) ; return OGraphCommandExecutorSQLFactory . runInConfiguredTxMode ( new OGraphCommandExecutorSQLFactory . GraphCallBack < List < Object > > ( ) { @ Override public List < Object > call ( OrientBaseGraph graph ) { final Set < OIdentifiable > fromIds = OSQLEngine . getInstance ( ) . parseRIDTarget ( graph . getRawGraph ( ) , from , context , iArgs ) ; final Set < OIdentifiable > toIds = OSQLEngine . getInstance ( ) . parseRIDTarget ( graph . getRawGraph ( ) , to , context , iArgs ) ; // CREATE EDGES
final List < Object > edges = new ArrayList < Object > ( ) ; for ( OIdentifiable from : fromIds ) { final OrientVertex fromVertex = graph . getVertex ( from ) ; if ( fromVertex == null ) throw new OCommandExecutionException ( "Source vertex '" + from + "' not exists" ) ; for ( OIdentifiable to : toIds ) { final OrientVertex toVertex ; if ( from . equals ( to ) ) { toVertex = fromVertex ; } else { toVertex = graph . getVertex ( to ) ; } if ( fields != null ) // EVALUATE FIELDS
for ( final OPair < String , Object > f : fields ) { if ( f . getValue ( ) instanceof OSQLFunctionRuntime ) { f . setValue ( ( ( OSQLFunctionRuntime ) f . getValue ( ) ) . getValue ( to , null , context ) ) ; } else if ( f . getValue ( ) instanceof OSQLFilterItem ) { f . setValue ( ( ( OSQLFilterItem ) f . getValue ( ) ) . getValue ( to , null , context ) ) ; } } OrientEdge edge = null ; if ( content != null ) { if ( fields != null ) // MERGE CONTENT WITH FIELDS
fields . addAll ( OPair . convertFromMap ( content . toMap ( ) ) ) ; else fields = OPair . convertFromMap ( content . toMap ( ) ) ; } edge = fromVertex . addEdge ( null , toVertex , edgeLabel , clusterName , fields ) ; if ( fields != null && ! fields . isEmpty ( ) ) { if ( edge . isLightweight ( ) ) edge . convertToDocument ( ) ; OSQLHelper . bindParameters ( edge . getRecord ( ) , fields , new OCommandParameters ( iArgs ) , context ) ; } edge . save ( clusterName ) ; edges . add ( edge ) ; if ( batch > 0 && edges . size ( ) % batch == 0 ) { graph . commit ( ) ; graph . begin ( ) ; } } } if ( edges . isEmpty ( ) ) { if ( fromIds . isEmpty ( ) ) throw new OCommandExecutionException ( "No edge has been created because no source vertices" ) ; else if ( toIds . isEmpty ( ) ) throw new OCommandExecutionException ( "No edge has been created because no target vertices" ) ; throw new OCommandExecutionException ( "No edge has been created between " + fromIds + " and " + toIds ) ; } return edges ; } } ) ;


signature:
public class OJSONReader { /** * Returns the next character from the input stream . Handles Unicode decoding . */
public int nextChar ( ) throws IOException { } }

implementation:
if ( missedChar != null ) { // RETURNS THE PREVIOUS PARSED CHAR
c = missedChar . charValue ( ) ; missedChar = null ; } else { int read = in . read ( ) ; if ( read == - 1 ) return - 1 ; c = ( char ) read ; if ( c == '\\' ) { read = in . read ( ) ; if ( read == - 1 ) return - 1 ; char c2 = ( char ) read ; if ( c2 == 'u' ) { // DECODE UNICODE CHAR
final StringBuilder buff = new StringBuilder ( 8 ) ; for ( int i = 0 ; i < 4 ; ++ i ) { read = in . read ( ) ; if ( read == - 1 ) return - 1 ; buff . append ( ( char ) read ) ; } cursor += 6 ; return ( char ) Integer . parseInt ( buff . toString ( ) , 16 ) ; } else { // REMEMBER THE CURRENT CHAR TO RETURN NEXT TIME
missedChar = c2 ; } } } cursor ++ ; if ( c == NEW_LINE ) { ++ lineNumber ; columnNumber = 0 ; } else ++ columnNumber ; return ( char ) c ;


signature:
public class OCommandExecutorSQLFindReferences { /** * Execute the FIND REFERENCES . */
public Object execute ( final Map < Object , Object > iArgs ) { } }

implementation: if ( recordIds . isEmpty ( ) && subQuery == null ) throw new OCommandExecutionException ( "Cannot execute the command because it has not been parsed yet" ) ; if ( subQuery != null ) { final List < OIdentifiable > result = new OCommandSQL ( subQuery . toString ( ) ) . execute ( ) ; for ( OIdentifiable id : result ) recordIds . add ( id . getIdentity ( ) ) ; } return OFindReferenceHelper . findReferences ( recordIds , classList ) ;


signature:
public class ONetworkBinaryProtocolFactory { /** * Legacy Protocol < 37
 * @ param requestType
 * @ return */
private static OBinaryRequest < ? extends OBinaryResponse > createRequest ( int requestType ) { } }

implementation: switch ( requestType ) { case OChannelBinaryProtocol . REQUEST_DB_OPEN : return new OOpenRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CONNECT : return new OConnectRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_REOPEN : return new OReopenRequest ( ) ; case OChannelBinaryProtocol . REQUEST_SHUTDOWN : return new OShutdownRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_LIST : return new OListDatabasesRequest ( ) ; case OChannelBinaryProtocol . REQUEST_SERVER_INFO : return new OServerInfoRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_RELOAD : return new OReloadRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_CREATE : return new OCreateDatabaseRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_CLOSE : return new OCloseRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_EXIST : return new OExistsDatabaseRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_DROP : return new ODropDatabaseRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_SIZE : return new OGetSizeRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_COUNTRECORDS : return new OCountRecordsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CLUSTER : return new ODistributedStatusRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CLUSTER_COUNT : return new OCountRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CLUSTER_DATARANGE : return new OGetClusterDataRangeRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CLUSTER_ADD : return new OAddClusterRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CLUSTER_DROP : return new ODropClusterRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_METADATA : return new OGetRecordMetadataRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_LOAD : return new OReadRecordRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_LOAD_IF_VERSION_NOT_LATEST : return new OReadRecordIfVersionIsNotLatestRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_CREATE : return new OCreateRecordRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_UPDATE : return new OUpdateRecordRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_DELETE : return new ODeleteRecordRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_HIDE : return new OHideRecordRequest ( ) ; case OChannelBinaryProtocol . REQUEST_POSITIONS_HIGHER : return new OHigherPhysicalPositionsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_POSITIONS_CEILING : return new OCeilingPhysicalPositionsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_POSITIONS_LOWER : return new OLowerPhysicalPositionsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_POSITIONS_FLOOR : return new OFloorPhysicalPositionsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_COMMAND : return new OCommandRequest ( ) ; case OChannelBinaryProtocol . REQUEST_QUERY : return new OQueryRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CLOSE_QUERY : return new OCloseQueryRequest ( ) ; case OChannelBinaryProtocol . REQUEST_QUERY_NEXT_PAGE : return new OQueryNextPageRequest ( ) ; case OChannelBinaryProtocol . REQUEST_TX_COMMIT : return new OCommitRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CONFIG_GET : return new OGetGlobalConfigurationRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CONFIG_SET : return new OSetGlobalConfigurationRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CONFIG_LIST : return new OListGlobalConfigurationsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_FREEZE : return new OFreezeDatabaseRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_RELEASE : return new OReleaseDatabaseRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_CLEAN_OUT : return new OCleanOutRecordRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CREATE_SBTREE_BONSAI : return new OSBTCreateTreeRequest ( ) ; case OChannelBinaryProtocol . REQUEST_SBTREE_BONSAI_GET : return new OSBTGetRequest ( ) ; case OChannelBinaryProtocol . REQUEST_SBTREE_BONSAI_FIRST_KEY : return new OSBTFirstKeyRequest ( ) ; case OChannelBinaryProtocol . REQUEST_SBTREE_BONSAI_GET_ENTRIES_MAJOR : return new OSBTFetchEntriesMajorRequest < > ( ) ; case OChannelBinaryProtocol . REQUEST_RIDBAG_GET_SIZE : return new OSBTGetRealBagSizeRequest ( ) ; case OChannelBinaryProtocol . REQUEST_INCREMENTAL_BACKUP : return new OIncrementalBackupRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_IMPORT : return new OImportRequest ( ) ; case OChannelBinaryProtocol . DISTRIBUTED_CONNECT : return new ODistributedConnectRequest ( ) ; default : throw new ODatabaseException ( "binary protocol command with code: " + requestType ) ; }


signature:
public class ONetworkBinaryProtocolFactory { /** * Protocol 37
 * @ param requestType
 * @ return */
public static OBinaryRequest < ? extends OBinaryResponse > createRequest37 ( int requestType ) { } }

implementation: switch ( requestType ) { case OChannelBinaryProtocol . SUBSCRIBE_PUSH : return new OSubscribeRequest ( ) ; case OChannelBinaryProtocol . EXPERIMENTAL : return new OExperimentalRequest ( ) ; case OChannelBinaryProtocol . UNSUBSCRIBE_PUSH : return new OUnsubscribeRequest ( ) ; case OChannelBinaryProtocol . REQUEST_TX_FETCH : return new OFetchTransactionRequest ( ) ; case OChannelBinaryProtocol . REQUEST_TX_REBEGIN : return new ORebeginTransactionRequest ( ) ; case OChannelBinaryProtocol . REQUEST_TX_BEGIN : return new OBeginTransactionRequest ( ) ; case OChannelBinaryProtocol . REQUEST_TX_COMMIT : return new OCommit37Request ( ) ; case OChannelBinaryProtocol . REQUEST_TX_ROLLBACK : return new ORollbackTransactionRequest ( ) ; case OChannelBinaryProtocol . REQUEST_BATCH_OPERATIONS : return new OBatchOperationsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_OPEN : return new OOpen37Request ( ) ; case OChannelBinaryProtocol . REQUEST_CONNECT : return new OConnect37Request ( ) ; case OChannelBinaryProtocol . REQUEST_DB_REOPEN : return new OReopenRequest ( ) ; case OChannelBinaryProtocol . REQUEST_SHUTDOWN : return new OShutdownRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_LIST : return new OListDatabasesRequest ( ) ; case OChannelBinaryProtocol . REQUEST_SERVER_INFO : return new OServerInfoRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_RELOAD : return new OReloadRequest37 ( ) ; case OChannelBinaryProtocol . REQUEST_DB_CREATE : return new OCreateDatabaseRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_CLOSE : return new OCloseRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_EXIST : return new OExistsDatabaseRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_DROP : return new ODropDatabaseRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_SIZE : return new OGetSizeRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_COUNTRECORDS : return new OCountRecordsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CLUSTER : return new ODistributedStatusRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CLUSTER_COUNT : return new OCountRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CLUSTER_DATARANGE : return new OGetClusterDataRangeRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CLUSTER_ADD : return new OAddClusterRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CLUSTER_DROP : return new ODropClusterRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_METADATA : return new OGetRecordMetadataRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_LOAD : return new OReadRecordRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_LOAD_IF_VERSION_NOT_LATEST : return new OReadRecordIfVersionIsNotLatestRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_CREATE : return new OCreateRecordRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_UPDATE : return new OUpdateRecordRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_DELETE : return new ODeleteRecordRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_HIDE : return new OHideRecordRequest ( ) ; case OChannelBinaryProtocol . REQUEST_POSITIONS_HIGHER : return new OHigherPhysicalPositionsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_POSITIONS_CEILING : return new OCeilingPhysicalPositionsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_POSITIONS_LOWER : return new OLowerPhysicalPositionsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_POSITIONS_FLOOR : return new OFloorPhysicalPositionsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_COMMAND : return new OCommandRequest ( ) ; case OChannelBinaryProtocol . REQUEST_QUERY : return new OQueryRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CLOSE_QUERY : return new OCloseQueryRequest ( ) ; case OChannelBinaryProtocol . REQUEST_QUERY_NEXT_PAGE : return new OQueryNextPageRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CONFIG_GET : return new OGetGlobalConfigurationRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CONFIG_SET : return new OSetGlobalConfigurationRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CONFIG_LIST : return new OListGlobalConfigurationsRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_FREEZE : return new OFreezeDatabaseRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_RELEASE : return new OReleaseDatabaseRequest ( ) ; case OChannelBinaryProtocol . REQUEST_RECORD_CLEAN_OUT : return new OCleanOutRecordRequest ( ) ; case OChannelBinaryProtocol . REQUEST_CREATE_SBTREE_BONSAI : return new OSBTCreateTreeRequest ( ) ; case OChannelBinaryProtocol . REQUEST_SBTREE_BONSAI_GET : return new OSBTGetRequest ( ) ; case OChannelBinaryProtocol . REQUEST_SBTREE_BONSAI_FIRST_KEY : return new OSBTFirstKeyRequest ( ) ; case OChannelBinaryProtocol . REQUEST_SBTREE_BONSAI_GET_ENTRIES_MAJOR : return new OSBTFetchEntriesMajorRequest < > ( ) ; case OChannelBinaryProtocol . REQUEST_RIDBAG_GET_SIZE : return new OSBTGetRealBagSizeRequest ( ) ; case OChannelBinaryProtocol . REQUEST_INCREMENTAL_BACKUP : return new OIncrementalBackupRequest ( ) ; case OChannelBinaryProtocol . REQUEST_DB_IMPORT : return new OImportRequest ( ) ; case OChannelBinaryProtocol . DISTRIBUTED_CONNECT : return new ODistributedConnectRequest ( ) ; default : throw new ODatabaseException ( "binary protocol command with code: " + requestType + " for protocol version 37" ) ; }


signature:
public class OSQLHelper { /** * Convert fields from text to real value . Supports : String , RID , Boolean , Float , Integer and NULL .
 * @ param iValue Value to convert .
 * @ return The value converted if recognized , otherwise VALUE _ NOT _ PARSED */
public static Object parseValue ( String iValue , final OCommandContext iContext ) { } }

implementation: return parseValue ( iValue , iContext , false ) ;


signature:
public class OCommandRequestAbstract { /** * Defines a callback to call in case of error during the asynchronous replication . */
@ Override public OCommandRequestAbstract onAsyncReplicationError ( final OAsyncReplicationError iCallback ) { } }

implementation: if ( iCallback != null ) { onAsyncReplicationError = new OAsyncReplicationError ( ) { int retry = 0 ; @ Override public ACTION onAsyncReplicationError ( Throwable iException , final int iRetry ) { switch ( iCallback . onAsyncReplicationError ( iException , ++ retry ) ) { case RETRY : execute ( ) ; break ; case IGNORE : } return ACTION . IGNORE ; } } ; } else onAsyncReplicationError = null ; return this ;


signature:
public class OCompressionFactory { /** * Registers a stateless implementations , the same instance will be shared on all the storages .
 * @ param compression Compression class */
public void register ( final Class < ? extends OCompression > compression ) { } }

implementation: try { final OCompression tempInstance = compression . newInstance ( ) ; final String name = tempInstance . name ( ) ; if ( compressions . containsKey ( name ) ) throw new IllegalArgumentException ( "Compression with name '" + name + "' was already registered" ) ; if ( compressionClasses . containsKey ( tempInstance . name ( ) ) ) throw new IllegalArgumentException ( "Compression with name '" + name + "' was already registered" ) ; compressionClasses . put ( name , compression ) ; } catch ( Exception e ) { OLogManager . instance ( ) . error ( this , "Cannot register storage compression algorithm '%s'" , e , compression ) ; }


signature:
public class ONative { /** * Detects limit of limit of open files .
 * @ param recommended recommended value of limit of open files .
 * @ param defLimit default value for limit of open files .
 * @ return limit of open files , available for the system . */
public int getOpenFilesLimit ( boolean verbose , int recommended , int defLimit ) { } }

implementation: if ( Platform . isLinux ( ) ) { final OCLibrary . Rlimit rlimit = new OCLibrary . Rlimit ( ) ; final int result = C_LIBRARY . getrlimit ( OCLibrary . RLIMIT_NOFILE , rlimit ) ; if ( result == 0 && rlimit . rlim_cur > 0 ) { if ( verbose ) { OLogManager . instance ( ) . infoNoDb ( this , "Detected limit of amount of simultaneously open files is %d, " + " limit of open files for disk cache will be set to %d" , rlimit . rlim_cur , rlimit . rlim_cur / 2 - 512 ) ; } if ( rlimit . rlim_cur < recommended ) { OLogManager . instance ( ) . warnNoDb ( this , "Value of limit of simultaneously open files is too small, recommended value is %d" , recommended ) ; } return ( int ) rlimit . rlim_cur / 2 - 512 ; } else { if ( verbose ) { OLogManager . instance ( ) . infoNoDb ( this , "Can not detect value of limit of open files." ) ; } } } else if ( Platform . isWindows ( ) ) { if ( verbose ) { OLogManager . instance ( ) . infoNoDb ( this , "Windows OS is detected, %d limit of open files will be set for the disk cache." , recommended ) ; } return recommended ; } if ( verbose ) { OLogManager . instance ( ) . infoNoDb ( this , "Default limit of open files (%d) will be used." , defLimit ) ; } return defLimit ;


signature:
public class ONative { /** * @ param printSteps Print all steps of discovering of memory limit in the log with { @ code INFO } level .
 * @ return Amount of memory which are allowed to be consumed by application , and detects whether OrientDB instance is running
 * inside container . If < code > null < / code > is returned then it was impossible to detect amount of memory on machine . */
public MemoryLimitResult getMemoryLimit ( final boolean printSteps ) { } }

implementation:
// Perform several steps here :
// 1 . Fetch physical size available on machine
// 2 . Fetch soft limit
// 3 . Fetch cgroup soft limit
// 4 . Fetch cgroup hard limit
// 5 . Return the minimal value from the list of results
long memoryLimit = getPhysicalMemorySize ( ) ; boolean insideContainer = false ; if ( printSteps ) { OLogManager . instance ( ) . infoNoDb ( this , "%d B/%d MB/%d GB of physical memory were detected on machine" , memoryLimit , convertToMB ( memoryLimit ) , convertToGB ( memoryLimit ) ) ; } if ( Platform . isLinux ( ) ) { final OCLibrary . Rlimit rlimit = new OCLibrary . Rlimit ( ) ; final int result = C_LIBRARY . getrlimit ( OCLibrary . RLIMIT_AS , rlimit ) ; // no errors during the call
if ( result == 0 ) { if ( printSteps ) OLogManager . instance ( ) . infoNoDb ( this , "Soft memory limit for this process is set to %d B/%d MB/%d GB" , rlimit . rlim_cur , convertToMB ( rlimit . rlim_cur ) , convertToGB ( rlimit . rlim_cur ) ) ; memoryLimit = updateMemoryLimit ( memoryLimit , rlimit . rlim_cur ) ; if ( printSteps ) OLogManager . instance ( ) . infoNoDb ( this , "Hard memory limit for this process is set to %d B/%d MB/%d GB" , rlimit . rlim_max , convertToMB ( rlimit . rlim_max ) , convertToGB ( rlimit . rlim_max ) ) ; memoryLimit = updateMemoryLimit ( memoryLimit , rlimit . rlim_max ) ; } final String memoryCGroupPath = findMemoryGCGroupPath ( ) ; if ( memoryCGroupPath != null ) { if ( printSteps ) OLogManager . instance ( ) . infoNoDb ( this , "Path to 'memory' cgroup is '%s'" , memoryCGroupPath ) ; final String memoryCGroupRoot = findMemoryGCRoot ( ) ; if ( printSteps ) OLogManager . instance ( ) . infoNoDb ( this , "Mounting path for memory cgroup controller is '%s'" , memoryCGroupRoot ) ; File memoryCGroup = new File ( memoryCGroupRoot , memoryCGroupPath ) ; if ( ! memoryCGroup . exists ( ) ) { if ( printSteps ) OLogManager . instance ( ) . infoNoDb ( this , "Can not find '%s' path for memory cgroup, it is supposed that " + "process is running in container, will try to read root '%s' memory cgroup data" , memoryCGroup , memoryCGroupRoot ) ; memoryCGroup = new File ( memoryCGroupRoot ) ; insideContainer = true ; } final long softMemoryLimit = fetchCGroupSoftMemoryLimit ( memoryCGroup , printSteps ) ; memoryLimit = updateMemoryLimit ( memoryLimit , softMemoryLimit ) ; final long hardMemoryLimit = fetchCGroupHardMemoryLimit ( memoryCGroup , printSteps ) ; memoryLimit = updateMemoryLimit ( memoryLimit , hardMemoryLimit ) ; } } if ( printSteps ) { if ( memoryLimit > 0 ) OLogManager . instance ( ) . infoNoDb ( this , "Detected memory limit for current process is %d B/%d MB/%d GB" , memoryLimit , convertToMB ( memoryLimit ) , convertToGB ( memoryLimit ) ) ; else OLogManager . instance ( ) . infoNoDb ( this , "Memory limit for current process is not set" ) ; } if ( memoryLimit <= 0 ) return null ; return new MemoryLimitResult ( memoryLimit , insideContainer ) ;


signature:
public class ONative { /** * Obtains the total size in bytes of the installed physical memory on this machine . Note that on some VMs it ' s impossible to
 * obtain the physical memory size , in this case the return value will { @ code - 1 } .
 * @ return the total physical memory size in bytes or { @ code < = 0 } if the size can ' t be obtained . */
private long getPhysicalMemorySize ( ) { } }

implementation: long osMemory = - 1 ; try { final MBeanServer mBeanServer = ManagementFactory . getPlatformMBeanServer ( ) ; final Object attribute = mBeanServer . getAttribute ( new ObjectName ( "java.lang" , "type" , "OperatingSystem" ) , "TotalPhysicalMemorySize" ) ; if ( attribute != null ) { if ( attribute instanceof Long ) { osMemory = ( Long ) attribute ; } else { try { osMemory = Long . parseLong ( attribute . toString ( ) ) ; } catch ( final NumberFormatException e ) { if ( ! OLogManager . instance ( ) . isDebugEnabled ( ) ) OLogManager . instance ( ) . warnNoDb ( OMemory . class , "Unable to determine the amount of installed RAM." ) ; else OLogManager . instance ( ) . debugNoDb ( OMemory . class , "Unable to determine the amount of installed RAM." , e ) ; } } } else { if ( ! OLogManager . instance ( ) . isDebugEnabled ( ) ) OLogManager . instance ( ) . warnNoDb ( OMemory . class , "Unable to determine the amount of installed RAM." ) ; } } catch ( MalformedObjectNameException | AttributeNotFoundException | InstanceNotFoundException | MBeanException | ReflectionException e ) { if ( ! OLogManager . instance ( ) . isDebugEnabled ( ) ) OLogManager . instance ( ) . warnNoDb ( OMemory . class , "Unable to determine the amount of installed RAM." ) ; else OLogManager . instance ( ) . debugNoDb ( OMemory . class , "Unable to determine the amount of installed RAM." , e ) ; } catch ( final RuntimeException e ) { OLogManager . instance ( ) . warnNoDb ( OMemory . class , "Unable to determine the amount of installed RAM." , e ) ; } return osMemory ;


signature:
public class OMathExpression { /** * tests if current expression is an indexed function AND that function can be used on this target
 * @ param target the query target
 * @ param context the execution context
 * @ return true if current expression is an indexed function AND that function can be used on this target , false otherwise */
public boolean allowsIndexedFunctionExecutionOnTarget ( OFromClause target , OCommandContext context , OBinaryCompareOperator operator , Object right ) { } }

implementation: if ( this . childExpressions . size ( ) != 1 ) { return false ; } return this . childExpressions . get ( 0 ) . allowsIndexedFunctionExecutionOnTarget ( target , context , operator , right ) ;


signature:
public class OCommandExecutorSQLCreateVertex { /** * Execute the command and return the ODocument object created . */
public Object execute ( final Map < Object , Object > iArgs ) { } }

implementation:
if ( clazz == null ) throw new OCommandExecutionException ( "Cannot execute the command because it has not been parsed yet" ) ; // CREATE VERTEX DOES NOT HAVE TO BE IN TX
return OGraphCommandExecutorSQLFactory . runWithAnyGraph ( new OGraphCommandExecutorSQLFactory . GraphCallBack < Object > ( ) { @ Override public Object call ( final OrientBaseGraph graph ) { final OrientVertex vertex = graph . addTemporaryVertex ( clazz . getName ( ) ) ; if ( fields != null ) // EVALUATE FIELDS
for ( final OPair < String , Object > f : fields ) { if ( f . getValue ( ) instanceof OSQLFunctionRuntime ) f . setValue ( ( ( OSQLFunctionRuntime ) f . getValue ( ) ) . getValue ( vertex . getRecord ( ) , null , context ) ) ; } OSQLHelper . bindParameters ( vertex . getRecord ( ) , fields , new OCommandParameters ( iArgs ) , context ) ; if ( content != null ) vertex . getRecord ( ) . merge ( content , true , false ) ; if ( clusterName != null ) vertex . save ( clusterName ) ; else vertex . save ( ) ; return vertex . getRecord ( ) ; } } ) ;


signature: public class HelperClasses { public static void writeOType ( BytesContainer bytes , int pos , OType type ) { } }

implementation: bytes . bytes [ pos ] = ( byte ) type . getId ( ) ;


signature:
public class OMemoryStream { /** * Move bytes left or right of an offset .
 * @ param iFrom Starting position
 * @ param iPosition Offset to the iFrom value : positive values mean move right , otherwise move left */
public void move ( final int iFrom , final int iPosition ) { } }

implementation: if ( iPosition == 0 ) return ; final int to = iFrom + iPosition ; final int size = iPosition > 0 ? buffer . length - to : buffer . length - iFrom ; System . arraycopy ( buffer , iFrom , buffer , to , size ) ;


signature:
public class OMemoryStream { /** * Returns the used buffer as byte [ ] .
 * @ return [ result . length = size ( ) ] */
public final byte [ ] toByteArray ( ) { } }

implementation:
if ( position == buffer . length - 1 ) // 100 % USED , RETURN THE FULL BUFFER
return buffer ; final int pos = position ; final byte [ ] destinBuffer = new byte [ pos ] ; final byte [ ] sourceBuffer = buffer ; if ( pos < NATIVE_COPY_THRESHOLD ) for ( int i = 0 ; i < pos ; ++ i ) destinBuffer [ i ] = sourceBuffer [ i ] ; else System . arraycopy ( sourceBuffer , 0 , destinBuffer , 0 , pos ) ; return destinBuffer ;


signature:
public class OMemoryStream { /** * Append byte [ ] to the stream .
 * @ param iContent
 * @ return The begin offset of the appended content
 * @ throws IOException */
public int set ( final byte [ ] iContent ) { } }

implementation: if ( iContent == null ) return - 1 ; final int begin = position ; assureSpaceFor ( OBinaryProtocol . SIZE_INT + iContent . length ) ; OBinaryProtocol . int2bytes ( iContent . length , buffer , position ) ; position += OBinaryProtocol . SIZE_INT ; write ( iContent , 0 , iContent . length ) ; return begin ;


signature:
public class OMemoryStream { /** * Fills the stream from current position writing iLength times the iFiller byte
 * @ param iLength Bytes to jump
 * @ param iFiller Byte to use to fill the space */
public void fill ( final int iLength , final byte iFiller ) { } }

implementation: assureSpaceFor ( iLength ) ; Arrays . fill ( buffer , position , position + iLength , iFiller ) ; position += iLength ;


signature:
public class OScriptExecutionPlan { /** * executes all the script and returns last statement execution step , so that it can be executed from outside
 * @ return */
public OExecutionStepInternal executeUntilReturn ( ) { } }

implementation: if ( steps . size ( ) > 0 ) { lastStep = steps . get ( steps . size ( ) - 1 ) ; } for ( int i = 0 ; i < steps . size ( ) - 1 ; i ++ ) { ScriptLineStep step = steps . get ( i ) ; if ( step . containsReturn ( ) ) { OExecutionStepInternal returnStep = step . executeUntilReturn ( ctx ) ; if ( returnStep != null ) { lastStep = returnStep ; return lastStep ; } } OResultSet lastResult = step . syncPull ( ctx , 100 ) ; while ( lastResult . hasNext ( ) ) { while ( lastResult . hasNext ( ) ) { lastResult . next ( ) ; } lastResult = step . syncPull ( ctx , 100 ) ; } } this . lastStep = steps . get ( steps . size ( ) - 1 ) ; return lastStep ;


signature:
public class OScriptExecutionPlan { /** * executes the whole script and returns last statement ONLY if it ' s a RETURN , otherwise it returns null ;
 * @ return */
public OExecutionStepInternal executeFull ( ) { } }

implementation: for ( int i = 0 ; i < steps . size ( ) ; i ++ ) { ScriptLineStep step = steps . get ( i ) ; if ( step . containsReturn ( ) ) { OExecutionStepInternal returnStep = step . executeUntilReturn ( ctx ) ; if ( returnStep != null ) { return returnStep ; } } OResultSet lastResult = step . syncPull ( ctx , 100 ) ; while ( lastResult . hasNext ( ) ) { while ( lastResult . hasNext ( ) ) { lastResult . next ( ) ; } lastResult = step . syncPull ( ctx , 100 ) ; } } return null ;


signature:
public class OObjectSerializerHelper { /** * Serialize the user POJO to a ORecordDocument instance .
 * @ param iPojo
 * User pojo to serialize
 * @ param iRecord
 * Record where to update
 * @ param iObj2RecHandler */
public static ODocument toStream ( final Object iPojo , final ODocument iRecord , final OEntityManager iEntityManager , final OClass schemaClass , final OUserObject2RecordHandler iObj2RecHandler , final ODatabaseObject db , final boolean iSaveOnlyDirty ) { } }

implementation:
if ( iSaveOnlyDirty && ! iRecord . isDirty ( ) ) return iRecord ; final long timer = Orient . instance ( ) . getProfiler ( ) . startChrono ( ) ; final Integer identityRecord = System . identityHashCode ( iRecord ) ; if ( OSerializationThreadLocal . INSTANCE . get ( ) . contains ( identityRecord ) ) return iRecord ; OSerializationThreadLocal . INSTANCE . get ( ) . add ( identityRecord ) ; OProperty schemaProperty ; final Class < ? > pojoClass = iPojo . getClass ( ) ; final List < Field > properties = getClassFields ( pojoClass ) ; // CHECK FOR ID BINDING
final Field idField = fieldIds . get ( pojoClass ) ; if ( idField != null ) { Object id = getFieldValue ( iPojo , idField . getName ( ) ) ; if ( id != null ) { // FOUND
if ( id instanceof ORecordId ) { ORecordInternal . setIdentity ( iRecord , ( ORecordId ) id ) ; } else if ( id instanceof Number ) { // TREATS AS CLUSTER POSITION
( ( ORecordId ) iRecord . getIdentity ( ) ) . setClusterId ( schemaClass . getDefaultClusterId ( ) ) ; ( ( ORecordId ) iRecord . getIdentity ( ) ) . setClusterPosition ( ( ( Number ) id ) . longValue ( ) ) ; } else if ( id instanceof String ) ( ( ORecordId ) iRecord . getIdentity ( ) ) . fromString ( ( String ) id ) ; else if ( id . getClass ( ) . equals ( Object . class ) ) ORecordInternal . setIdentity ( iRecord , ( ORecordId ) id ) ; else OLogManager . instance ( ) . warn ( OObjectSerializerHelper . class , "@Id field has been declared as %s while the supported are: ORID, Number, String, Object" , id . getClass ( ) ) ; } } // CHECK FOR VERSION BINDING
final Field vField = fieldVersions . get ( pojoClass ) ; boolean versionConfigured = false ; if ( vField != null ) { versionConfigured = true ; Object ver = getFieldValue ( iPojo , vField . getName ( ) ) ; final int version = convertVersion ( ver ) ; ORecordInternal . setVersion ( iRecord , version ) ; } if ( db . isMVCC ( ) && ! versionConfigured && db . getTransaction ( ) instanceof OTransactionOptimistic ) throw new OTransactionException ( "Cannot involve an object of class '" + pojoClass + "' in an Optimistic Transaction commit because it does not define @Version or @OVersion and therefore cannot handle MVCC" ) ; // SET OBJECT CLASS
iRecord . setClassName ( schemaClass != null ? schemaClass . getName ( ) : null ) ; String fieldName ; Object fieldValue ; // CALL BEFORE MARSHALLING
invokeCallback ( iPojo , iRecord , OBeforeSerialization . class ) ; for ( Field p : properties ) { fieldName = p . getName ( ) ; if ( idField != null && fieldName . equals ( idField . getName ( ) ) ) continue ; if ( vField != null && fieldName . equals ( vField . getName ( ) ) ) continue ; fieldValue = serializeFieldValue ( getFieldType ( iPojo , fieldName ) , getFieldValue ( iPojo , fieldName ) ) ; schemaProperty = schemaClass != null ? schemaClass . getProperty ( fieldName ) : null ; if ( fieldValue != null ) { if ( isEmbeddedObject ( iPojo . getClass ( ) , fieldValue . getClass ( ) , fieldName , iEntityManager ) ) { // AUTO CREATE SCHEMA PROPERTY
if ( schemaClass == null ) { db . getMetadata ( ) . getSchema ( ) . createClass ( iPojo . getClass ( ) ) ; iRecord . setClassNameIfExists ( iPojo . getClass ( ) . getSimpleName ( ) ) ; } if ( schemaProperty == null ) { OType t = OType . getTypeByClass ( fieldValue . getClass ( ) ) ; if ( t == null ) t = OType . EMBEDDED ; schemaProperty = iRecord . getSchemaClass ( ) . createProperty ( fieldName , t ) ; } } } fieldValue = typeToStream ( fieldValue , schemaProperty != null ? schemaProperty . getType ( ) : null , iEntityManager , iObj2RecHandler , db , iRecord , iSaveOnlyDirty ) ; iRecord . field ( fieldName , fieldValue ) ; } iObj2RecHandler . registerUserObject ( iPojo , iRecord ) ; // CALL AFTER MARSHALLING
invokeCallback ( iPojo , iRecord , OAfterSerialization . class ) ; OSerializationThreadLocal . INSTANCE . get ( ) . remove ( identityRecord ) ; Orient . instance ( ) . getProfiler ( ) . stopChrono ( "Object.toStream" , "Serialize object to stream" , timer ) ; return iRecord ;


signature:
public class OObjectSerializerHelper { /** * Returns the declared generic types of a class .
 * @ param iObject
 * Class to examine
 * @ return The array of Type if any , otherwise null */
public static Type [ ] getGenericTypes ( final Object iObject ) { } }

implementation: if ( iObject instanceof OTrackedMultiValue ) { final Class < ? > cls = ( ( OTrackedMultiValue < ? , ? > ) iObject ) . getGenericClass ( ) ; if ( cls != null ) return new Type [ ] { cls } ; } return OReflectionHelper . getGenericTypes ( iObject . getClass ( ) ) ;


signature:
public class OQueryTargetOperator { /** * At run - time the evaluation per record must return always true since the recordset are filtered at the beginning unless an
 * operator can work in both modes . In this case sub - class must extend it . */
@ Override public Object evaluateRecord ( final OIdentifiable iRecord , ODocument iCurrentResult , final OSQLFilterCondition iCondition , final Object iLeft , final Object iRight , OCommandContext iContext , final ODocumentSerializer serializer ) { } }

implementation: return true ;


signature:
public class OCommandExecutorSQLMoveVertex { /** * Executes the command and return the ODocument object created . */
public Object execute ( final Map < Object , Object > iArgs ) { } }

implementation:
ODatabaseDocumentInternal db = getDatabase ( ) ; db . begin ( ) ; if ( className == null && clusterName == null ) throw new OCommandExecutionException ( "Cannot execute the command because it has not been parsed yet" ) ; OModifiableBoolean shutdownGraph = new OModifiableBoolean ( ) ; final boolean txAlreadyBegun = getDatabase ( ) . getTransaction ( ) . isActive ( ) ; try { final Set < OIdentifiable > sourceRIDs = OSQLEngine . getInstance ( ) . parseRIDTarget ( db , source , context , iArgs ) ; // CREATE EDGES
final List < ODocument > result = new ArrayList < ODocument > ( sourceRIDs . size ( ) ) ; for ( OIdentifiable from : sourceRIDs ) { final OVertex fromVertex = toVertex ( from ) ; if ( fromVertex == null ) continue ; final ORID oldVertex = fromVertex . getIdentity ( ) . copy ( ) ; final ORID newVertex = fromVertex . moveTo ( className , clusterName ) ; final ODocument newVertexDoc = newVertex . getRecord ( ) ; if ( fields != null ) { // EVALUATE FIELDS
for ( final OPair < String , Object > f : fields ) { if ( f . getValue ( ) instanceof OSQLFunctionRuntime ) f . setValue ( ( ( OSQLFunctionRuntime ) f . getValue ( ) ) . getValue ( newVertex . getRecord ( ) , null , context ) ) ; } OSQLHelper . bindParameters ( newVertexDoc , fields , new OCommandParameters ( iArgs ) , context ) ; } if ( merge != null ) newVertexDoc . merge ( merge , true , false ) ; // SAVE CHANGES
newVertexDoc . save ( ) ; // PUT THE MOVE INTO THE RESULT
result . add ( new ODocument ( ) . setTrackingChanges ( false ) . field ( "old" , oldVertex , OType . LINK ) . field ( "new" , newVertex , OType . LINK ) ) ; if ( batch > 0 && result . size ( ) % batch == 0 ) { db . commit ( ) ; db . begin ( ) ; } } db . commit ( ) ; return result ; } finally { // if ( ! txAlreadyBegun )
// db . commit ( ) ;
}


signature:
public class OStringSerializer { /** * { @ inheritDoc } */
@ Override public void serializeInByteBufferObject ( String object , ByteBuffer buffer , Object ... hints ) { } }

implementation: int length = object . length ( ) ; buffer . putInt ( length ) ; byte [ ] binaryData = new byte [ length * 2 ] ; char [ ] stringContent = new char [ length ] ; object . getChars ( 0 , length , stringContent , 0 ) ; int counter = 0 ; for ( char character : stringContent ) { binaryData [ counter ] = ( byte ) character ; counter ++ ; binaryData [ counter ] = ( byte ) ( character >>> 8 ) ; counter ++ ; } buffer . put ( binaryData ) ;


signature:
public class ONetworkProtocolBinary { /** * Write a OIdentifiable instance using this format : < br > - 2 bytes : class id [ - 2 = no record , - 3 = rid , - 1 = no class id , > - 1 = valid ]
 * < br > - 1 byte : record type [ d , b , f ] < br > - 2 bytes : cluster id < br > - 8 bytes : position in cluster < br > - 4 bytes : record
 * version < br > - x bytes : record content < br >
 * @ param channel TODO */
public static void writeIdentifiable ( OChannelBinary channel , OClientConnection connection , final OIdentifiable o ) throws IOException { } }

implementation: if ( o == null ) channel . writeShort ( OChannelBinaryProtocol . RECORD_NULL ) ; else if ( o instanceof ORecordId ) { channel . writeShort ( OChannelBinaryProtocol . RECORD_RID ) ; channel . writeRID ( ( ORID ) o ) ; } else { writeRecord ( channel , connection , o . getRecord ( ) ) ; }


signature:
public class OStorageConfigurationImpl { /** * This method load the record information by the internal cluster segment . It ' s for compatibility with older database than
 * 0.9.25. */
public OStorageConfigurationImpl load ( final OContextConfiguration configuration ) throws OSerializationException { } }

implementation: lock . acquireWriteLock ( ) ; try { initConfiguration ( configuration ) ; final byte [ ] record = storage . readRecord ( CONFIG_RID , null , false , false , null ) . getResult ( ) . buffer ; if ( record == null ) throw new OStorageException ( "Cannot load database configuration. The database seems corrupted" ) ; fromStream ( record , 0 , record . length , streamCharset ) ; } finally { lock . releaseWriteLock ( ) ; } return this ;


signature:
public class OStorageConfigurationImpl { /** * Added version used for managed Network Versioning . */
public byte [ ] toStream ( final int iNetworkVersion , Charset charset ) throws OSerializationException { } }

implementation:
lock . acquireReadLock ( ) ; try { final StringBuilder buffer = new StringBuilder ( 8192 ) ; write ( buffer , CURRENT_VERSION ) ; write ( buffer , name ) ; write ( buffer , schemaRecordId ) ; write ( buffer , dictionaryRecordId ) ; write ( buffer , indexMgrRecordId ) ; write ( buffer , localeLanguage ) ; write ( buffer , localeCountry ) ; write ( buffer , dateFormat ) ; write ( buffer , dateTimeFormat ) ; write ( buffer , timeZone . getID ( ) ) ; write ( buffer , charset ) ; if ( iNetworkVersion > 24 ) write ( buffer , conflictStrategy ) ; phySegmentToStream ( buffer , fileTemplate ) ; write ( buffer , clusters . size ( ) ) ; for ( OStorageClusterConfiguration c : clusters ) { if ( c == null ) { write ( buffer , - 1 ) ; continue ; } write ( buffer , c . getId ( ) ) ; write ( buffer , c . getName ( ) ) ; write ( buffer , c . getDataSegmentId ( ) ) ; if ( c instanceof OStoragePaginatedClusterConfiguration ) { write ( buffer , "d" ) ; final OStoragePaginatedClusterConfiguration paginatedClusterConfiguration = ( OStoragePaginatedClusterConfiguration ) c ; write ( buffer , paginatedClusterConfiguration . useWal ) ; write ( buffer , paginatedClusterConfiguration . recordOverflowGrowFactor ) ; write ( buffer , paginatedClusterConfiguration . recordGrowFactor ) ; write ( buffer , paginatedClusterConfiguration . compression ) ; if ( iNetworkVersion >= 31 ) write ( buffer , paginatedClusterConfiguration . encryption ) ; if ( iNetworkVersion > 24 ) write ( buffer , paginatedClusterConfiguration . conflictStrategy ) ; if ( iNetworkVersion > 25 ) write ( buffer , paginatedClusterConfiguration . getStatus ( ) . name ( ) ) ; if ( iNetworkVersion >= Integer . MAX_VALUE ) { write ( buffer , paginatedClusterConfiguration . getBinaryVersion ( ) ) ; } } } if ( iNetworkVersion <= 25 ) { // dataSegment array
write ( buffer , 0 ) ; // tx Segment File
write ( buffer , "" ) ; write ( buffer , "" ) ; write ( buffer , 0 ) ; // tx segment flags
write ( buffer , false ) ; write ( buffer , false ) ; } synchronized ( properties ) { write ( buffer , properties . size ( ) ) ; for ( OStorageEntryConfiguration e : properties ) entryToStream ( buffer , e ) ; } write ( buffer , binaryFormatVersion ) ; write ( buffer , clusterSelection ) ; write ( buffer , getMinimumClusters ( ) ) ; if ( iNetworkVersion > 24 ) { write ( buffer , recordSerializer ) ; write ( buffer , recordSerializerVersion ) ; // WRITE CONFIGURATION
write ( buffer , configuration . getContextSize ( ) ) ; for ( String k : configuration . getContextKeys ( ) ) { final OGlobalConfiguration cfg = OGlobalConfiguration . findByKey ( k ) ; write ( buffer , k ) ; if ( cfg != null ) { write ( buffer , cfg . isHidden ( ) ? null : configuration . getValueAsString ( cfg ) ) ; } else { write ( buffer , null ) ; OLogManager . instance ( ) . warn ( this , "Storing configuration for property:'" + k + "' not existing in current version" ) ; } } } write ( buffer , indexEngines . size ( ) ) ; for ( IndexEngineData engineData : indexEngines . values ( ) ) { write ( buffer , engineData . getName ( ) ) ; write ( buffer , engineData . getAlgorithm ( ) ) ; write ( buffer , engineData . getIndexType ( ) == null ? "" : engineData . getIndexType ( ) ) ; write ( buffer , engineData . getValueSerializerId ( ) ) ; write ( buffer , engineData . getKeySerializedId ( ) ) ; write ( buffer , engineData . isAutomatic ( ) ) ; write ( buffer , engineData . getDurableInNonTxMode ( ) ) ; write ( buffer , engineData . getVersion ( ) ) ; write ( buffer , engineData . isNullValuesSupport ( ) ) ; write ( buffer , engineData . getKeySize ( ) ) ; write ( buffer , engineData . getEncryption ( ) ) ; write ( buffer , engineData . getEncryptionOptions ( ) ) ; if ( engineData . getKeyTypes ( ) != null ) { write ( buffer , engineData . getKeyTypes ( ) . length ) ; for ( OType type : engineData . getKeyTypes ( ) ) { write ( buffer , type . name ( ) ) ; } } else { write ( buffer , 0 ) ; } if ( engineData . getEngineProperties ( ) == null ) { write ( buffer , 0 ) ; } else { write ( buffer , engineData . getEngineProperties ( ) . size ( ) ) ; for ( Map . Entry < String , String > property : engineData . getEngineProperties ( ) . entrySet ( ) ) { write ( buffer , property . getKey ( ) ) ; write ( buffer , property . getValue ( ) ) ; } } write ( buffer , engineData . getApiVersion ( ) ) ; write ( buffer , engineData . isMultivalue ( ) ) ; } write ( buffer , createdAtVersion ) ; write ( buffer , pageSize ) ; write ( buffer , freeListBoundary ) ; write ( buffer , maxKeySize ) ; // PLAIN : ALLOCATE ENOUGH SPACE TO REUSE IT EVERY TIME
buffer . append ( "|" ) ; return buffer . toString ( ) . getBytes ( charset ) ; } finally { lock . releaseReadLock ( ) ; } } public void create ( ) throws IOException { lock . acquireWriteLock ( ) ; try { storage . createRecord ( CONFIG_RID , new byte [ ] { 0 , 0 , 0 , 0 } , 0 , OBlob . RECORD_TYPE , null ) ; } finally { lock . releaseWriteLock ( ) ; }


signature:
public class OArrays { /** * Returns true if an arrays contains a value , otherwise false */
public static boolean contains ( final int [ ] iArray , final int iToFind ) { } }

implementation: if ( iArray == null || iArray . length == 0 ) return false ; for ( int e : iArray ) if ( e == iToFind ) return true ; return false ;


signature:
public class OArrays { /** * Returns true if an arrays contains a value , otherwise false */
public static < T > boolean contains ( final T [ ] iArray , final T iToFind ) { } }

implementation: if ( iArray == null || iArray . length == 0 ) return false ; for ( T e : iArray ) if ( e != null && e . equals ( iToFind ) ) return true ; return false ;


signature:
public class OMatchStatement { /** * this method parses the statement
 * @ param iRequest Command request implementation .
 * @ param < RET >
 * @ return */
@ Override public < RET extends OCommandExecutor > RET parse ( OCommandRequest iRequest ) { } }

implementation:
final OCommandRequestText textRequest = ( OCommandRequestText ) iRequest ; if ( iRequest instanceof OSQLSynchQuery ) { request = ( OSQLSynchQuery < ODocument > ) iRequest ; } else if ( iRequest instanceof OSQLAsynchQuery ) { request = ( OSQLAsynchQuery < ODocument > ) iRequest ; } else { // BUILD A QUERY OBJECT FROM THE COMMAND REQUEST
request = new OSQLSynchQuery < ODocument > ( textRequest . getText ( ) ) ; if ( textRequest . getResultListener ( ) != null ) { request . setResultListener ( textRequest . getResultListener ( ) ) ; } } String queryText = textRequest . getText ( ) ; // please , do not look at this . . . refactor this ASAP with new executor structure
final InputStream is = new ByteArrayInputStream ( queryText . getBytes ( ) ) ; OrientSql osql = null ; try { ODatabaseDocumentInternal db = getDatabase ( ) ; if ( db == null ) { osql = new OrientSql ( is ) ; } else { osql = new OrientSql ( is , db . getStorage ( ) . getConfiguration ( ) . getCharset ( ) ) ; } } catch ( UnsupportedEncodingException e ) { OLogManager . instance ( ) . warn ( this , "Invalid charset for database " + getDatabase ( ) + " " + getDatabase ( ) . getStorage ( ) . getConfiguration ( ) . getCharset ( ) ) ; osql = new OrientSql ( is ) ; } try { OMatchStatement result = ( OMatchStatement ) osql . parse ( ) ; this . matchExpressions = result . matchExpressions ; this . notMatchExpressions = result . notMatchExpressions ; this . returnItems = result . returnItems ; this . returnAliases = result . returnAliases ; this . limit = result . limit ; } catch ( ParseException e ) { OCommandSQLParsingException ex = new OCommandSQLParsingException ( e , queryText ) ; OErrorCode . QUERY_PARSE_ERROR . throwException ( ex . getMessage ( ) , ex ) ; } buildPatterns ( ) ; pattern . validate ( ) ; return ( RET ) this ;


signature:
public class OMatchStatement { /** * rebinds filter ( where ) conditions to alias nodes after optimization
 * @ param aliasFilters */
private void rebindFilters ( Map < String , OWhereClause > aliasFilters ) { } }

implementation: for ( OMatchExpression expression : matchExpressions ) { OWhereClause newFilter = aliasFilters . get ( expression . origin . getAlias ( ) ) ; expression . origin . setFilter ( newFilter ) ; for ( OMatchPathItem item : expression . items ) { newFilter = aliasFilters . get ( item . filter . getAlias ( ) ) ; item . filter . setFilter ( newFilter ) ; } }


signature:
public class OMatchStatement { /** * assigns default aliases to pattern nodes that do not have an explicit alias
 * @ param matchExpressions */
private void assignDefaultAliases ( List < OMatchExpression > matchExpressions ) { } }

implementation: int counter = 0 ; for ( OMatchExpression expression : matchExpressions ) { if ( expression . origin . getAlias ( ) == null ) { expression . origin . setAlias ( DEFAULT_ALIAS_PREFIX + ( counter ++ ) ) ; } for ( OMatchPathItem item : expression . items ) { if ( item . filter == null ) { item . filter = new OMatchFilter ( - 1 ) ; } if ( item . filter . getAlias ( ) == null ) { item . filter . setAlias ( DEFAULT_ALIAS_PREFIX + ( counter ++ ) ) ; } } }


signature:
public class OMatchStatement { /** * this method works statefully , using request and context variables from current Match statement . This method will be deprecated
 * in next releases
 * @ param iArgs Optional variable arguments to pass to the command .
 * @ return */
@ Override public Object execute ( Map < Object , Object > iArgs ) { } }

implementation: this . context . setInputParameters ( iArgs ) ; return execute ( this . request , this . context , this . progressListener ) ;


signature:
public class OMatchStatement { /** * executes the match statement . This is the preferred execute ( ) method and it has to be used as the default one in the future .
 * This method works in stateless mode
 * @ param request
 * @ param context
 * @ return */
public Object execute ( OSQLAsynchQuery < ODocument > request , OCommandContext context , OProgressListener progressListener ) { } }

implementation:
if ( orderBy != null ) { throw new OCommandExecutionException ( "ORDER BY is not supported in MATCH on the legacy API" ) ; } if ( groupBy != null ) { throw new OCommandExecutionException ( "GROUP BY is not supported in MATCH on the legacy API" ) ; } if ( unwind != null ) { throw new OCommandExecutionException ( "UNWIND is not supported in MATCH on the legacy API" ) ; } if ( skip != null ) { throw new OCommandExecutionException ( "SKIP is not supported in MATCH on the legacy API" ) ; } Map < Object , Object > iArgs = context . getInputParameters ( ) ; try { Map < String , Long > estimatedRootEntries = estimateRootEntries ( aliasClasses , aliasFilters , context ) ; if ( estimatedRootEntries . values ( ) . contains ( 0l ) ) { return new OBasicLegacyResultSet ( ) ; // some aliases do not match on any classes
} List < EdgeTraversal > sortedEdges = getTopologicalSortedSchedule ( estimatedRootEntries , pattern ) ; MatchExecutionPlan executionPlan = new MatchExecutionPlan ( ) ; executionPlan . sortedEdges = sortedEdges ; calculateMatch ( pattern , estimatedRootEntries , new MatchContext ( ) , aliasClasses , aliasFilters , context , request , executionPlan ) ; return getResult ( request ) ; } finally { if ( request . getResultListener ( ) != null ) { request . getResultListener ( ) . end ( ) ; } }


signature:
public class OMatchStatement { /** * Start a depth - first traversal from the starting node , adding all viable unscheduled edges and vertices .
 * @ param startNode the node from which to start the depth - first traversal
 * @ param visitedNodes set of nodes that are already visited ( mutated in this function )
 * @ param visitedEdges set of edges that are already visited and therefore don ' t need to be scheduled ( mutated in this
 * function )
 * @ param remainingDependencies dependency map including only the dependencies that haven ' t yet been satisfied ( mutated in this
 * function )
 * @ param resultingSchedule the schedule being computed i . e . appended to ( mutated in this function ) */
private void updateScheduleStartingAt ( PatternNode startNode , Set < PatternNode > visitedNodes , Set < PatternEdge > visitedEdges , Map < String , Set < String > > remainingDependencies , List < EdgeTraversal > resultingSchedule ) { } }

implementation:
// OrientDB requires the schedule to contain all edges present in the query , which is a stronger condition
// than simply visiting all nodes in the query . Consider the following example query :
// MATCH {
// class : A ,
// as : foo
// } . in ( ) {
// as : bar
// class : B ,
// as : bar
// } . out ( ) {
// as : foo
// } RETURN $ matches
// The schedule for the above query must have two edges , even though there are only two nodes and they can both
// be visited with the traversal of a single edge .
// To satisfy it , we obey the following for each non - optional node :
// - ignore edges to neighboring nodes which have unsatisfied dependencies ;
// - for visited neighboring nodes , add their edge if it wasn ' t already present in the schedule , but do not
// recurse into the neighboring node ;
// - for unvisited neighboring nodes with satisfied dependencies , add their edge and recurse into them .
visitedNodes . add ( startNode ) ; for ( Set < String > dependencies : remainingDependencies . values ( ) ) { dependencies . remove ( startNode . alias ) ; } Map < PatternEdge , Boolean > edges = new LinkedHashMap < PatternEdge , Boolean > ( ) ; for ( PatternEdge outEdge : startNode . out ) { edges . put ( outEdge , true ) ; } for ( PatternEdge inEdge : startNode . in ) { edges . put ( inEdge , false ) ; } for ( Map . Entry < PatternEdge , Boolean > edgeData : edges . entrySet ( ) ) { PatternEdge edge = edgeData . getKey ( ) ; boolean isOutbound = edgeData . getValue ( ) ; PatternNode neighboringNode = isOutbound ? edge . in : edge . out ; if ( ! remainingDependencies . get ( neighboringNode . alias ) . isEmpty ( ) ) { // Unsatisfied dependencies , ignore this neighboring node .
continue ; } if ( visitedNodes . contains ( neighboringNode ) ) { if ( ! visitedEdges . contains ( edge ) ) { // If we are executing in this block , we are in the following situation :
// - the startNode has not been visited yet ;
// - it has a neighboringNode that has already been visited ;
// - the edge between the startNode and the neighboringNode has not been scheduled yet .
// The isOutbound value shows us whether the edge is outbound from the point of view of the startNode .
// However , if there are edges to the startNode , we must visit the startNode from an already - visited
// neighbor , to preserve the validity of the traversal . Therefore , we negate the value of isOutbound
// to ensure that the edge is always scheduled in the direction from the already - visited neighbor
// toward the startNode . Notably , this is also the case when evaluating " optional " nodes - - we always
// visit the optional node from its non - optional and already - visited neighbor .
// The only exception to the above is when we have edges with " while " conditions . We are not allowed
// to flip their directionality , so we leave them as - is .
boolean traversalDirection ; if ( startNode . optional || edge . item . isBidirectional ( ) ) { traversalDirection = ! isOutbound ; } else { traversalDirection = isOutbound ; } visitedEdges . add ( edge ) ; resultingSchedule . add ( new EdgeTraversal ( edge , traversalDirection ) ) ; } } else if ( ! startNode . optional ) { // If the neighboring node wasn ' t visited , we don ' t expand the optional node into it , hence the above check .
// Instead , we ' ll allow the neighboring node to add the edge we failed to visit , via the above block .
if ( visitedEdges . contains ( edge ) ) { // Should never happen .
throw new AssertionError ( "The edge was visited, but the neighboring vertex was not: " + edge + " " + neighboringNode ) ; } visitedEdges . add ( edge ) ; resultingSchedule . add ( new EdgeTraversal ( edge , isOutbound ) ) ; updateScheduleStartingAt ( neighboringNode , visitedNodes , visitedEdges , remainingDependencies , resultingSchedule ) ; } }


signature:
public class OMatchStatement { /** * sort edges in the order they will be matched */
private List < EdgeTraversal > getTopologicalSortedSchedule ( Map < String , Long > estimatedRootEntries , Pattern pattern ) { } }

implementation:
List < EdgeTraversal > resultingSchedule = new ArrayList < EdgeTraversal > ( ) ; Map < String , Set < String > > remainingDependencies = getDependencies ( pattern ) ; Set < PatternNode > visitedNodes = new HashSet < PatternNode > ( ) ; Set < PatternEdge > visitedEdges = new HashSet < PatternEdge > ( ) ; // Sort the possible root vertices in order of estimated size , since we want to start with a small vertex set .
List < OPair < Long , String > > rootWeights = new ArrayList < OPair < Long , String > > ( ) ; for ( Map . Entry < String , Long > root : estimatedRootEntries . entrySet ( ) ) { rootWeights . add ( new OPair < Long , String > ( root . getValue ( ) , root . getKey ( ) ) ) ; } Collections . sort ( rootWeights ) ; // Add the starting vertices , in the correct order , to an ordered set .
Set < String > remainingStarts = new LinkedHashSet < String > ( ) ; for ( OPair < Long , String > item : rootWeights ) { remainingStarts . add ( item . getValue ( ) ) ; } // Add all the remaining aliases after all the suggested start points .
for ( String alias : pattern . aliasToNode . keySet ( ) ) { if ( ! remainingStarts . contains ( alias ) ) { remainingStarts . add ( alias ) ; } } while ( resultingSchedule . size ( ) < pattern . numOfEdges ) { // Start a new depth - first pass , adding all nodes with satisfied dependencies .
// 1 . Find a starting vertex for the depth - first pass .
PatternNode startingNode = null ; List < String > startsToRemove = new ArrayList < String > ( ) ; for ( String currentAlias : remainingStarts ) { PatternNode currentNode = pattern . aliasToNode . get ( currentAlias ) ; if ( visitedNodes . contains ( currentNode ) ) { // If a previous traversal already visited this alias , remove it from further consideration .
startsToRemove . add ( currentAlias ) ; } else if ( remainingDependencies . get ( currentAlias ) . isEmpty ( ) ) { // If it hasn ' t been visited , and has all dependencies satisfied , visit it .
startsToRemove . add ( currentAlias ) ; startingNode = currentNode ; break ; } } remainingStarts . removeAll ( startsToRemove ) ; if ( startingNode == null ) { // We didn ' t manage to find a valid root , and yet we haven ' t constructed a complete schedule .
// This means there must be a cycle in our dependency graph , or all dependency - free nodes are optional .
// Therefore , the query is invalid .
throw new OCommandExecutionException ( "This query contains MATCH conditions that cannot be evaluated, " + "like an undefined alias or a circular dependency on a $matched condition." ) ; } // 2 . Having found a starting vertex , traverse its neighbors depth - first ,
// adding any non - visited ones with satisfied dependencies to our schedule .
updateScheduleStartingAt ( startingNode , visitedNodes , visitedEdges , remainingDependencies , resultingSchedule ) ; } if ( resultingSchedule . size ( ) != pattern . numOfEdges ) { throw new AssertionError ( "Incorrect number of edges: " + resultingSchedule . size ( ) + " vs " + pattern . numOfEdges ) ; } return resultingSchedule ;


signature:
public class OMatchStatement { /** * @ param request
 * @ param ctx
 * @ param record
 * @ return false if limit was reached */
private boolean addSingleResult ( OSQLAsynchQuery < ODocument > request , OBasicCommandContext ctx , ORecord record ) { } }

implementation: if ( ( ( OBasicCommandContext ) context ) . addToUniqueResult ( record ) ) { request . getResultListener ( ) . result ( record ) ; long currentCount = ctx . getResultsProcessed ( ) . incrementAndGet ( ) ; long limitValue = limitFromProtocol ; if ( limit != null ) { limitValue = limit . num . getValue ( ) . longValue ( ) ; } if ( limitValue > - 1 && limitValue <= currentCount ) { return false ; } } return true ;


signature: public class OMatchStatement { private OSelectStatement buildSelectStatement ( String className , OWhereClause oWhereClause ) { } }

implementation: OSelectStatement stm = new OSelectStatement ( - 1 ) ; stm . whereClause = oWhereClause ; stm . target = new OFromClause ( - 1 ) ; stm . target . item = new OFromItem ( - 1 ) ; stm . target . item . identifier = new OIdentifier ( className ) ; return stm ;


signature:
public class OBinaryComparatorV0 { /** * Compares if 2 field values are the same .
 * @ param iField1 First value to compare
 * @ param iField2 Second value to compare
 * @ return true if they match , otherwise false */
@ Override public boolean isEqual ( final OBinaryField iField1 , final OBinaryField iField2 ) { } }

implementation: final BytesContainer fieldValue1 = iField1 . bytes ; final int offset1 = fieldValue1 . offset ; final BytesContainer fieldValue2 = iField2 . bytes ; final int offset2 = fieldValue2 . offset ; try { switch ( iField1 . type ) { case INTEGER : { final int value1 = OVarIntSerializer . readAsInteger ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case DATE : { final long value2 = ( OVarIntSerializer . readAsLong ( fieldValue2 ) * MILLISEC_PER_DAY ) ; return value1 == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case BYTE : { final byte value2 = readByte ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { return Integer . parseInt ( readString ( fieldValue2 ) ) == value1 ; } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . intValue ( ) ; } } break ; } case LONG : { final long value1 = OVarIntSerializer . readAsLong ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case DATE : { final long value2 = ( OVarIntSerializer . readAsLong ( fieldValue2 ) * MILLISEC_PER_DAY ) ; return value1 == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case BYTE : { final byte value2 = readByte ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { return Long . parseLong ( readString ( fieldValue2 ) ) == value1 ; } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . longValue ( ) ; } } break ; } case SHORT : { final short value1 = OVarIntSerializer . readAsShort ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case DATE : { final long value2 = ( OVarIntSerializer . readAsLong ( fieldValue2 ) * MILLISEC_PER_DAY ) ; return value1 == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case BYTE : { final byte value2 = readByte ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { return Short . parseShort ( readString ( fieldValue2 ) ) == value1 ; } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . shortValue ( ) ; } } break ; } case STRING : { switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return Integer . parseInt ( readString ( fieldValue1 ) ) == value2 ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return Long . parseLong ( readString ( fieldValue1 ) ) == value2 ; } case DATE : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) * MILLISEC_PER_DAY ; return Long . parseLong ( readString ( fieldValue1 ) ) == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return Short . parseShort ( readString ( fieldValue1 ) ) == value2 ; } case BYTE : { final byte value2 = readByte ( fieldValue2 ) ; return Byte . parseByte ( readString ( fieldValue1 ) ) == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return Float . parseFloat ( readString ( fieldValue1 ) ) == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return Double . parseDouble ( readString ( fieldValue1 ) ) == value2 ; } case STRING : { final int len1 = OVarIntSerializer . readAsInteger ( fieldValue1 ) ; final int len2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; if ( len1 != len2 ) return false ; final OCollate collate = ( iField1 . collate != null && ! ODefaultCollate . NAME . equals ( iField1 . collate . getName ( ) ) ) ? iField1 . collate : ( iField2 . collate != null && ! ODefaultCollate . NAME . equals ( iField2 . collate . getName ( ) ) ? iField2 . collate : null ) ; if ( collate != null ) { final String str1 = ( String ) collate . transform ( stringFromBytes ( fieldValue1 . bytes , fieldValue1 . offset , len1 ) ) ; final String str2 = ( String ) collate . transform ( stringFromBytes ( fieldValue2 . bytes , fieldValue2 . offset , len2 ) ) ; return str1 . equals ( str2 ) ; } else { for ( int i = 0 ; i < len1 ; ++ i ) { if ( fieldValue1 . bytes [ fieldValue1 . offset + i ] != fieldValue2 . bytes [ fieldValue2 . offset + i ] ) return false ; } } return true ; } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return new BigDecimal ( readString ( fieldValue1 ) ) . equals ( value2 ) ; } case BOOLEAN : { final boolean value2 = readByte ( fieldValue2 ) == 1 ; return Boolean . parseBoolean ( readString ( fieldValue1 ) ) == value2 ; } } break ; } case DOUBLE : { final long value1AsLong = readLong ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case SHORT : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case BYTE : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; final byte value2 = readByte ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2AsLong = readLong ( fieldValue2 ) ; return value1AsLong == value2AsLong ; } case STRING : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; return Double . parseDouble ( readString ( fieldValue2 ) ) == value1 ; } case DECIMAL : { final double value1 = Double . longBitsToDouble ( value1AsLong ) ; final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . doubleValue ( ) ; } } break ; } case FLOAT : { final int value1AsInt = readInteger ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case SHORT : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case BYTE : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; final byte value2 = readByte ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2AsInt = readInteger ( fieldValue2 ) ; return value1AsInt == value2AsInt ; } case DOUBLE : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; return Float . parseFloat ( readString ( fieldValue2 ) ) == value1 ; } case DECIMAL : { final float value1 = Float . intBitsToFloat ( value1AsInt ) ; final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . floatValue ( ) ; } } break ; } case BYTE : { final byte value1 = readByte ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case BYTE : { final byte value2 = readByte ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { final byte value2 = Byte . parseByte ( ( readString ( fieldValue2 ) ) ) ; return value1 == value2 ; } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . byteValue ( ) ; } } break ; } case BOOLEAN : { final boolean value1 = readByte ( fieldValue1 ) == 1 ; switch ( iField2 . type ) { case BOOLEAN : { final boolean value2 = readByte ( fieldValue2 ) == 1 ; return value1 == value2 ; } case STRING : { final String str = readString ( fieldValue2 ) ; return Boolean . parseBoolean ( str ) == value1 ; } } break ; } case DATE : { final long value1 = OVarIntSerializer . readAsLong ( fieldValue1 ) * MILLISEC_PER_DAY ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; value2 = convertDayToTimezone ( ODateHelper . getDatabaseTimeZone ( ) , TimeZone . getTimeZone ( "GMT" ) , value2 ) ; return value1 == value2 ; } case DATE : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) * MILLISEC_PER_DAY ; return value1 == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . longValue ( ) ; } } break ; } case DATETIME : { final long value1 = OVarIntSerializer . readAsLong ( fieldValue1 ) ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 == value2 ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 == value2 ; } case DATE : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) * MILLISEC_PER_DAY ; return value1 == value2 ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 == value2 ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 == value2 ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 == value2 ; } case STRING : { final String value2AsString = readString ( fieldValue2 ) ; if ( OIOUtils . isLong ( value2AsString ) ) { final long value2 = Long . parseLong ( value2AsString ) ; return value1 == value2 ; } final ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal . instance ( ) . getIfDefined ( ) ; try { final SimpleDateFormat dateFormat = db != null ? db . getStorage ( ) . getConfiguration ( ) . getDateTimeFormatInstance ( ) : new SimpleDateFormat ( OStorageConfiguration . DEFAULT_DATETIME_FORMAT ) ; final Date value2AsDate = dateFormat . parse ( value2AsString ) ; final long value2 = value2AsDate . getTime ( ) ; return value1 == value2 ; } catch ( ParseException ignore ) { try { final SimpleDateFormat dateFormat = db != null ? db . getStorage ( ) . getConfiguration ( ) . getDateFormatInstance ( ) : new SimpleDateFormat ( OStorageConfiguration . DEFAULT_DATE_FORMAT ) ; final Date value2AsDate = dateFormat . parse ( value2AsString ) ; final long value2 = value2AsDate . getTime ( ) ; return value1 == value2 ; } catch ( ParseException ignored ) { return new Date ( value1 ) . toString ( ) . equals ( value2AsString ) ; } } } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 == value2 . longValue ( ) ; } } break ; } case BINARY : { switch ( iField2 . type ) { case BINARY : { final int length1 = OVarIntSerializer . readAsInteger ( fieldValue1 ) ; final int length2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; if ( length1 != length2 ) return false ; for ( int i = 0 ; i < length1 ; ++ i ) { if ( fieldValue1 . bytes [ fieldValue1 . offset + i ] != fieldValue2 . bytes [ fieldValue2 . offset + i ] ) return false ; } return true ; } } break ; } case LINK : { switch ( iField2 . type ) { case LINK : { final int clusterId1 = OVarIntSerializer . readAsInteger ( fieldValue1 ) ; final int clusterId2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; if ( clusterId1 != clusterId2 ) return false ; final long clusterPos1 = OVarIntSerializer . readAsLong ( fieldValue1 ) ; final long clusterPos2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; if ( clusterPos1 == clusterPos2 ) return true ; break ; } case STRING : { return readOptimizedLink ( fieldValue1 , false ) . toString ( ) . equals ( readString ( fieldValue2 ) ) ; } } break ; } case DECIMAL : { final BigDecimal value1 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue1 . bytes , fieldValue1 . offset ) ; switch ( iField2 . type ) { case INTEGER : { final int value2 = OVarIntSerializer . readAsInteger ( fieldValue2 ) ; return value1 . equals ( new BigDecimal ( value2 ) ) ; } case LONG : case DATETIME : { final long value2 = OVarIntSerializer . readAsLong ( fieldValue2 ) ; return value1 . equals ( new BigDecimal ( value2 ) ) ; } case SHORT : { final short value2 = OVarIntSerializer . readAsShort ( fieldValue2 ) ; return value1 . equals ( new BigDecimal ( value2 ) ) ; } case FLOAT : { final float value2 = Float . intBitsToFloat ( readInteger ( fieldValue2 ) ) ; return value1 . equals ( new BigDecimal ( value2 ) ) ; } case DOUBLE : { final double value2 = Double . longBitsToDouble ( readLong ( fieldValue2 ) ) ; return value1 . equals ( new BigDecimal ( value2 ) ) ; } case STRING : { return value1 . toString ( ) . equals ( readString ( fieldValue2 ) ) ; } case DECIMAL : { final BigDecimal value2 = ODecimalSerializer . INSTANCE . deserialize ( fieldValue2 . bytes , fieldValue2 . offset ) ; return value1 . equals ( value2 ) ; } } break ; } } } finally { fieldValue1 . offset = offset1 ; fieldValue2 . offset = offset2 ; } return false ;