Skip to content

Commit

Permalink
fix gradle to require jdk 8 compat (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsargent committed Aug 19, 2022
1 parent 46a0c2c commit 7872ad6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public byte[] decode(byte[] compressed) {
} else {
// XXX should cache this so we don't have to do look up repeatedly
final Optional<ZStdDict> lookup = repository.lookup(dictIdFromDict);
if (lookup.isEmpty()) {
if (! lookup.isPresent()) {
throw new NoDictionaryFoundException("No dictionary found for dictId", dictIdFromDict);
}
final ZStdDict zstdDict = lookup.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public static byte[] trainDictionary(int sampleSize, int dictSize, Stream<byte[]

public static boolean isDictionary(File dictFile) throws IOException {
try (InputStream in = Files.newInputStream(dictFile.toPath())) {
final byte[] bytes = in.readNBytes(4);
final byte[] bytes = new byte[4];
in.read(bytes);

return Arrays.equals(bytes, ZSTD_DICT_MAGIC_NUMBER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ protected ZstdDictRepository explicitDictionary(File dictFile) {
protected boolean isDatabase(File dictFile) {
try (InputStream inputStream = Files.newInputStream(dictFile.toPath())) {
// https://sqlite.org/fileformat.html
final byte[] bytes = inputStream.readNBytes(15);
final byte[] bytes = new byte[15];
inputStream.read(bytes);
final byte[] magicBytes = "SQLite format 3".getBytes(StandardCharsets.UTF_8);
return Arrays.equals(bytes, magicBytes);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public void run() {
codec.initialize(reporter);
registerCodecFunction(c, codec);

Statement statement = c.createStatement();
try (statement) {
try (Statement statement = c.createStatement()) {
String attachName = "blacklite_zstd";
final String attachStatement = getAttachStatement(dest.toAbsolutePath(), attachName);
System.out.println("attachStatement = " + attachStatement);
Expand Down Expand Up @@ -99,13 +98,11 @@ private void initializeCompressDatabase() throws Exception {
EntryStoreConfig config = new DefaultEntryStoreConfig();
config.setFile(dest.toAbsolutePath().toString());
config.setBatchInsertSize(1); // don't batch inserts here.
EntryStore entryStore = new DefaultEntryStore(config);
try (entryStore) {
try (EntryStore entryStore = new DefaultEntryStore(config)) {
entryStore.initialize();
}

final ZStdDictSqliteRepository repository = new ZStdDictSqliteRepository();
try (repository) {
try (ZStdDictSqliteRepository repository = new ZStdDictSqliteRepository()) {
repository.setFile(dest.toFile().getAbsolutePath());
repository.initialize();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public void initialize() throws Exception {
EntryStoreConfig config = new DefaultEntryStoreConfig();
config.setFile(archivePath.toString());
config.setBatchInsertSize(1); // don't batch inserts here.
EntryStore entryStore = new DefaultEntryStore(config);
try (entryStore) {
try (EntryStore entryStore = new DefaultEntryStore(config)) {
entryStore.initialize();
}
}
Expand Down
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ subprojects { subproj ->
apply plugin: 'java-library'
apply plugin: 'com.diffplug.spotless'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(8)
}
}

repositories {
//mavenLocal()
mavenCentral()
Expand Down

0 comments on commit 7872ad6

Please sign in to comment.