List of usage examples for com.google.common.collect Iterables concat
public static <T> Iterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b)
From source file:sg.atom.utils._beta.functional.FunctionalIterable.java
public FunctionalIterable<T> concat(Iterable<T>... toConcat) { if (toConcat.length == 1) { return new FunctionalIterable<T>(Iterables.concat(delegate, toConcat[0])); }/* w w w . j a va2 s . c om*/ return new FunctionalIterable<T>(Iterables.concat(delegate, Iterables.concat(toConcat))); }
From source file:com.facebook.buck.cpp.AbstractNativeBuildable.java
@Override public Collection<Path> getInputsToCompareToOutput() { return SourcePaths.filterInputsToCompareToOutput(Iterables.concat(srcs, headers)); }
From source file:io.hops.transaction.lock.BlockLock.java
@Override protected void acquire(TransactionLocks locks) throws IOException { boolean individualBlockAlreadyRead = false; if (locks.containsLock(Type.INode)) { BaseINodeLock inodeLock = (BaseINodeLock) locks.getLock(Type.INode); Iterable blks = Collections.EMPTY_LIST; for (INode inode : inodeLock.getAllResolvedINodes()) { if (BaseINodeLock.isStoredInDB(inode)) { LOG.debug("Stuffed Inode: BlockLock. Skipping acquring locks on the inode named: " + inode.getLocalName() + " as the file is stored in the database"); announceEmptyFile(inode.getId()); continue; }/*from ww w . ja v a 2s.co m*/ if (inode instanceof INodeFile) { Collection<BlockInfoContiguous> inodeBlocks = Collections.EMPTY_LIST; if (((INodeFile) inode).hasBlocks()) { inodeBlocks = acquireLockList(DEFAULT_LOCK_TYPE, BlockInfoContiguous.Finder.ByINodeId, inode.getId()); } if (!individualBlockAlreadyRead) { individualBlockAlreadyRead = inode.getId() == inodeId; } if (inodeBlocks == null || inodeBlocks.isEmpty()) { announceEmptyFile(inode.getId()); } blks = Iterables.concat(blks, inodeBlocks); files.add((INodeFile) inode); } } } else if (locks.containsLock(Type.AllCachedBlock)) { AllCachedBlockLock cachedBlockLock = (AllCachedBlockLock) locks.getLock(Type.AllCachedBlock); Collection<io.hops.metadata.hdfs.entity.CachedBlock> cBlocks = cachedBlockLock .getAllResolvedCachedBlock(); Set<Long> blockIdSet = new HashSet<>(); for (io.hops.metadata.hdfs.entity.CachedBlock cBlock : cBlocks) { blockIdSet.add(cBlock.getBlockId()); } long[] blockIds = Longs.toArray(blockIdSet); long[] inodeIds = INodeUtil.resolveINodesFromBlockIds(blockIds); blocks.addAll(acquireLockList(DEFAULT_LOCK_TYPE, BlockInfoContiguous.Finder.ByBlockIdsAndINodeIds, blockIds, inodeIds)); } else { throw new TransactionLocks.LockNotAddedException( "BlockLock must come either after an InodeLock of a AllCachedBlockLock"); } if (!individualBlockAlreadyRead) { super.acquire(locks); } }
From source file:org.obiba.opal.web.project.permissions.ProjectSubjectPermissionsResource.java
/** * Delete all permissions of a subject in the project. * * @param domain//from ww w. j a v a2 s .c om * @param type * @return */ @DELETE public Response deleteSubjectPermissions(@QueryParam("type") @DefaultValue("USER") SubjectType type) { // make sure project exists projectService.getProject(name); SubjectAcl.Subject subject = type.subjectFor(principal); for (SubjectAclService.Permissions permissions : Iterables.concat( subjectAclService.getSubjectNodeHierarchyPermissions(DOMAIN, getProjectNode(), subject), subjectAclService.getSubjectNodeHierarchyPermissions(DOMAIN, getDatasourceNode(), subject))) { subjectAclService.deleteSubjectPermissions(DOMAIN, permissions.getNode(), subject); } return Response.ok().build(); }
From source file:org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.java
private void storeResult(JavaCompileSpec spec, WorkResult result) { ClasspathSnapshotData classpathSnapshot = classpathSnapshotProvider .getClasspathSnapshot(Iterables.concat(spec.getCompileClasspath(), spec.getModulePath())).getData(); AnnotationProcessingData annotationProcessingData = getAnnotationProcessingResult(spec, result); PreviousCompilationData data = new PreviousCompilationData(spec.getDestinationDir(), annotationProcessingData, classpathSnapshot, spec.getAnnotationProcessorPath()); stash.put(data);//w w w .j av a 2 s .c o m }
From source file:org.eclipse.ziggurat.collect.collectors.WidthCollector.java
/** * Width wise collection./*from w w w . j a va 2 s. c om*/ * * @param handler * the handler that processes each element. * @param element * : the current layer from which the collection is performed. * @throws CollectionAbortedException */ protected void collectWidthWise(ResultHandler<T> handler, Iterable<T> currentLayer) throws CollectionAbortedException { Iterable<T> nextLayer = Collections.emptyList(); while (currentLayer != null && !Iterables.isEmpty(currentLayer)) { for (T currentElement : currentLayer) { try { handler.handleResult(currentElement); //Building the next layer. for (Picker<T> picker : this.getPickers()) { Iterable<T> nexts = picker.getNexts(currentElement); //getting children. if (nexts != null) { nextLayer = Iterables.concat(nextLayer, nexts); } } } catch (CannotHandleException e) { //do nothing } catch (Exception e) { throw new CollectionAbortedException(e); } } //The current layer has been processed. Going through the next one. currentLayer = nextLayer; nextLayer = Collections.emptyList(); } }
From source file:org.apache.jackrabbit.oak.spi.commit.MoveTracker.java
public boolean containsMove(@CheckForNull String path) { if (path != null) { for (String p : Iterables.concat(parentSourcePaths, parentDestPaths)) { if (Text.isDescendantOrEqual(path, p)) { return true; }//from ww w . j a v a 2s . c o m } } return false; }
From source file:org.obiba.opal.web.project.permissions.ProjectPermissionsResource.java
@GET @Path("/subjects") public Iterable<Opal.Subject> getSubjects(@QueryParam("type") SubjectType type) { // make sure project exists projectService.getProject(name);/*from w ww. ja v a 2 s.c o m*/ Iterable<SubjectAclService.Permissions> permissions = Iterables.concat( subjectAclService.getNodeHierarchyPermissions(DOMAIN, getNode(), type), Iterables.filter(subjectAclService.getNodeHierarchyPermissions(DOMAIN, "/datasource/" + name, type), new MagmaPermissionsPredicate())); List<SubjectAcl.Subject> subjects = Lists.newArrayList(); for (SubjectAclService.Permissions perms : permissions) { SubjectAcl.Subject subject = perms.getSubject(); if (!subjects.contains(subject)) subjects.add(subject); } return Iterables.transform(subjects, new Function<SubjectAcl.Subject, Opal.Subject>() { @Nullable @Override public Opal.Subject apply(@Nullable SubjectAcl.Subject input) { assert input != null; return Opal.Subject.newBuilder().setPrincipal(input.getPrincipal()) .setType(Opal.Subject.SubjectType.valueOf(input.getType().name())).build(); } }); }
From source file:com.google.devtools.build.skyframe.CycleInfo.java
private static CycleInfo normalizeCycle(final SkyKey value, CycleInfo cycle) { int index = cycle.cycle.indexOf(value); if (index > -1) { if (!cycle.pathToCycle.isEmpty()) { // The head value we are considering is already part of a cycle, but we have reached it by a // roundabout way. Since we should have reached it directly as well, filter this roundabout // way out. Example (c has a dependence on top): // top // / ^ // a | // / \ / // b-> c // In the traversal, we start at top, visit a, then c, then top. This yields the // cycle {top,a,c}. Then we visit b, getting (b, {top,a,c}). Then we construct the full // error for a. The error should just be the cycle {top,a,c}, but we have an extra copy of // it via the path through b. return null; }/*from w ww . j a v a 2 s . c o m*/ return new CycleInfo(cycle.cycle, index); } return new CycleInfo(Iterables.concat(ImmutableList.of(value), cycle.pathToCycle), cycle.cycle); }
From source file:org.richfaces.cdk.templatecompiler.statements.SwitchStatement.java
@Override public Iterable<JavaField> getRequiredFields() { return Iterables.concat(super.getRequiredFields(), statement.getRequiredFields()); }