當前位置: 首頁>>代碼示例>>Java>>正文


Java OSQLAsynchQuery類代碼示例

本文整理匯總了Java中com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery的典型用法代碼示例。如果您正苦於以下問題:Java OSQLAsynchQuery類的具體用法?Java OSQLAsynchQuery怎麽用?Java OSQLAsynchQuery使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OSQLAsynchQuery類屬於com.orientechnologies.orient.core.sql.query包,在下文中一共展示了OSQLAsynchQuery類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public <R> Observable<R> execute() {
  return Observable.create(subscriber -> {
    try (ODatabaseDocument conn = dao.getConnection()) {
      subscriber.onStart();
      if (logger.isDebugEnabled()) {
        logger.debug("Executing query '{}'. Params: {}", sql, asList(params));
      }
      OQuery<R> query = new OSQLAsynchQuery<>(sql, new OCommandResultListener() {
        @Override
        public boolean result(Object iRecord) {
          subscriber.onNext((R) iRecord);
          return true;
        }

        @Override
        public void end() {
          subscriber.onCompleted();
        }
      });
      if (fetchPlan != null) {
        query.setFetchPlan(fetchPlan);
      }
      query.execute(params);
    } catch (Throwable e) {
      logger.error("Error performing query: {}", e.getMessage(), e);
      subscriber.onError(e);
    }
  });
}
 
開發者ID:lfridael,項目名稱:resourceful-java-prototype,代碼行數:31,代碼來源:OrientDbQuery.java

示例2: createQueryCommand

import com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery; //導入依賴的package包/類
@Override
protected OCommandRequest createQueryCommand(final CommandMethodDescriptor descriptor,
                                             final SqlCommandDescriptor desc) {
    final boolean blocking = (Boolean) descriptor.extDescriptors.get(EXT_BLOCKING);
    // correct listener will be set by @Listen extension
    if (blocking) {
        return new OSQLAsynchQuery(desc.command);
    } else {
        return new OSQLNonBlockingQuery(desc.command, null);
    }
}
 
開發者ID:xvik,項目名稱:guice-persist-orient,代碼行數:12,代碼來源:AsyncQueryMethodExtension.java

示例3: createSolrIndex

import com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery; //導入依賴的package包/類
private void createSolrIndex() {
       destConn.activateOnCurrentThread();

       String query = "SELECT FROM network where isDeleted=false and isComplete=true";
       
	counter = 0;
	
	OSQLAsynchQuery<ODocument> asyncQuery =
			new OSQLAsynchQuery<ODocument>(query, new OCommandResultListener() { 
	            @Override 
	            public boolean result(Object iRecord) { 
	            	ODocument doc = (ODocument) iRecord;
	            	try {
						networkDao.createSolrIndex(doc);
						Thread.sleep(500);
					} catch (Exception e) {
						// TODO Auto-generated catch block
						logger.severe("Network " + doc.field(NdexClasses.ExternalObj_ID) + " solr index failed to create. Error:" + e.getMessage());
						e.printStackTrace();
						return true;
					}
	            	counter ++;
	  				if ( counter % 50 == 0 ) {
	  					logger.info(  counter + " Solr indexes created for networks.");
	  				}
	  				return true; 
	            } 
	   
	            @Override 
	            public void end() { 
	            	logger.info( "Solr index creation completed. Total record: " + counter);
	            }
	            
	          });
	        
       
       destConn.command(asyncQuery).execute(); 
       
}
 
開發者ID:ndexbio,項目名稱:ndex-common,代碼行數:40,代碼來源:Migrator1_2to1_3.java

示例4: createSolrIndex

import com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery; //導入依賴的package包/類
private void createSolrIndex(String UUID) {

        String query = "SELECT FROM network where isDeleted=false and isComplete=true" + 
              (UUID == null ? "" : (" and UUID='" + UUID + "'") );
        
		counter = 0;
		
		OSQLAsynchQuery<ODocument> asyncQuery =
				new OSQLAsynchQuery<ODocument>(query, new OCommandResultListener() { 
		            @Override 
		            public boolean result(Object iRecord) { 
		            	ODocument doc = (ODocument) iRecord;
		            	try {
							networkDao.createSolrIndex(doc);
							Thread.sleep(200);
						} catch (Exception e) {
							// TODO Auto-generated catch block
							logger.severe("Network " + doc.field(NdexClasses.ExternalObj_ID) + " solr index failed to create. Error:" + e.getMessage());
							e.printStackTrace();
							return true;
						}
		            	counter ++;
		  				if ( counter % 50 == 0 ) {
		  					logger.info(  counter + " Solr indexes created for networks.");
		  				}
		  				return true; 
		            } 
		   
		            @Override 
		            public void end() { 
		            	logger.info( "Solr index creation completed. Total record: " + counter);
		            }
		            
		          });
		        
        
        destConn.command(asyncQuery).execute(); 
        
	}
 
