0

我正在对对象列表进行大量处理和搜索。我的应用程序在呈现结果时内存不足。是否有任何 API 可以有效地处理/处理对象列表,我正在尝试对其进行优化。

我还要说一件事,我正在用新的 ArrayList 初始化我的所有列表。我应该使用其他东西吗?

我有一个需要显示记录和搜索这些记录的屏幕,我正在使用那里的 API(这是我唯一的方法,因为我无法访问他们的数据库,我无法运行 SQL 查询。)屏幕上显示的每条记录搜索特定标准,我正在使用他们的搜索 API 进行相同的搜索。我正在调试代码,发现该搜索方法引发了异常。我正在粘贴错误日志

Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.2.v20100323-r6872): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: [OWLS][SQLServer JDBC Driver][SQLServer]There is insufficient system memory in resource pool 'internal' to run this query.
Error Code: 701
Call: SELECT DISTINCT t0.PRIMARY_KEY, t0.TOTAL_ACCRUAL, t0.TOTAL_ALLOCATED, t0.ALLOC_LIMIT, t0.APPL_END_ON, t0.APPL_EXPENSE_PERCENT, t0.APPL_NON_US_TAX_PERCENT, t0.APPL_INVD_EXPENSE_PERCENT, t0.APPL_INVD_TASK_PERCENT, t0.APPL_START_ON, t0.APPL_TASK_PERCENT, t0.INVOLVED_APPL_TYPE_IID, t0.PROJECT_APPL_TYPE_IID, t0.VENDOR_APPL_TYPE_IID, t0.TOTAL_BG_AVAILABLE, t0.CREATED_ON, t0.STATUS_IID, t0.APPL_EXPENSE, t0.APPL_INVC_ACCRUAL, t0.APPL_INVC_CREDIT_NOTE, t0.APPL_NON_US_TAX, t0.APPL_INVC_SHADOW, t0.APPL_INVC_STANDARD, t0.APPL_INVD_EXPENSE, t0.APPL_INVD_TASK, t0.APPL_TASK, t0.AUTO_POST, t0.MODIFIED_ON, t0.NAME, t0.OVERDRAFT_TYPE_IID, t0.POSTED_TYPE_IID, t0.SECURITY_TYPE_IID, t0.TREE_KEY, t0.TYPE_IID, t0.TOTAL_USED, t0.VERSION, t0.APPL_EXPENSE_CATEGORY_ID, t0.APPL_NON_US_TAX_TYPE, t0.APPL_INVOLVED_ID, t0.APPL_INVD_EXP_CATEGORY_ID, t0.APPL_INVD_TASK_CATEGORY_ID, t0.APPL_PROJECT_CATEGORY_ID, t0.APPL_PROJ_DETAIL_FIELD_ID, t0.PROJECT_ID, t0.APPL_TASK_CATEGORY_ID, t0.APPL_VENDOR_ID, t0.APPROVAL_STATUS_ID, t0.CREATED_BY_ID, t0.CREATED_ON_BEHALF_OF_ID, t0.DEFAULT_CATEGORY_ID, t0.DOCUMENT_FOLDER_ID, t0.FORUM_ID, t0.MODIFIED_BY_ID, t0.NOTE_ID, t0.PARENT_ACCOUNT_ID FROM T_ACCOUNT_SECURITY_FILTER t5, Y_OBJ_CATEGORY t4, T_PROJECT t3, E_ACCT t2, T_CONTACT t1, T_ACCOUNT t0 WHERE ((((((((((t0.VENDOR_APPL_TYPE_IID = 2) AND (t1.PRIMARY_KEY = 2004)) AND (t2."YEARACCT" = N'2012')) AND (t0.PROJECT_APPL_TYPE_IID = 2)) AND (t3.PRIMARY_KEY = 46537)) AND (t4.TREE_POSITION = N'ACCT_ACTL_CCSP_VNDR_MONT')) AND (t0.NAME = N'Actuals - Cost Center 10 - LA2012000250 - Singla, Ashima - 2012 - October')) AND (t2."PERIODACCT" = N'M9')) AND (t5.USER_ID = 1504)) AND (((((t1.PRIMARY_KEY = t0.APPL_VENDOR_ID) AND (t2.ACCOUNT_ID$ = t0.PRIMARY_KEY)) AND (t3.PRIMARY_KEY = t0.PROJECT_ID)) AND (t4.PRIMARY_KEY = t0.DEFAULT_CATEGORY_ID)) AND (t5.ENTERPRISE_OBJECT_ID = t0.PRIMARY_KEY)))
Query: ReadAllQuery(referenceClass=TFAccount sql="SELECT DISTINCT t0.PRIMARY_KEY, t0.TOTAL_ACCRUAL, t0.TOTAL_ALLOCATED, t0.ALLOC_LIMIT, t0.APPL_END_ON, t0.APPL_EXPENSE_PERCENT, t0.APPL_NON_US_TAX_PERCENT, t0.APPL_INVD_EXPENSE_PERCENT, t0.APPL_INVD_TASK_PERCENT, t0.APPL_START_ON, t0.APPL_TASK_PERCENT, t0.INVOLVED_APPL_TYPE_IID, t0.PROJECT_APPL_TYPE_IID, t0.VENDOR_APPL_TYPE_IID, t0.TOTAL_BG_AVAILABLE, t0.CREATED_ON, t0.STATUS_IID, t0.APPL_EXPENSE, t0.APPL_INVC_ACCRUAL, t0.APPL_INVC_CREDIT_NOTE, t0.APPL_NON_US_TAX, t0.APPL_INVC_SHADOW, t0.APPL_INVC_STANDARD, t0.APPL_INVD_EXPENSE, t0.APPL_INVD_TASK, t0.APPL_TASK, t0.AUTO_POST, t0.MODIFIED_ON, t0.NAME, t0.OVERDRAFT_TYPE_IID, t0.POSTED_TYPE_IID, t0.SECURITY_TYPE_IID, t0.TREE_KEY, t0.TYPE_IID, t0.TOTAL_USED, t0.VERSION, t0.APPL_EXPENSE_CATEGORY_ID, t0.APPL_NON_US_TAX_TYPE, t0.APPL_INVOLVED_ID, t0.APPL_INVD_EXP_CATEGORY_ID, t0.APPL_INVD_TASK_CATEGORY_ID, t0.APPL_PROJECT_CATEGORY_ID, t0.APPL_PROJ_DETAIL_FIELD_ID, t0.PROJECT_ID, t0.APPL_TASK_CATEGORY_ID, t0.APPL_VENDOR_ID, t0.APPROVAL_STATUS_ID, t0.CREATED_BY_ID, t0.CREATED_ON_BEHALF_OF_ID, t0.DEFAULT_CATEGORY_ID, t0.DOCUMENT_FOLDER_ID, t0.FORUM_ID, t0.MODIFIED_BY_ID, t0.NOTE_ID, t0.PARENT_ACCOUNT_ID FROM T_ACCOUNT_SECURITY_FILTER t5, Y_OBJ_CATEGORY t4, T_PROJECT t3, E_ACCT t2, T_CONTACT t1, T_ACCOUNT t0 WHERE ((((((((((t0.VENDOR_APPL_TYPE_IID = ?) AND (t1.PRIMARY_KEY = ?)) AND (t2."YEARACCT" = ?)) AND (t0.PROJECT_APPL_TYPE_IID = ?)) AND (t3.PRIMARY_KEY = ?)) AND (t4.TREE_POSITION = ?)) AND (t0.NAME = ?)) AND (t2."PERIODACCT" = ?)) AND (t5.USER_ID = ?)) AND (((((t1.PRIMARY_KEY = t0.APPL_VENDOR_ID) AND (t2.ACCOUNT_ID$ = t0.PRIMARY_KEY)) AND (t3.PRIMARY_KEY = t0.PROJECT_ID)) AND (t4.PRIMARY_KEY = t0.DEFAULT_CATEGORY_ID)) AND (t5.ENTERPRISE_OBJECT_ID = t0.PRIMARY_KEY)))")
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:687)
    at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:530)
    at org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:529)

谢谢拉维库马尔

4

2 回答 2

2

你可以看看 Apache 的CollectionUils包。API 可以提供一些您可能已经在做的功能,但 API 可能会更有效地做到这一点。话虽这么说,但没有告诉我们您实际上在做什么,我们只能推测。

于 2012-05-02T06:31:57.010 回答
0

您是否考虑过一些延迟加载技术?

例如,在集合的实际迭代期间加载您的集合对象。

或者具有存储在集合中的实际对象的轻量级表示(例如只有对象的 DB 键)。

如果您想要高效的搜索,那么您应该考虑搜索引擎库,例如Lucene

于 2012-05-02T06:35:32.620 回答