private static String getFileName(DataHandler handler, int tableId, int objectId) { if (SysProperties.CHECK && tableId == 0 && objectId == 0) { throw Message.getInternalError("0 LOB"); } if (handler.getLobFilesInDirectories()) { String table = tableId < 0 ? ".temp" : ".t" + tableId; return getFileNamePrefix(handler.getDatabasePath(), objectId) + table + Constants.SUFFIX_LOB_FILE; } else { return handler.getDatabasePath() + "." + tableId + "." + objectId + Constants.SUFFIX_LOB_FILE; } }
public static void removeAllForTable(DataHandler handler, int tableId) throws SQLException { if (handler.getLobFilesInDirectories()) { String dir = getFileNamePrefix(handler.getDatabasePath(), 0); removeAllForTable(handler, dir, tableId); } else { String prefix = handler.getDatabasePath(); String dir = FileUtils.getParent(prefix); String[] list = FileUtils.listFiles(dir); for (int i = 0; i < list.length; i++) { String name = list[i]; if (name.startsWith(prefix + "." + tableId + ".") && name.endsWith(".lob.db")) { deleteFile(handler, name); } } } }
public void unlink() throws SQLException { if (linked && fileName != null) { String temp; // synchronize on the database, to avoid concurrent temp file // creation / deletion / backup synchronized (handler) { if (handler.getLobFilesInDirectories()) { temp = getFileName(handler, -1, objectId); } else { // just to get a filename - an empty file will be created temp = handler.createTempFile(); } deleteFile(handler, temp); renameFile(handler, fileName, temp); tempFile = FileStore.open(handler, temp, "rw", null); tempFile.autoDelete(); tempFile.closeSilently(); fileName = temp; linked = false; } } }
private FileStoreOutputStream initLarge(DataHandler handler) throws IOException, SQLException { this.handler = handler; this.tableId = 0; this.linked = false; this.precision = 0; this.small = null; this.hash = 0; String compressionAlgorithm = handler.getLobCompressionAlgorithm(type); this.compression = compressionAlgorithm != null; synchronized (handler) { if (handler.getLobFilesInDirectories()) { objectId = getNewObjectId(handler); fileName = getFileNamePrefix(handler.getDatabasePath(), objectId) + ".temp.db"; } else { objectId = handler.allocateObjectId(false, true); fileName = handler.createTempFile(); } tempFile = handler.openFile(fileName, "rw", false); tempFile.autoDelete(); } FileStoreOutputStream out = new FileStoreOutputStream(tempFile, handler, compressionAlgorithm); return out; }
if (handler.getLobFilesInDirectories()) { copy.objectId = getNewObjectId(handler); } else {