開發者ID:ndexbio,項目名稱:ndex-common,代碼行數:40,代碼來源:ReIndexer.java

示例5: copySupport

import com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery; //導入依賴的package包/類
private void copySupport() {
       srcConnection.activateOnCurrentThread();

       String query = "SELECT FROM support where in_supports is not null";
       
	counter = 0;
	
	OSQLAsynchQuery<ODocument> asyncQuery =
			new OSQLAsynchQuery<ODocument>(query, new OCommandResultListener() { 
	            @Override 
	            public boolean result(Object iRecord) { 
	            	ODocument doc = (ODocument) iRecord;
	  				Long id = (Long) doc.field(NdexClasses.Element_ID);
	  				String text= doc.field(NdexClasses.Support_P_text);
	  				if ( text == null) {  // skip this if the text is null
	  					logger.warning("empty support text. Support record" + id + " is ignored.");
	  					return true;
	  				}
	  				
	  				Object netRec = doc.field("in_supports");
	  				if ( ! (netRec instanceof ODocument)) {
	  					logger.warning("Support id" + id + " is not pointing to a network, ignoring it.");
	  					return true;
	  				}
	  					
	  				ODocument netDoc = (ODocument)netRec;
	  				String uuid = netDoc.field(NdexClasses.ExternalObj_ID);
	  				
	  				ODocument cDoc = doc.field("out_citeFrom");

	  				Long citationId = null;
	  				if ( cDoc != null) {
  							citationId = cDoc.field(NdexClasses.Element_ID);
	  				
	  				}
	  				
	  				// get properties
	  				List<NdexPropertyValuePair> props = getProperties(doc);
	  				
	  				destConn.activateOnCurrentThread();
	  				
	  				ODocument newDoc = new ODocument(NdexClasses.Support)
	              			.fields(NdexClasses.Element_ID,id, 
	              					NdexClasses.Support_P_text, text,
	              					NdexClasses.Citation, citationId);
	              	
	  				if ( !props.isEmpty())
	              		newDoc.field(NdexClasses.ndexProperties, props);

	  				newDoc.save();
	  				
	  				// connect to network headnode.
	  				if ( !connectToNetworkHeadNode(newDoc, uuid, NdexClasses.Network_E_Supports))
	  					return false;
	  				
	  				counter++;
	  				if ( counter % 10000 == 0 ) {
	  					destConn.commit();
	  					logger.info( "Support commited " + counter + " records.");
	  				}
	  				srcConnection.activateOnCurrentThread();
	            	
	  				return true; 
	            } 
	   
	            @Override 
	            public void end() {
	            	destConn.activateOnCurrentThread();
	            	destConn.commit();
	            	logger.info( "Support copy completed. Total record: " + counter);
	            }
	            
	          });
	        
       
       srcConnection.command(asyncQuery).execute(); 
       

}
 
開發者ID:ndexbio,項目名稱:ndex-common,代碼行數:80,代碼來源:Migrator1_2to1_3.java

示例6: copyCitations

