Java Code Examples for org.apache.atlas.model.discovery.SearchParameters#setLimit()
The following examples show how to use
org.apache.atlas.model.discovery.SearchParameters#setLimit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AtlasAuditService.java From atlas with Apache License 2.0 | 6 votes |
private SearchParameters getSearchParameters(AuditSearchParameters auditSearchParameters) throws AtlasBaseException { SearchParameters searchParameters = new SearchParameters(); searchParameters.setTypeName(ENTITY_TYPE_AUDIT_ENTRY); SearchParameters.FilterCriteria validFilter = getNonEmptyFilter(auditSearchParameters.getAuditFilters()); searchParameters.setEntityFilters(validFilter); searchParameters.setLimit(auditSearchParameters.getLimit()); searchParameters.setOffset(auditSearchParameters.getOffset()); String sortBy = auditSearchParameters.getSortBy(); validateSortByParameter(sortBy); searchParameters.setSortBy(auditSearchParameters.getSortBy()); searchParameters.setSortOrder(auditSearchParameters.getSortOrder()); return searchParameters; }
Example 2
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 6 votes |
@Test(priority = -1) public void searchWithNEQ_stringAttr() throws AtlasBaseException { String expectedEntityName = "hive_Table_Null_tableType"; createDummyEntity(expectedEntityName,HIVE_TABLE_TYPE); SearchParameters params = new SearchParameters(); params.setTypeName(HIVE_TABLE_TYPE); SearchParameters.FilterCriteria filterCriteria = getSingleFilterCondition("tableType", SearchParameters.Operator.NEQ, "Managed"); params.setEntityFilters(filterCriteria); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, indexer.getVertexIndexKeys()); EntitySearchProcessor processor = new EntitySearchProcessor(context); List<AtlasVertex> vertices = processor.execute(); assertEquals(vertices.size(), 3); List<String> nameList = new ArrayList<>(); for (AtlasVertex vertex : vertices) { nameList.add((String) entityRetriever.toAtlasEntityHeader(vertex, Collections.singleton("name")).getAttribute("name")); } assertTrue(nameList.contains(expectedEntityName)); }
Example 3
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 6 votes |
@Test(dependsOnMethods = "searchWithNEQ_stringAttr") public void searchWithNEQ_pipeSeperatedAttr() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(HIVE_TABLE_TYPE); SearchParameters.FilterCriteria filterCriteria = getSingleFilterCondition("__classificationNames", SearchParameters.Operator.NEQ, METRIC_CLASSIFICATION); params.setEntityFilters(filterCriteria); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, indexer.getVertexIndexKeys()); EntitySearchProcessor processor = new EntitySearchProcessor(context); List<AtlasVertex> vertices = processor.execute(); assertEquals(vertices.size(), 7); List<String> nameList = new ArrayList<>(); for (AtlasVertex vertex : vertices) { nameList.add((String) entityRetriever.toAtlasEntityHeader(vertex, Collections.singleton("name")).getAttribute("name")); } assertTrue(nameList.contains("hive_Table_Null_tableType")); }
Example 4
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 6 votes |
@Test(dependsOnMethods = "searchWithNEQ_stringAttr") public void searchWithNEQ_doubleAttr() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(HIVE_TABLE_TYPE); SearchParameters.FilterCriteria filterCriteria = getSingleFilterCondition("retention", SearchParameters.Operator.NEQ, "5"); params.setEntityFilters(filterCriteria); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, indexer.getVertexIndexKeys()); EntitySearchProcessor processor = new EntitySearchProcessor(context); List<AtlasVertex> vertices = processor.execute(); assertEquals(vertices.size(), 1); List<String> nameList = new ArrayList<>(); for (AtlasVertex vertex : vertices) { nameList.add((String) entityRetriever.toAtlasEntityHeader(vertex, Collections.singleton("name")).getAttribute("name")); } assertTrue(nameList.contains("hive_Table_Null_tableType")); }
Example 5
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void ALLEntityType() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(SearchParameters.ALL_ENTITY_TYPES); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); EntitySearchProcessor processor = new EntitySearchProcessor(context); assertEquals(processor.execute().size(), 20); }
Example 6
Source File: FreeTextSearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void searchTablesByName() throws AtlasBaseException, InterruptedException { SearchParameters params = new SearchParameters(); params.setTypeName("hive_table"); params.setQuery("sales"); params.setExcludeDeletedEntities(true); params.setLimit(3); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); FreeTextSearchProcessor processor = new FreeTextSearchProcessor(context); assertEquals(processor.getResultCount(), 3); assertEquals(processor.execute().size(), 3); }
Example 7
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void searchWithEntityTypesAndEntityFiltersAndTag() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(DATABASE_TYPE+","+HIVE_TABLE_TYPE); SearchParameters.FilterCriteria filterCriteria = getSingleFilterCondition("owner", SearchParameters.Operator.CONTAINS, "ETL"); params.setEntityFilters(filterCriteria); params.setClassification(LOGDATA_CLASSIFICATION); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); EntitySearchProcessor processor = new EntitySearchProcessor(context); assertEquals(processor.execute().size(), 2); }
Example 8
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void searchWithEntityTypesAndEntityFilters() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(DATABASE_TYPE+","+HIVE_TABLE_TYPE); SearchParameters.FilterCriteria filterCriteria = getSingleFilterCondition("owner", SearchParameters.Operator.CONTAINS, "ETL"); params.setEntityFilters(filterCriteria); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); EntitySearchProcessor processor = new EntitySearchProcessor(context); assertEquals(processor.execute().size(), 4); }
Example 9
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void entityTypesAndTag() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(DATABASE_TYPE+","+HIVE_TABLE_TYPE); params.setClassification(FACT_CLASSIFICATION); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); EntitySearchProcessor processor = new EntitySearchProcessor(context); assertEquals(processor.execute().size(), 3); }
Example 10
Source File: FreeTextSearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void emptySearch() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName("hive_table"); params.setQuery("not_exists"); params.setExcludeDeletedEntities(true); params.setLimit(3); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); FreeTextSearchProcessor processor = new FreeTextSearchProcessor(context); assertEquals(processor.getResultCount(), 0); assertEquals(processor.execute().size(), 0); }
Example 11
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test(expectedExceptions = AtlasBaseException.class, expectedExceptionsMessageRegExp = "Not_Exists: Unknown/invalid typename") public void entityTypesNotAllowed() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(DATABASE_TYPE+",Not_Exists"); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); }
Example 12
Source File: FreeTextSearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void searchByNameSortBy() throws AtlasBaseException, InterruptedException { SearchParameters params = new SearchParameters(); params.setTypeName("hive_table"); params.setQuery("sales"); params.setExcludeDeletedEntities(true); params.setLimit(3); params.setSortBy("owner"); params.setSortOrder(SortOrder.ASCENDING); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); FreeTextSearchProcessor processor = new FreeTextSearchProcessor(context); List<AtlasVertex> vertices = processor.execute(); assertEquals(processor.getResultCount(), 3); assertEquals(vertices.size(), 3); AtlasVertex firstVertex = vertices.get(0); String firstOwner = (String) entityRetriever.toAtlasEntityHeader(firstVertex, Sets.newHashSet(params.getSortBy())).getAttribute(params.getSortBy()); AtlasVertex secondVertex = vertices.get(1); String secondOwner = (String) entityRetriever.toAtlasEntityHeader(secondVertex, Sets.newHashSet(params.getSortBy())).getAttribute(params.getSortBy()); assertEquals(firstOwner, "Jane BI"); assertEquals(secondOwner, "Joe"); }
Example 13
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void entityType() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(DATABASE_TYPE); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); EntitySearchProcessor processor = new EntitySearchProcessor(context); assertEquals(processor.execute().size(), 3); }
Example 14
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void ALLEntityTypeWithTag() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(SearchParameters.ALL_ENTITY_TYPES); params.setClassification(FACT_CLASSIFICATION); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); EntitySearchProcessor processor = new EntitySearchProcessor(context); assertEquals(processor.execute().size(), 5); }
Example 15
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test(expectedExceptions = AtlasBaseException.class, expectedExceptionsMessageRegExp = "NotExisting: Unknown/invalid classification") public void searchByNonExistingClassification() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName("hive_process"); params.setClassification("NotExisting"); params.setLimit(10); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); new EntitySearchProcessor(context); }
Example 16
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void emptySearchByClassification() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName("hive_table"); params.setClassification("PII"); params.setLimit(10); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); EntitySearchProcessor processor = new EntitySearchProcessor(context); assertEquals(processor.getResultCount(), 0); assertEquals(processor.execute().size(), 0); }
Example 17
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void searchByClassificationSortBy() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName("hive_table"); params.setClassification("Metric"); params.setLimit(10); params.setSortBy("createTime"); params.setSortOrder(SortOrder.ASCENDING); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); EntitySearchProcessor processor = new EntitySearchProcessor(context); List<AtlasVertex> vertices = processor.execute(); assertEquals(processor.getResultCount(), 4); assertEquals(vertices.size(), 4); AtlasVertex firstVertex = vertices.get(0); Date firstDate = (Date) entityRetriever.toAtlasEntityHeader(firstVertex, Sets.newHashSet(params.getSortBy())).getAttribute(params.getSortBy()); AtlasVertex secondVertex = vertices.get(1); Date secondDate = (Date) entityRetriever.toAtlasEntityHeader(secondVertex, Sets.newHashSet(params.getSortBy())).getAttribute(params.getSortBy()); assertTrue(firstDate.before(secondDate)); }
Example 18
Source File: EntitySearchProcessorTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void searchTablesByClassification() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName("hive_column"); params.setClassification("PII"); params.setLimit(10); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); EntitySearchProcessor processor = new EntitySearchProcessor(context); assertEquals(processor.getResultCount(), 4); assertEquals(processor.execute().size(), 4); }
Example 19
Source File: BasicSearchClassificationTest.java From atlas with Apache License 2.0 | 5 votes |
@Test public void searchByALLTagAndIndexSysFiltersToTestLimit() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setClassification(ALL_CLASSIFICATION_TYPES); FilterCriteria filterCriteria = getSingleFilterCondition("__timestamp", Operator.LT, String.valueOf(System.currentTimeMillis())); params.setTagFilters(filterCriteria); params.setLimit(totalClassifiedEntities - 2); List<AtlasEntityHeader> entityHeaders = discoveryService.searchWithParameters(params).getEntities(); assertEquals(entityHeaders.size(), totalClassifiedEntities - 2); }
Example 20
Source File: TableReplicationRequestProcessor.java From atlas with Apache License 2.0 | 4 votes |
private Set<String> getGuidsToDelete(String dbName, List<String> excludeGUIDs, String sourceCluster) throws AtlasBaseException { SearchParameters parameters = getSearchParameters(dbName, sourceCluster); Set<String> unsafeGUIDs = new HashSet<>(); final int max = 10000; int fetchedSize = 0; int i = 0; parameters.setLimit(max); while (fetchedSize == (max * i)) { if (LOG.isDebugEnabled()) { LOG.debug("i={}, fetchedSize={}, unsafeGUIDs.size()={}", i, fetchedSize, unsafeGUIDs.size()); } int offset = max * i; parameters.setOffset(offset); AtlasSearchResult searchResult = discoveryService.searchWithParameters(parameters); if (CollectionUtils.isEmpty(searchResult.getEntities())) { break; } else { if (LOG.isDebugEnabled()) { LOG.debug("getGuidsToDelete: {}", searchResult.getApproximateCount()); } } String classificationName = String.format(REPLICATED_TAG_NAME, sourceCluster); for (AtlasEntityHeader entityHeader : searchResult.getEntities()) { if (!entityHeader.getClassificationNames().contains(classificationName)) { continue; } String guid = entityHeader.getGuid(); if (!excludeGUIDs.contains(guid)) { unsafeGUIDs.add(guid); } } fetchedSize = searchResult.getEntities().size(); i++; } return unsafeGUIDs; }