Debian Codegraph @

src/main/org/h2/store/fs/niomem/FilePathNioMemLZF.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6 package org.h2.store.fs.niomem;
7
8 /**
9 * A memory file system that compresses blocks to conserve memory.
10 */
11 public class FilePathNioMemLZF extends FilePathNioMem {
12
13 @Override
14 boolean compressed() {
15 return true;
16 }
17
18 @Override
19 public FilePathNioMem getPath(String path) {
20 if (!path.startsWith(getScheme())) {
21 throw new IllegalArgumentException(path +
22 " doesn't start with " + getScheme());
23 }
24 int idx1 = path.indexOf(':');
25 int idx2 = path.lastIndexOf(':');
26 final FilePathNioMemLZF p = new FilePathNioMemLZF();
27 if (idx1 != -1 && idx1 != idx2) {
28 p.compressLaterCachePercent = Float.parseFloat(path.substring(idx1 + 1, idx2));
29 }
30 p.name = getCanonicalPath(path);
31 return p;
32 }
33
34 @Override
35 protected boolean isRoot() {
36 return name.lastIndexOf(':') == name.length() - 1;
37 }
38
39 @Override
40 public String getScheme() {
41 return "nioMemLZF";
42 }
43
44 }