From 8a890864f94059308134925ff8e37a95568cfb79 Mon Sep 17 00:00:00 2001 From: Mathias Herberts Date: Fri, 14 Jun 2019 13:25:26 +0200 Subject: [PATCH 1/6] Fixes #96 - Removed autoclose of FileChannel. --- .../main/java/org/iq80/leveldb/impl/TableCache.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/leveldb/src/main/java/org/iq80/leveldb/impl/TableCache.java b/leveldb/src/main/java/org/iq80/leveldb/impl/TableCache.java index 34b5055e..58ed1ace 100755 --- a/leveldb/src/main/java/org/iq80/leveldb/impl/TableCache.java +++ b/leveldb/src/main/java/org/iq80/leveldb/impl/TableCache.java @@ -26,6 +26,7 @@ import org.iq80.leveldb.table.MMapTable; import org.iq80.leveldb.table.Table; import org.iq80.leveldb.table.UserComparator; +import org.iq80.leveldb.util.Closeables; import org.iq80.leveldb.util.Finalizer; import org.iq80.leveldb.util.InternalTableIterator; import org.iq80.leveldb.util.Slice; @@ -120,8 +121,10 @@ private TableAndFile(File databaseDir, long fileNumber, UserComparator userCompa { String tableFileName = Filename.tableFileName(fileNumber); File tableFile = new File(databaseDir, tableFileName); - try (FileInputStream fis = new FileInputStream(tableFile); - FileChannel fileChannel = fis.getChannel()) { + FileInputStream fis = null; + try { + fis = new FileInputStream(tableFile); + FileChannel fileChannel = fis.getChannel(); if (Iq80DBFactory.USE_MMAP) { table = new MMapTable(tableFile.getAbsolutePath(), fileChannel, userComparator, verifyChecksums); } @@ -129,6 +132,10 @@ private TableAndFile(File databaseDir, long fileNumber, UserComparator userCompa table = new FileChannelTable(tableFile.getAbsolutePath(), fileChannel, userComparator, verifyChecksums); } } + catch (IOException ioe) { + Closeables.closeQuietly(fis); + throw ioe; + } } public Table getTable() From 435ceefb40961a1476a1c237dc41198f88874a67 Mon Sep 17 00:00:00 2001 From: Mathias Herberts Date: Sat, 15 Jun 2019 19:47:50 +0200 Subject: [PATCH 2/6] Added closing of the FileChannel and associated InputStream after creation of the MMapTable instance --- leveldb/src/main/java/org/iq80/leveldb/impl/TableCache.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/leveldb/src/main/java/org/iq80/leveldb/impl/TableCache.java b/leveldb/src/main/java/org/iq80/leveldb/impl/TableCache.java index 58ed1ace..ce2fb0e8 100755 --- a/leveldb/src/main/java/org/iq80/leveldb/impl/TableCache.java +++ b/leveldb/src/main/java/org/iq80/leveldb/impl/TableCache.java @@ -127,6 +127,8 @@ private TableAndFile(File databaseDir, long fileNumber, UserComparator userCompa FileChannel fileChannel = fis.getChannel(); if (Iq80DBFactory.USE_MMAP) { table = new MMapTable(tableFile.getAbsolutePath(), fileChannel, userComparator, verifyChecksums); + // We can close the channel and input stream as the mapping does not need them + Closeables.closeQuietly(fis); } else { table = new FileChannelTable(tableFile.getAbsolutePath(), fileChannel, userComparator, verifyChecksums); From b151559f2e07875bb7ccc25869e718b3475bd856 Mon Sep 17 00:00:00 2001 From: Li Zhiming Date: Fri, 5 Apr 2019 17:30:26 +0800 Subject: [PATCH 3/6] BlockIterator: readEntry: do not allocate for key if sharedKeyLength==0 Signed-off-by: Li Zhiming --- .../java/org/iq80/leveldb/table/BlockIterator.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/leveldb/src/main/java/org/iq80/leveldb/table/BlockIterator.java b/leveldb/src/main/java/org/iq80/leveldb/table/BlockIterator.java index f91dd36f..ca525911 100644 --- a/leveldb/src/main/java/org/iq80/leveldb/table/BlockIterator.java +++ b/leveldb/src/main/java/org/iq80/leveldb/table/BlockIterator.java @@ -189,14 +189,17 @@ private static BlockEntry readEntry(SliceInput data, BlockEntry previousEntry) int valueLength = VariableLengthQuantity.readVariableLengthInt(data); // read key - Slice key = Slices.allocate(sharedKeyLength + nonSharedKeyLength); - SliceOutput sliceOutput = key.output(); + final Slice key; if (sharedKeyLength > 0) { + key = Slices.allocate(sharedKeyLength + nonSharedKeyLength); + SliceOutput sliceOutput = key.output(); checkState(previousEntry != null, "Entry has a shared key but no previous entry was provided"); sliceOutput.writeBytes(previousEntry.getKey(), 0, sharedKeyLength); + sliceOutput.writeBytes(data, nonSharedKeyLength); + } + else { + key = data.readSlice(nonSharedKeyLength); } - sliceOutput.writeBytes(data, nonSharedKeyLength); - // read value Slice value = data.readSlice(valueLength); From 72bdb60a8eb4fe854bbdb213add87cda215bbf40 Mon Sep 17 00:00:00 2001 From: Dain Sundstrom Date: Wed, 26 Jun 2019 13:51:17 -0700 Subject: [PATCH 4/6] [maven-release-plugin] prepare release 0.12 --- leveldb-api/pom.xml | 2 +- leveldb-benchmark/pom.xml | 2 +- leveldb/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/leveldb-api/pom.xml b/leveldb-api/pom.xml index ee9ddafb..fa27a2b2 100644 --- a/leveldb-api/pom.xml +++ b/leveldb-api/pom.xml @@ -5,7 +5,7 @@ org.iq80.leveldb leveldb-project - 0.12-SNAPSHOT + 0.12 leveldb-api diff --git a/leveldb-benchmark/pom.xml b/leveldb-benchmark/pom.xml index d73dd874..9130e21e 100644 --- a/leveldb-benchmark/pom.xml +++ b/leveldb-benchmark/pom.xml @@ -21,7 +21,7 @@ leveldb-project org.iq80.leveldb - 0.12-SNAPSHOT + 0.12 leveldb-benchmark diff --git a/leveldb/pom.xml b/leveldb/pom.xml index 09f90478..90448d00 100644 --- a/leveldb/pom.xml +++ b/leveldb/pom.xml @@ -5,7 +5,7 @@ org.iq80.leveldb leveldb-project - 0.12-SNAPSHOT + 0.12 leveldb diff --git a/pom.xml b/pom.xml index e963e48a..bd3923be 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.iq80.leveldb leveldb-project - 0.12-SNAPSHOT + 0.12 pom Port of LevelDB to Java @@ -51,7 +51,7 @@ scm:git:git://github.com/dain/leveldb.git scm:git:git@github.com:dain/leveldb.git http://github.com/dain/leveldb/tree/master - HEAD + 0.12 From 75d23657c7e51eb49bb7f640814abf66678eb422 Mon Sep 17 00:00:00 2001 From: Dain Sundstrom Date: Wed, 26 Jun 2019 13:51:17 -0700 Subject: [PATCH 5/6] [maven-release-plugin] prepare for next development iteration --- leveldb-api/pom.xml | 2 +- leveldb-benchmark/pom.xml | 2 +- leveldb/pom.xml | 2 +- pom.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/leveldb-api/pom.xml b/leveldb-api/pom.xml index fa27a2b2..32cc1715 100644 --- a/leveldb-api/pom.xml +++ b/leveldb-api/pom.xml @@ -5,7 +5,7 @@ org.iq80.leveldb leveldb-project - 0.12 + 0.13-SNAPSHOT leveldb-api diff --git a/leveldb-benchmark/pom.xml b/leveldb-benchmark/pom.xml index 9130e21e..0262f0b8 100644 --- a/leveldb-benchmark/pom.xml +++ b/leveldb-benchmark/pom.xml @@ -21,7 +21,7 @@ leveldb-project org.iq80.leveldb - 0.12 + 0.13-SNAPSHOT leveldb-benchmark diff --git a/leveldb/pom.xml b/leveldb/pom.xml index 90448d00..ebd55194 100644 --- a/leveldb/pom.xml +++ b/leveldb/pom.xml @@ -5,7 +5,7 @@ org.iq80.leveldb leveldb-project - 0.12 + 0.13-SNAPSHOT leveldb diff --git a/pom.xml b/pom.xml index bd3923be..e541c17d 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.iq80.leveldb leveldb-project - 0.12 + 0.13-SNAPSHOT pom Port of LevelDB to Java @@ -51,7 +51,7 @@ scm:git:git://github.com/dain/leveldb.git scm:git:git@github.com:dain/leveldb.git http://github.com/dain/leveldb/tree/master - 0.12 + HEAD From 130db6965ebba2c19106c5355bee0c8dc59f57db Mon Sep 17 00:00:00 2001 From: Colm O hEigeartaigh Date: Thu, 30 Jan 2020 16:11:48 +0000 Subject: [PATCH 6/6] Update to latest airbase version --- pom.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index e541c17d..223d88e2 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ io.airlift airbase - 77 + 95 org.iq80.leveldb @@ -63,6 +63,8 @@ ${air.check.fail-basic} -missing + src/license/LICENSE-HEADER.txt + ${air.main.basedir}/src/checkstyle/checks.xml @@ -86,7 +88,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 2.17 + 3.1.0 validate