public CFPointWriterConfig(NetcdfFileWriter.Version version) { this(version, new Nc4ChunkingDefault()); // The default chunker used in Nc4Iosp. }
@Override public long[] computeChunking(Variable v) { // check attribute int[] resultFromAtt = computeChunkingFromAttribute(v); if (resultFromAtt != null) return convertToLong(resultFromAtt); int maxElements = defaultChunkSize / v.getElementSize(); // no unlimited dimensions if (!v.isUnlimited()) { int[] result = fillRightmost(v.getShape(), maxElements); return convertToLong(result); } // unlimited case int[] result = computeUnlimitedChunking(v.getDimensions(), v.getElementSize()); return convertToLong(result); }
public int[] computeUnlimitedChunking(List<Dimension> dims, int elemSize) { int maxElements = defaultChunkSize / elemSize; int[] result = fillRightmost(convertUnlimitedShape(dims), maxElements); long resultSize = new Section(result).computeSize(); if (resultSize < minChunksize) { maxElements = minChunksize / elemSize; result = incrUnlimitedShape(dims, result, maxElements); } return result; }
private void testOneStrategy(Dimension[] shape, int maxChunkElems, long expectSize) { List<Dimension> dims = Arrays.asList(shape); show("shape", dims); System.out.printf(" max = %d%n", maxChunkElems); Nc4ChunkingDefault chunker = new Nc4ChunkingDefault(); chunker.setDefaultChunkSize(maxChunkElems); chunker.setMinChunksize(maxChunkElems); int[] result = chunker.computeUnlimitedChunking(dims, 1); show("chunk", result); long shapeSize = new Section(result).computeSize(); System.out.printf(" size = %d%n%n", shapeSize); assert shapeSize <= maxChunkElems; assert shapeSize >= maxChunkElems/2; assert shapeSize == expectSize : shapeSize +" != "+ expectSize; }
private void testRealStrategy(Dimension[] shape, int elemSize) { List<Dimension> dims = Arrays.asList(shape); show("shape", dims); System.out.printf(" elemSize = %d%n", elemSize); Nc4ChunkingDefault chunker = new Nc4ChunkingDefault(); int[] result = chunker.computeUnlimitedChunking(dims, elemSize); show("chunk", result); long shapeSize = new Section(result).computeSize(); System.out.printf(" size = %d%n%n", shapeSize); int expectSize = chunker.getMinChunksize() / elemSize; assert shapeSize == expectSize : shapeSize +" != "+ expectSize; }
@Override public long[] computeChunking(Variable v) { /* check attribute int[] resultFromAtt = computeChunkingFromAttribute(v); if (resultFromAtt != null) return convertToLong(resultFromAtt); */ int maxElements = defaultChunkSize / v.getElementSize(); // no unlimited dimensions if (!v.isUnlimited()) { int[] result = fillRightmost(v.getShape(), maxElements); return convertToLong(result); } // unlimited case int[] result = computeUnlimitedChunking(v.getDimensions(), v.getElementSize()); return convertToLong(result); }
public CFPointWriterConfig(NetcdfFileWriter.Version version) { this(version, new Nc4ChunkingDefault()); // The default chunker used in Nc4Iosp. }
public int[] computeUnlimitedChunking(List<Dimension> dims, int elemSize) { int maxElements = defaultChunkSize / elemSize; int[] result = fillRightmost(convertUnlimitedShape(dims), maxElements); long resultSize = new Section(result).computeSize(); if (resultSize < minChunksize) { maxElements = minChunksize / elemSize; result = incrUnlimitedShape(dims, result, maxElements); } return result; }
/** * @param type Strategy type * @param deflateLevel 0 corresponds to no compression and 9 to maximum compression, * @param shuffle true to turn shuffling on which may improve compression. This option is ignored unless a non-zero deflation level is specified. * @return Nc4Chunking implementation */ public static Nc4Chunking factory(Strategy type, int deflateLevel, boolean shuffle) { switch (type) { case standard: return new Nc4ChunkingDefault(deflateLevel, shuffle); case grib: return new Nc4ChunkingStrategyGrib(deflateLevel, shuffle); case none: return new Nc4ChunkingStrategyNone(); } throw new IllegalArgumentException("Illegal Nc4Chunking.Standard " + type); }
/** * @param type Strategy type * @param deflateLevel 0 corresponds to no compression and 9 to maximum compression, * @param shuffle true to turn shuffling on which may improve compression. This option is ignored unless a non-zero deflation level is specified. * @return Nc4Chunking implementation */ public static Nc4Chunking factory(Strategy type, int deflateLevel, boolean shuffle) { switch (type) { case standard: return new Nc4ChunkingDefault(deflateLevel, shuffle); case grib: return new Nc4ChunkingStrategyGrib(deflateLevel, shuffle); case none: return new Nc4ChunkingStrategyNone(); } throw new IllegalArgumentException("Illegal Nc4Chunking.Standard " + type); }
private NetcdfFileWriter getWriter(File file, String outputFormat) throws IOException { if (NetCDFUtilities.NETCDF4_MIMETYPE.equalsIgnoreCase(outputFormat)) { version = Version.netcdf4_classic; } else { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Requested output format " + outputFormat + " isn't " + NetCDFUtilities.NETCDF4_MIMETYPE + "\nFallback to Version 3"); } // Version 3 as fallback (the Default) version = Version.netcdf3; } NetcdfFileWriter writer = null; if (version == Version.netcdf4_classic) { if (!NetCDFUtilities.isNC4CAvailable()) { throw new IOException(NetCDFUtilities.NC4_ERROR_MESSAGE); } Nc4Chunking chunker = new Nc4ChunkingDefault(compressionLevel, shuffle); writer = NetcdfFileWriter.createNew(version, file.getAbsolutePath(), chunker); } return writer != null ? writer : NetcdfFileWriter.createNew(Version.netcdf3, file.getAbsolutePath()); }
protected NetcdfFileWriter getWriter(File file, String outputFormat) throws IOException { if (NetCDFUtilities.NETCDF4_MIMETYPE.equalsIgnoreCase(outputFormat)) { version = NetcdfFileWriter.Version.netcdf4_classic; } else { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine( "Requested output format " + outputFormat + " isn't " + NetCDFUtilities.NETCDF4_MIMETYPE + "\nFallback to Version 3"); } // Version 3 as fallback (the Default) version = NetcdfFileWriter.Version.netcdf3; } NetcdfFileWriter writer = null; if (version == NetcdfFileWriter.Version.netcdf4_classic) { if (!NetCDFUtilities.isNC4CAvailable()) { throw new IOException(NetCDFUtilities.NC4_ERROR_MESSAGE); } Nc4Chunking chunker = new Nc4ChunkingDefault(compressionLevel, shuffle); writer = NetcdfFileWriter.createNew(version, file.getAbsolutePath(), chunker); } return writer != null ? writer : NetcdfFileWriter.createNew( NetcdfFileWriter.Version.netcdf3, file.getAbsolutePath()); }