List of usage examples for com.google.common.collect ImmutableSet isEmpty
boolean isEmpty();
From source file:org.elasticsearch.search.facet.terms.ip.TermsIpOrdinalsFacetCollector.java
public TermsIpOrdinalsFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<String> excluded) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms long facet collector on it"); }/*www .j av a2 s.c om*/ // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.LONG) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] is not of long type, can't run terms long facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (excluded == null || excluded.isEmpty()) { this.excluded = null; } else { this.excluded = new TLongHashSet(excluded.size()); for (String s : excluded) { this.excluded.add(Long.parseLong(s)); } } // minCount is offset by -1 if (allTerms) { minCount = -1; } else { minCount = 0; } this.aggregators = new ArrayList<ReaderAggregator>(context.searcher().getIndexReader().leaves().size()); }
From source file:org.elasticsearch.search.facet.terms.longs.TermsLongOrdinalsFacetCollector.java
public TermsLongOrdinalsFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms long facet collector on it"); }//from w ww. j av a 2s. c o m // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.LONG) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] is not of long type, can't run terms long facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (excluded == null || excluded.isEmpty()) { this.excluded = null; } else { this.excluded = new TLongHashSet(excluded.size()); for (BytesRef s : excluded) { this.excluded.add(Long.parseLong(s.utf8ToString())); } } // minCount is offset by -1 if (allTerms) { minCount = -1; } else { minCount = 0; } this.aggregators = new ArrayList<ReaderAggregator>(context.searcher().getIndexReader().leaves().size()); }
From source file:org.elasticsearch.search.facet.terms.bytes.TermsByteOrdinalsFacetCollector.java
public TermsByteOrdinalsFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms byte facet collector on it"); }/*from w ww. j ava 2 s . c o m*/ // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.BYTE) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] is not of byte type, can't run terms byte facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (excluded == null || excluded.isEmpty()) { this.excluded = null; } else { this.excluded = new TByteHashSet(excluded.size()); for (BytesRef s : excluded) { this.excluded.add(Byte.parseByte(s.utf8ToString())); } } // minCount is offset by -1 if (allTerms) { minCount = -1; } else { minCount = 0; } this.aggregators = new ArrayList<ReaderAggregator>(context.searcher().getIndexReader().leaves().size()); }
From source file:org.elasticsearch.search.facet.terms.shorts.TermsShortOrdinalsFacetCollector.java
public TermsShortOrdinalsFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms short facet collector on it"); }/*from w ww . j a va 2 s . c o m*/ // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.SHORT) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] is not of short type, can't run terms short facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (excluded == null || excluded.isEmpty()) { this.excluded = null; } else { this.excluded = new TShortHashSet(excluded.size()); for (BytesRef s : excluded) { this.excluded.add(Short.parseShort(s.utf8ToString())); } } // minCount is offset by -1 if (allTerms) { minCount = -1; } else { minCount = 0; } this.aggregators = new ArrayList<ReaderAggregator>(context.searcher().getIndexReader().leaves().size()); }
From source file:org.elasticsearch.search.facet.terms.floats.TermsFloatOrdinalsFacetCollector.java
public TermsFloatOrdinalsFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms float facet collector on it"); }/* ww w .j a va 2s . co m*/ // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.FLOAT) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] is not of float type, can't run terms float facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (excluded == null || excluded.isEmpty()) { this.excluded = null; } else { this.excluded = new TFloatHashSet(excluded.size()); for (BytesRef s : excluded) { this.excluded.add(Float.parseFloat(s.utf8ToString())); } } // minCount is offset by -1 if (allTerms) { minCount = -1; } else { minCount = 0; } this.aggregators = new ArrayList<ReaderAggregator>(context.searcher().getIndexReader().leaves().size()); }
From source file:org.elasticsearch.search.facet.terms.doubles.TermsDoubleOrdinalsFacetCollector.java
public TermsDoubleOrdinalsFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms double facet collector on it"); }//from w w w . ja v a2 s . c om // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.DOUBLE) { throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] is not of double type, can't run terms double facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (excluded == null || excluded.isEmpty()) { this.excluded = null; } else { this.excluded = new TDoubleHashSet(excluded.size()); for (BytesRef s : excluded) { this.excluded.add(Double.parseDouble(s.utf8ToString())); } } // minCount is offset by -1 if (allTerms) { minCount = -1; } else { minCount = 0; } this.aggregators = new ArrayList<ReaderAggregator>(context.searcher().getIndexReader().leaves().size()); }
From source file:com.facebook.buck.android.UberRDotJavaBuildable.java
@Override public List<Step> getBuildSteps(BuildContext context, final BuildableContext buildableContext) throws IOException { ImmutableList.Builder<Step> steps = ImmutableList.builder(); AndroidResourceDetails androidResourceDetails = androidResourceDepsFinder.getAndroidResourceDetails(); final Set<String> rDotJavaPackages = androidResourceDetails.rDotJavaPackages; final ImmutableSet<String> resDirectories; final Supplier<ImmutableSet<String>> nonEnglishStringFiles; if (requiresResourceFilter()) { final FilterResourcesStep filterResourcesStep = createFilterResourcesStep( androidResourceDetails.resDirectories, androidResourceDetails.whitelistedStringDirs); steps.add(filterResourcesStep);/*from w ww. j ava2s . c om*/ resDirectories = filterResourcesStep.getOutputResourceDirs(); nonEnglishStringFiles = new Supplier<ImmutableSet<String>>() { @Override public ImmutableSet<String> get() { return FluentIterable.from(filterResourcesStep.getNonEnglishStringFiles()) .transform(Functions.toStringFunction()).toSet(); } }; for (String outputResourceDir : resDirectories) { buildableContext.recordArtifactsInDirectory(Paths.get(outputResourceDir)); } } else { resDirectories = androidResourceDetails.resDirectories; nonEnglishStringFiles = Suppliers.ofInstance(ImmutableSet.<String>of()); } if (!resDirectories.isEmpty()) { generateAndCompileRDotJavaFiles(resDirectories, rDotJavaPackages, steps, buildableContext); } steps.add(new AbstractExecutionStep("record_build_output") { @Override public int execute(ExecutionContext context) { buildableContext.addMetadata(RES_DIRECTORIES_KEY, resDirectories); buildableContext.addMetadata(NON_ENGLISH_STRING_FILES_KEY, nonEnglishStringFiles.get()); return 0; } }); return steps.build(); }
From source file:org.elasticsearch.search.facet.terms.strings.FieldsTermsStringFacetCollector.java
public FieldsTermsStringFacetCollector(String facetName, String[] fieldsNames, int size, InternalStringTermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded, Pattern pattern, String scriptLang, String script, Map<String, Object> params) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); fieldsDataType = new FieldDataType[fieldsNames.length]; fieldsData = new FieldData[fieldsNames.length]; indexFieldsNames = new String[fieldsNames.length]; for (int i = 0; i < fieldsNames.length; i++) { MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldsNames[i]); if (smartMappers == null || !smartMappers.hasMapper()) { this.indexFieldsNames[i] = fieldsNames[i]; this.fieldsDataType[i] = FieldDataType.DefaultTypes.STRING; } else {/*from ww w. j a v a 2s . c o m*/ this.indexFieldsNames[i] = smartMappers.mapper().names().indexName(); this.fieldsDataType[i] = smartMappers.mapper().fieldDataType(); } } if (script != null) { this.script = context.scriptService().search(context.lookup(), scriptLang, script, params); } else { this.script = null; } if (excluded.isEmpty() && pattern == null && this.script == null) { aggregator = new StaticAggregatorValueProc(CacheRecycler.<BytesRef>popObjectIntMap()); } else { aggregator = new AggregatorValueProc(CacheRecycler.<BytesRef>popObjectIntMap(), excluded, pattern, this.script); } if (allTerms) { try { for (int i = 0; i < fieldsNames.length; i++) { for (AtomicReaderContext readerContext : context.searcher().getTopReaderContext().leaves()) { FieldData fieldData = fieldDataCache.cache(fieldsDataType[i], readerContext.reader(), indexFieldsNames[i]); fieldData.forEachValue(aggregator); } } } catch (Exception e) { throw new FacetPhaseExecutionException(facetName, "failed to load all terms", e); } } }
From source file:org.elasticsearch.search.facet.terms.strings.TermsStringOrdinalsFacetCollector.java
public TermsStringOrdinalsFacetCollector(String facetName, String fieldName, int size, TermsFacet.ComparatorType comparatorType, boolean allTerms, SearchContext context, ImmutableSet<BytesRef> excluded, Pattern pattern) { super(facetName); this.fieldDataCache = context.fieldDataCache(); this.size = size; this.comparatorType = comparatorType; this.numberOfShards = context.numberOfShards(); MapperService.SmartNameFieldMappers smartMappers = context.smartFieldMappers(fieldName); if (smartMappers == null || !smartMappers.hasMapper()) { throw new ElasticSearchIllegalArgumentException( "Field [" + fieldName + "] doesn't have a type, can't run terms long facet collector on it"); }/* w w w . ja v a2 s. co m*/ // add type filter if there is exact doc mapper associated with it if (smartMappers.explicitTypeInNameWithDocMapper()) { setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter())); } if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.STRING) { throw new ElasticSearchIllegalArgumentException("Field [" + fieldName + "] is not of string type, can't run terms string facet collector on it"); } this.indexFieldName = smartMappers.mapper().names().indexName(); this.fieldDataType = smartMappers.mapper().fieldDataType(); if (excluded == null || excluded.isEmpty()) { this.excluded = null; } else { this.excluded = excluded; } this.matcher = pattern != null ? pattern.matcher("") : null; // minCount is offset by -1 if (allTerms) { minCount = -1; } else { minCount = 0; } this.aggregators = new ArrayList<ReaderAggregator>(context.searcher().getIndexReader().leaves().size()); }
From source file:com.facebook.buck.cli.ProjectCommand.java
/** * Run xcode specific project generation actions. */// w ww . j ava2 s .c om int runXcodeProjectGenerator(ProjectCommandOptions options) throws IOException { PartialGraph partialGraph; try { partialGraph = PartialGraph.createFullGraph(getProjectFilesystem(), options.getDefaultIncludes(), getParser(), getBuckEventBus()); } catch (BuildTargetException | BuildFileParseException e) { throw new HumanReadableException(e); } ImmutableSet<BuildTarget> passedInTargetsSet; try { List<String> argumentsAsBuildTargets = options.getArgumentsFormattedAsBuildTargets(); passedInTargetsSet = ImmutableSet.copyOf(getBuildTargets(argumentsAsBuildTargets)); } catch (NoSuchBuildTargetException e) { throw new HumanReadableException(e); } ExecutionContext executionContext = createExecutionContext(options, partialGraph.getDependencyGraph()); if (options.getCombinedProject() != null) { // Generate a single project containing a target and all its dependencies and tests. ProjectGenerator projectGenerator = new ProjectGenerator(partialGraph, passedInTargetsSet, getProjectFilesystem(), executionContext, getProjectFilesystem().getPathForRelativePath(Paths.get("_gen")), "GeneratedProject", ProjectGenerator.COMBINED_PROJECT_OPTIONS); projectGenerator.createXcodeProjects(); console.getStdOut().println(projectGenerator.getProjectPath()); } else { // Generate projects based on xcode_project_config rules, and place them in the same directory // as the Buck file. ImmutableSet<BuildTarget> targets; if (passedInTargetsSet.isEmpty()) { ImmutableSet.Builder<BuildTarget> targetsBuilder = ImmutableSet.builder(); for (BuildRule node : partialGraph.getDependencyGraph().getNodes()) { if (node.getType() == XcodeProjectConfigDescription.TYPE) { targetsBuilder.add(node.getBuildTarget()); } } targets = targetsBuilder.build(); } else { targets = passedInTargetsSet; } SeparatedProjectsGenerator projectGenerator = new SeparatedProjectsGenerator(getProjectFilesystem(), partialGraph, executionContext, targets); ImmutableSet<Path> generatedProjectPaths = projectGenerator.generateProjects(); for (Path path : generatedProjectPaths) { console.getStdOut().println(path.toString()); } } return 0; }