import com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery; //導入依賴的package包/類
private void copyCitations() {
       srcConnection.activateOnCurrentThread();

       String query = "SELECT FROM citation where in_citations is not null";
       
	counter = 0;
	
	OSQLAsynchQuery<ODocument> asyncQuery =
			new OSQLAsynchQuery<ODocument>(query, new OCommandResultListener() { 
	            @Override 
	            public boolean result(Object iRecord) { 
	            	ODocument doc = (ODocument) iRecord;
	  				Long id = (Long) doc.field(NdexClasses.Element_ID);
	  				String title= doc.field(NdexClasses.Citation_P_title);
	  				String idType = doc.field(NdexClasses.Citation_p_idType);
	  				String identifier = doc.field(NdexClasses.Citation_P_identifier);  
	  				List<String> authors = doc.field(NdexClasses.Citation_P_contributors);
	  				
	  				
	  				ODocument netDoc = doc.field("in_citations");
	  				String uuid = netDoc.field(NdexClasses.ExternalObj_ID);
	  				
	  				// get properties
	  				List<NdexPropertyValuePair> props = getProperties(doc);
	  				
	  				destConn.activateOnCurrentThread();
	  				
	  				ODocument newDoc = new ODocument(NdexClasses.Citation)
	              			.fields(NdexClasses.Element_ID,id, 
	              					NdexClasses.Citation_P_title, title, 
	              					NdexClasses.Citation_p_idType, idType,
	              					NdexClasses.Citation_P_identifier, identifier,
	              					NdexClasses.Citation_P_contributors, authors);
	              	
	  				if ( !props.isEmpty())
	              		newDoc.field(NdexClasses.ndexProperties, props);

	  				newDoc.save();
	  				
	  				// connect to network headnode.
	  				if ( !connectToNetworkHeadNode(newDoc, uuid, NdexClasses.Network_E_Citations))
	  					return false;
	  				
	  				counter++;
	  				if ( counter % 10000 == 0 ) {
	  					destConn.commit();
	  					logger.info( "Citation commited " + counter + " records.");
	  				}
	  				srcConnection.activateOnCurrentThread();
	            	
	  				return true; 
	            } 
	   
	            @Override 
	            public void end() { 
	            	destConn.activateOnCurrentThread();
	            	destConn.commit();
	            	logger.info( "Citation copy completed. Total record: " + counter);
	            }
	            
	          });
	        
       
       srcConnection.command(asyncQuery).execute(); 
       

}
 
開發者ID:ndexbio,項目名稱:ndex-common,代碼行數:68,代碼來源:Migrator1_2to1_3.java

示例7: copyReifiedEdgeElements

import com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery; //導入依賴的package包/類
private void copyReifiedEdgeElements() {
       srcConnection.activateOnCurrentThread();

       String query = "SELECT FROM reifiedEdgeTerm where in_reifiedETerms is not null";
       
	counter = 0;
	
	OSQLAsynchQuery<ODocument> asyncQuery =
			new OSQLAsynchQuery<ODocument>(query, new OCommandResultListener() { 
	            @Override 
	            public boolean result(Object iRecord) { 
	            	ODocument doc = (ODocument) iRecord;
	  				Long id = (Long) doc.field(NdexClasses.Element_ID);
	  		
	  				ODocument netDoc = doc.field("in_reifiedETerms");
	  				String uuid = netDoc.field(NdexClasses.ExternalObj_ID);
	  				
	  				
	  				destConn.activateOnCurrentThread();
	  				
	  				ODocument newDoc = new ODocument(NdexClasses.ReifiedEdgeTerm)
	              			.fields(NdexClasses.Element_ID,id);
	              	
	  				newDoc.save();
	  				
	  				// connect to network headnode.
	  				if ( !connectToNetworkHeadNode(newDoc, uuid, NdexClasses.Network_E_ReifiedEdgeTerms))
	  					return false;
	  				
	  				counter++;
	  				if ( counter % 5000 == 0 ) {
	  					destConn.commit();
	  					logger.info( "ReifiedEdge term commited " + counter + " records.");
	  				}
	  				srcConnection.activateOnCurrentThread();
	            	
	  				return true; 
	            } 
	   
	            @Override 
	            public void end() { 
	            	destConn.activateOnCurrentThread();
	            	destConn.commit();
	            	logger.info( "Refied edge record copy completed. Total record: " + counter);
	            }
	            
	          });
	        
       srcConnection.command(asyncQuery).execute(); 
       

}
 
開發者ID:ndexbio,項目名稱:ndex-common,代碼行數:53,代碼來源:Migrator1_2to1_3.java

示例8: copyReifiedEdgeLinks

