@Override public Iterable<Entry<NamespaceKey, NameSpaceContainer>> find(String username, FindByCondition condition) { return factoryProvider.get() .get(username) .find(condition); }
private Iterable<Map.Entry<NamespaceKey, NameSpaceContainer>> getModifiedNamespaceContainers(long previousWakeupTime, Map<String, CollaborationTag> collaborationTagMap) { // if this is our first time, index everything as entities created in the previous versions will have a null last // modified time (we don't necessarily reindex on upgrade). if (previousWakeupTime <= 0) { return namespaceService.find(null); } final List<SearchQuery> queries = new ArrayList<>(); queries.add(newRangeLong(NamespaceIndexKeys.LAST_MODIFIED.getIndexFieldName(), previousWakeupTime, Long.MAX_VALUE, true, false)); // namespace ids that have modified collaboration tags queries.addAll(collaborationTagMap.keySet().stream().map( input -> newTermQuery(DatasetIndexKeys.DATASET_UUID.getIndexFieldName(), input) ).collect(Collectors.toList())); final FindByCondition condition = new FindByCondition().setCondition(or(queries)); return namespaceService.find(condition); }
public List<DatasetConfig> searchDatasets(String query) { final SearchQuery searchQuery; if (query == null || query.isEmpty()) { searchQuery = SearchQueryUtils.newMatchAllQuery(); } else { final ImmutableList.Builder<SearchQuery> builder = ImmutableList.builder(); for (final String name : MAPPING.getSearchAllIndexKeys()) { final String value; if (query.contains("*")) { value = query; } else { value = String.format("*%s*", query); } builder.add(SearchQueryUtils.newWildcardQuery(name, value)); } searchQuery = SearchQueryUtils.or(builder.build()); } final FindByCondition condition = new FindByCondition() .setCondition(searchQuery) .setLimit(100) // TODO(DX-10859): this should be in the function API .addSorting(DEFAULT_SORTING); final List<DatasetConfig> datasets = Lists.newArrayList(); for (Entry<NamespaceKey, NameSpaceContainer> entry : namespaceService.find(condition)) { if (entry.getValue().getType() == NameSpaceContainer.Type.DATASET) { datasets.add(entry.getValue().getDataset()); } } return datasets; }
/** * Get list of dataset paths depending on given dataset * @param path path of saved dataset * @return dataset paths of descendants. * @throws NamespaceException */ public Iterable<DatasetPath> getDescendants(DatasetPath path) throws NamespaceException { FindByCondition condition = new FindByCondition() .setCondition(SearchQueryUtils.newTermQuery(DATASET_ALLPARENTS, path.toNamespaceKey().toString())) .setLimit(1000); return Iterables.transform(namespaceService.find(condition), new Function<Entry<NamespaceKey, NameSpaceContainer>, DatasetPath>() { @Override public DatasetPath apply(Entry<NamespaceKey, NameSpaceContainer> input) { return new DatasetPath(input.getKey().getPathComponents()); } }); }
List<DatasetConfig> possibleMatches = FluentIterable.from(userNamespaceService.find(condition)).filter(new Predicate<Entry<NamespaceKey, NameSpaceContainer>>() { @Override public boolean apply(Entry<NamespaceKey, NameSpaceContainer> entry) {
if(!Iterables.isEmpty(userNamespaceService.find(new FindByCondition().setCondition( SearchQueryUtils.and( SearchQueryUtils.newTermQuery(NamespaceIndexKeys.ENTITY_TYPE.getIndexFieldName(), NameSpaceContainer.Type.DATASET.getNumber()),