public TDFDataset createDataset(String name, TDFDataset.DataType dataType, int tileWidth, int nTiles) { if (datasetCache.containsKey(name)) { throw new RuntimeException("Dataset: " + name + " already exists"); } TDFDataset ds = new TDFDataset(name, dataType, tileWidth, nTiles); datasetCache.put(name, ds); return ds; }
public TDFDataset createDataset(String name, TDFDataset.DataType dataType, int tileWidth, int nTiles) { if (datasetCache.containsKey(name)) { throw new RuntimeException("Dataset: " + name + " already exists"); } TDFDataset ds = new TDFDataset(name, dataType, tileWidth, nTiles); datasetCache.put(name, ds); return ds; }
public synchronized TDFDataset getDataset(String name) { if (datasetCache.containsKey(name)) { return datasetCache.get(name); } try { if (datasetIndex.containsKey(name)) { IndexEntry ie = datasetIndex.get(name); long position = ie.position; int nBytes = ie.nBytes; //fis.seek(position); //byte[] buffer = new byte[nBytes]; //readFully(buffer); byte[] buffer = readBytes(position, nBytes); ByteBuffer byteBuffer = ByteBuffer.wrap(buffer); byteBuffer.order(ByteOrder.LITTLE_ENDIAN); TDFDataset ds = new TDFDataset(name, byteBuffer, this); datasetCache.put(name, ds); return ds; } else { return null; } } catch (IOException ex) { log.error("Error reading dataset: " + name, ex); throw new RuntimeException("System error occured while reading dataset: " + name); } }
public synchronized TDFDataset getDataset(String name) { if (datasetCache.containsKey(name)) { return datasetCache.get(name); } try { if (datasetIndex.containsKey(name)) { IndexEntry ie = datasetIndex.get(name); long position = ie.position; int nBytes = ie.nBytes; //fis.seek(position); //byte[] buffer = new byte[nBytes]; //readFully(buffer); byte[] buffer = readBytes(position, nBytes); ByteBuffer byteBuffer = ByteBuffer.wrap(buffer); byteBuffer.order(ByteOrder.LITTLE_ENDIAN); TDFDataset ds = new TDFDataset(name, byteBuffer, this); datasetCache.put(name, ds); return ds; } else { datasetCache.put(name, null); return null; } } catch (IOException ex) { log.error("Error reading dataset: " + getPath() + " (" + name + ")", ex); throw new RuntimeException("System error occured while reading dataset: " + name); } }