import com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery; //導入依賴的package包/類
private void copyReifiedEdgeLinks() {
       srcConnection.activateOnCurrentThread();

       String query = "SELECT FROM reifiedEdgeTerm where in_reifiedETerms is not null";
       
	counter = 0;
	
	OSQLAsynchQuery<ODocument> asyncQuery =
			new OSQLAsynchQuery<ODocument>(query, new OCommandResultListener() { 
	            @Override 
	            public boolean result(Object iRecord) { 
	            	ODocument doc = (ODocument) iRecord;
	  				Long id = (Long) doc.field(NdexClasses.Element_ID);
	  		
	  				ODocument edgeDoc = doc.field("out_reify");
	  				Long edgeId = edgeDoc.field(NdexClasses.Element_ID);		  				
	  				
	  				destConn.activateOnCurrentThread();
	  				
 					ODocument edgeNDoc;
 					ODocument reifiedNDoc;
					try {
						edgeNDoc = dbDao.getDocumentByElementId(edgeId);
						reifiedNDoc = dbDao.getDocumentByElementId(id);
					} catch (NdexException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
							logger.warning("Edge id not found in target db:" + edgeId );

							srcConnection.activateOnCurrentThread();

							return true;
					}
	  				OrientVertex edgeV = graph.getVertex(edgeNDoc);
	  				OrientVertex reifiedV = graph.getVertex(reifiedNDoc);
	  					
	  				graph.addEdge(null, reifiedV, edgeV, NdexClasses.ReifiedEdge_E_edge);

	  				counter++;
	  				if ( counter % 5000 == 0 ) {
	  					destConn.commit();
	  					logger.info( "ReifiedEdge link commited " + counter + " records.");
	  				}
	  				srcConnection.activateOnCurrentThread();
	            	
	  				return true; 
	            } 
	   
	            @Override 
	            public void end() { 
	            	destConn.activateOnCurrentThread();
	            	destConn.commit();
	            	logger.info( "Refied edge linke copy completed. Total record: " + counter);
	            }
	            
	          });
	        
       srcConnection.command(asyncQuery).execute(); 
       

}
 
開發者ID:ndexbio,項目名稱:ndex-common,代碼行數:62,代碼來源:Migrator1_2to1_3.java

示例9: copyUsers

import com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery; //導入依賴的package包/類
private void copyUsers() {
       srcConnection.activateOnCurrentThread();

       String query = "SELECT FROM user where isDeleted=false";
       
	counter = 0;
	
	OSQLAsynchQuery<ODocument> asyncQuery =
			new OSQLAsynchQuery<ODocument>(query, new OCommandResultListener() { 
	            @Override 
	            public boolean result(Object iRecord) { 
	            	ODocument doc = (ODocument) iRecord;
	  				String uuid =  doc.field(NdexClasses.ExternalObj_ID);
	  				String desc = doc.field("description");
	  				Date ct = doc.field(NdexClasses.ExternalObj_cTime);
	  				Date mt = doc.field(NdexClasses.ExternalObj_mTime);
	  				String imgURL = doc.field("imageURL");
	  				String password = doc.field("password");
	  				String websiteURL = doc.field("websiteURL");
	  				String accName = doc.field(NdexClasses.account_P_accountName);
	  				String email = doc.field("emailAddress");
	  				String firstName = doc.field("firstName");
	  				String lastName = doc.field("lastName");
	  				
	  				destConn.activateOnCurrentThread();
	  				ODocument newbtDoc = new ODocument(NdexClasses.User)
	              			.fields(NdexClasses.ExternalObj_ID, uuid,
	              					NdexClasses.ExternalObj_cTime, ct,
	              					NdexClasses.ExternalObj_mTime,mt,
	              					NdexClasses.account_P_accountName, accName,
	              					"isDeleted", false,
	              					"description", desc,
	              					"imageURL", imgURL,
	              					"password", password,
	              					"websiteURL", websiteURL,
	              					"emailAddress",email,
	              					"firstName", firstName,
	              					"lastName", lastName);
	  				newbtDoc.save();
	  				counter++;
	  				if ( counter % 5000 == 0 ) {
	  					destConn.commit();
	  					logger.info( "User commited " + counter + " records.");
	  				}
	  				srcConnection.activateOnCurrentThread();
	            	
	  				return true; 
	            } 
	   
	            @Override 
	            public void end() { 
	            	destConn.activateOnCurrentThread();
	            	destConn.commit();
	            	logger.info( "user class copy completed. Total record: " + counter);
	            }
	            
	          });
	        
       
       srcConnection.command(asyncQuery).execute(); 
       

}
 
開發者ID:ndexbio,項目名稱:ndex-common,代碼行數:64,代碼來源:Migrator1_2to1_3.java


注:本文中的com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。