instantiate( infoFile ); List<File> blobFiles = new ArrayList<File>(); long totalSize = 0; setTilesPerBlob( (int) ( blobFiles.get( 0 ).length() / getBytesPerTile() ) ); long expectedBlobSize = getTileRows() * getTileColumns() * getBytesPerTile(); if ( expectedBlobSize != totalSize ) { String msg = "Size of grid (all blob file) (=" + totalSize + ") does not match the expected size (="
@Override public BufferResult read( RasterRect rect, ByteBuffer resultBuffer ) throws IOException { BufferResult res = null; RasterRect fRect = snapToGrid( rect ); if ( fRect != null ) { int[] minCRmaxCR = getIntersectingTiles( fRect ); if ( minCRmaxCR == null ) { return null; } int size = fRect.width * fRect.height * sampleSize; if ( resultBuffer == null ) { resultBuffer = ByteBufferPool.allocate( size, false ); } RasterRect tmpRect = new RasterRect( 0, 0, fRect.width, fRect.height ); for ( int col = minCRmaxCR[0]; col <= minCRmaxCR[2]; ++col ) { for ( int row = minCRmaxCR[1]; row <= minCRmaxCR[3]; ++row ) { int tileId = getTileId( col, row ); int blobNo = tileId / getTilesPerBlob(); FileChannel channel = blobChannels[blobNo]; readValuesFromTile( col, row, fRect, channel, resultBuffer ); } } res = new BufferResult( tmpRect, resultBuffer ); } return res; }
@Override protected void read( int columnId, int rowId, ByteBuffer buffer ) throws IOException { long begin = System.currentTimeMillis(); int tileId = getTileId( columnId, rowId ); buffer.rewind(); // transfer the data from the blob try { int blobNo = tileId / getTilesPerBlob(); int tileInBlob = tileId % getTilesPerBlob(); LOG.debug( "Tile id: {} -> pos in blob: {}", tileId, +tileInBlob ); FileChannel channel = blobChannels[blobNo]; channel.position( tileInBlob * getBytesPerTile() ); channel.read( buffer ); buffer.rewind(); } catch ( IOException e ) { LOG.error( "Error reading tile data from blob: " + e.getMessage(), e ); } if ( LOG.isDebugEnabled() ) { long elapsed = System.currentTimeMillis() - begin; LOG.debug( "Loading of tile ({}x{}) in {} ms.", new Object[] { infoFile.getTileRasterWidth(), infoFile.getTileRasterHeight(), elapsed } ); } }
if ( files != null ) { if ( files.length > 1 ) { this.blobReader = new SplittedBlobReader( blobDir, BLOB_FILE_NAME, BLOB_FILE_EXT, metaInfoFile ); } else { this.blobReader = new GridFileReader( metaInfoFile, files[0] );