@Transactional(readOnly = true) // ticket:5232 public Object doWork(Session session, ServiceFactory sf) { return pixDataSrv.getPixelBuffer(pixelsObj, false); } });
public PixelBuffer _getPixelBuffer(Pixels pixels, boolean write) final String originalFilePath = getOriginalFilePath(pixels); final boolean requirePyramid = requiresPixelsPyramid(pixels); final String pixelsFilePath = getPixelsPath(pixels.getId()); final File pixelsFile = new File(pixelsFilePath); final String pixelsPyramidFilePath = pixelsFilePath + PYRAMID_SUFFIX; int series = getSeries(pixels); PixelBuffer bfPixelBuffer = createBfPixelBuffer( originalFilePath, series); if (bfPixelBuffer.getResolutionLevels() > 1) { handleMissingPyramid(pixels, pixelsPyramidFilePath); handleMissingStatsInfo(pixels); return createPyramidPixelBuffer(pixels, pixelsPyramidFilePath, write); return createPyramidPixelBuffer(pixels, pixelsPyramidFilePath, write); } else { if (originalFilePath != null) { int series = getSeries(pixels); return createBfPixelBuffer(originalFilePath, series); createSubpath(pixelsFilePath); return createRomioPixelBuffer(pixelsFilePath, pixels, write); return createRomioPixelBuffer(pixelsFilePath, pixels, false);
/** * Returns a pixel buffer for a given set of pixels. Either a proprietary * ROMIO pixel buffer or a specific pixel buffer implementation. * @param pixels Pixels set to retrieve a pixel buffer for. * @param write Whether or not to open the pixel buffer as read-write. * <code>true</code> opens as read-write, <code>false</code> opens as * read-only. * @return A pixel buffer instance. * @since OMERO-Beta4.3 */ public PixelBuffer getPixelBuffer(Pixels pixels, boolean write) { PixelBuffer pb = _getPixelBuffer(pixels, write); if (log.isDebugEnabled()) { log.debug(pb +" for " + pixels); } return pb; }
/** * Short-cut in the FS case where we know that we are dealing with a FS-lite * file, and want to retrieve the actual file as opposed to a pyramid or anything * else. This may be used to access the original metadata. * @throws FormatException * @throws IOException */ public IFormatReader getBfReader(Pixels pixels) throws FormatException, IOException { // from getPixelBuffer final String originalFilePath = getOriginalFilePath(pixels); final int series = getSeries(pixels); final IFormatReader reader = createBfReader(); reader.setId(originalFilePath); // Called by BfPixelsBuffer elsewhere. reader.setSeries(series); return reader; }
/** * Creates a PixelBuffer for a given pixels set. * * @param pixels Pixels set to create a pixel buffer for. * @return Allocated pixel buffer ready to be used. * @throws IOException If there is an I/O error creating the pixel buffer * backing file. */ public PixelBuffer createPixelBuffer(Pixels pixels) throws IOException { RomioPixelBuffer pixbuf = new RomioPixelBuffer(getPixelsPath(pixels .getId()), pixels, true); initPixelBuffer(pixbuf); return pixbuf; }
final String pixelsFilePath = getPixelsPath(pixels.getId()); final File pixelsFile = new File(pixelsFilePath); final String pixelsPyramidFilePath = pixelsFilePath + PYRAMID_SUFFIX; final File pixelsPyramidFile = new File(pixelsPyramidFilePath); final String originalFilePath = getOriginalFilePath(pixels); final boolean requirePyramid = requiresPixelsPyramid(pixels); int series = getSeries(pixels); final PixelsPyramidMinMaxStore minMaxStore = new PixelsPyramidMinMaxStore(pixels.getSizeC()); BfPixelBuffer bfPixelBuffer = createMinMaxBfPixelBuffer( originalFilePath, series, minMaxStore); final BfPyramidPixelBuffer pixelsPyramid = createPyramidPixelBuffer( pixels, pixelsPyramidFilePath, true); PixelsPyramidMinMaxStore minMaxStore = performWrite( pixels, pixelsPyramidFile, pixelsPyramid, pixelsFile, pixelsFilePath, originalFilePath);
/** * Returns whether a pyramid should be used for the given {@link Pixels}. * This usually implies that this is a "Big image" and therefore will * need tiling. * * @see PixelsService#requiresPixelsPyramid(Pixels) * @param pix the pixels * @return {@code true} if a pyramid should be used, {@code false} * otherwise */ public boolean requiresPixelsPyramid(Pixels pix) { return data.requiresPixelsPyramid(pix); }
/** * Create an {@link IFormatReader} with the appropriate {@link loci.formats.ReaderWrapper} * instances and {@link IFormatReader#setFlattenedResolutions(boolean)} set to false. */ protected IFormatReader createBfReader() { IFormatReader reader = new ImageReader(); reader = new ChannelFiller(reader); reader = new ChannelSeparator(reader); if (memoizerDirectoryLocalRW == null) { reader = new Memoizer(reader, getMemoizerWait(), getMemoizerDirectory()); } else { reader = new MemoizerFallback(reader, getMemoizerWait(), memoizerDirectoryLocalRW, Collections.singleton( new MemoizerReadOnly(reader, getMemoizerWait(), getMemoizerDirectory()))); } reader.setFlattenedResolutions(false); reader.setMetadataFiltered(true); return reader; }
String path = getPixelsPath(pixbuf.getId()); createSubpath(path); Integer size = RomioPixelBuffer.safeLongToInteger(pixbuf.getPlaneSize()); byte[] padding = new byte[size - NULL_PLANE_SIZE];
/** * Removes files from data repository based on a parameterized List of Long * pixels ids * * @param pixelIds Long file keys to be deleted * @throws ResourceError If deletion fails. */ public void removePixels(List<Long> pixelIds) { File file; String fileName; boolean success = false; for (Iterator<Long> iter = pixelIds.iterator(); iter.hasNext();) { Long id = iter.next(); String pixelPath = getPixelsPath(id); file = new File(pixelPath); fileName = file.getName(); if (file.exists()) { success = file.delete(); if (!success) { throw new ResourceError( "Pixels " + fileName + " deletion failed"); } else { if (log.isInfoEnabled()) { log.info("INFO: Pixels " + fileName + " deleted."); } } } } }
/** * Use {@link PixelsService} to find pre-FS binary files under * "/OMERO/Files", "/OMERO/Pixels", and "/OMERO/Thumbnails", * and store their size in the response. */ private void findBinary() { IQuery query = helper.getServiceFactory().getQueryService(); Pixels pixels = query.get(Image.class, imageId).getPrimaryPixels(); List<Thumbnail> thumbs = query.findAllByQuery( "select tb from Thumbnail tb where " + "tb.pixels.id = :id", new Parameters().addId(pixels.getId())); String path = pixelsService.getPixelsPath(pixels.getId()); files = new PixelFiles(path); files.update(rsp); for (Thumbnail tb: thumbs) { path = pixelsService.getThumbnailPath(tb.getId()); File thumbnailFile = new File(path); thumbnailFiles.add(thumbnailFile); rsp.thumbnailSize += thumbnailFile.length(); } }
source = createRomioPixelBuffer(pixelsFilePath, pixels, false); int series = getSeries(pixels); BfPixelBuffer bfPixelBuffer = createMinMaxBfPixelBuffer( originalFilePath, series, minMaxStore); pixelsPyramid.setByteOrder(
/** * Helper method to properly log any exceptions raised by Bio-Formats. * @param filePath Non-null. * @param series series to use * @return the initialized {@link BfPixelBuffer} */ protected BfPixelBuffer createBfPixelBuffer(final String filePath, final int series) { try { IFormatReader reader = createBfReader(); BfPixelBuffer pixelBuffer = new BfPixelBuffer(filePath, reader); pixelBuffer.setSeries(series); log.info(String.format("Creating BfPixelBuffer: %s Series: %d", filePath, series)); return pixelBuffer; } catch (Exception e) { String msg = "Error instantiating pixel buffer: " + filePath; log.error(msg, e); throw new ResourceError(msg); } }
@RolesAllowed("user") public boolean requiresPixelsPyramid() { rwl.writeLock().lock(); try { errorIfInvalidState(); return pixDataSrv.requiresPixelsPyramid(pixelsObj); } finally { rwl.writeLock().unlock(); } }
@Override public Ice.Object create(String name) { ManagedImportRequestI mir = new ManagedImportRequestI(reg, sizes, dao, new OMEROWrapper( new ImportConfig(), pixels.getMemoizerWait(), pixels.getMemoizerDirectory()), ring.uuid); mir.setResources(resources); return mir; }
final Long ownerId = (Long) resultRow[1]; final Long groupId = (Long) resultRow[2]; final String pixelsPath = pixelsService.getPixelsPath(pixelsId); usage.bumpTotals().add(ownerId, groupId, className, getFileSize(pixelsPath)); usage.bumpTotals().add(ownerId, groupId, className, getFileSize(pixelsPath + PixelsService.PYRAMID_SUFFIX));
/** * Helper method to properly log any exceptions raised by Bio-Formats and * add a min/max calculator wrapper to the reader stack. * @param filePath Non-null. * @param series series to use * @param store Min/max store to use with the min/max calculator. */ protected BfPixelBuffer createMinMaxBfPixelBuffer(final String filePath, final int series, final IMinMaxStore store) { try { IFormatReader reader = createBfReader(); MinMaxCalculator calculator = new MinMaxCalculator(reader); calculator.setMinMaxStore(store); BfPixelBuffer pixelBuffer = new BfPixelBuffer(filePath, calculator); pixelBuffer.setSeries(series); log.info(String.format("Creating BfPixelBuffer: %s Series: %d", filePath, series)); return pixelBuffer; } catch (Exception e) { String msg = "Error instantiating pixel buffer: " + filePath; log.error(msg, e); throw new ResourceError(msg); } }
/** * Returns a pixel buffer for a given set of pixels. Either a proprietary * ROMIO pixel buffer or a specific pixel buffer implementation. * @param pixels Pixels set to retrieve a pixel buffer for. * @return A pixel buffer instance. <b>NOTE:</b> The pixel buffer is * initialized as <b>read-write</b>. * @deprecated In the future callers should use the more descriptive * {@link #getPixelBuffer(Pixels, boolean)}. * @since OMERO-Beta4.3 * @see #getPixelBuffer(Pixels, boolean) */ @Deprecated public PixelBuffer getPixelBuffer(Pixels pixels) { return getPixelBuffer(pixels, true); }
@RolesAllowed("user") public synchronized boolean requiresPixelsPyramid() { errorIfNotLoaded(); return dataService.requiresPixelsPyramid(pixelsInstance); }
final Long ownerId = (Long) resultRow[1]; final Long groupId = (Long) resultRow[2]; final String pixelsPath = pixelsService.getPixelsPath(pixelsId); usage.bumpTotals().add(ownerId, groupId, className, getFileSize(pixelsPath)); usage.bumpTotals().add(ownerId, groupId, className, getFileSize(pixelsPath + PixelsService.PYRAMID_SUFFIX));