Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static List<byte[]> listColumnFamiliesEmptyOptions(final String path)
}
}

static RocksDatabase open(File dbFile, ManagedDBOptions dbOptions,
public static RocksDatabase open(File dbFile, ManagedDBOptions dbOptions,
ManagedWriteOptions writeOptions, Set<TableConfig> families,
boolean readOnly) throws IOException {
List<ColumnFamilyDescriptor> descriptors = null;
Expand Down Expand Up @@ -460,8 +460,13 @@ public void ingestExternalFile(ColumnFamily family, List<String> files,

public void put(ColumnFamily family, byte[] key, byte[] value)
throws IOException {
put(family.getHandle(), key, value);
}

public void put(ColumnFamilyHandle handle, byte[] key, byte[] value)
throws IOException {
try (UncheckedAutoCloseable ignored = acquire()) {
db.get().put(family.getHandle(), writeOptions, key, value);
db.get().put(handle, writeOptions, key, value);
} catch (RocksDBException e) {
closeOnError(e);
throw toIOException(this, "put " + bytes2String(key), e);
Expand Down Expand Up @@ -621,9 +626,14 @@ RocksCheckpoint createCheckpoint() {
*/
Supplier<byte[]> keyMayExist(ColumnFamily family, byte[] key)
throws IOException {
return keyMayExist(family.getHandle(), key);
}

public Supplier<byte[]> keyMayExist(ColumnFamilyHandle handle, byte[] key)
throws IOException {
try (UncheckedAutoCloseable ignored = acquire()) {
final Holder<byte[]> out = new Holder<>();
return db.get().keyMayExist(family.getHandle(), key, out) ?
return db.get().keyMayExist(handle, key, out) ?
out::getValue : null;
}
}
Expand Down Expand Up @@ -652,16 +662,39 @@ public Collection<ColumnFamily> getExtraColumnFamilies() {
return Collections.unmodifiableCollection(columnFamilies.values());
}

byte[] get(ColumnFamily family, byte[] key) throws IOException {
public void dropColumnFamily(ColumnFamilyHandle handle) throws IOException {
try (UncheckedAutoCloseable ignored = acquire()) {
return db.get().get(family.getHandle(), key);
db.get().dropColumnFamily(handle);
} catch (RocksDBException e) {
closeOnError(e);
final String message = "get " + bytes2String(key) + " from " + family;
throw toIOException(this, "dropColumnFamily", e);
}
}

public ColumnFamilyHandle createColumnFamily(ColumnFamilyDescriptor descriptor) throws IOException {
try (UncheckedAutoCloseable ignored = acquire()) {
return db.get().createColumnFamily(descriptor);
} catch (RocksDBException e) {
closeOnError(e);
throw toIOException(this, "createColumnFamily", e);
}
}

public byte[] get(ColumnFamily family, byte[] key) throws IOException {
return get(family.getHandle(), key, family.getName());
}

public byte[] get(ColumnFamilyHandle handle, byte[] key, String familyName) throws IOException {
try (UncheckedAutoCloseable ignored = acquire()) {
return db.get().get(handle, key);
} catch (RocksDBException e) {
closeOnError(e);
final String message = "get " + bytes2String(key) + " from " + familyName;
throw toIOException(this, message, e);
}
}


/**
* Get the value mapped to the given key.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ public void deleteFile(LiveFileMetaData fileToBeDeleted)
File file = new File(fileToBeDeleted.path(), fileToBeDeleted.fileName());
ManagedRocksObjectUtils.waitForFileDelete(file, Duration.ofSeconds(60));
}

}
Loading