sashapolo commented on a change in pull request #723:
URL: https://github.com/apache/ignite-3/pull/723#discussion_r829843037
##########
File path:
modules/rocksdb-common/src/main/java/org/apache/ignite/internal/rocksdb/ColumnFamily.java
##########
@@ -44,53 +43,53 @@
/** Column family handle. */
private final ColumnFamilyHandle cfHandle;
- /** Column family options. */
- private final ColumnFamilyOptions cfOptions;
-
- /** Options for the column family options. */
- private final Options options;
-
/**
* Constructor.
*
- * @param db Db.
- * @param handle Column family handle.
- * @param cfName Column family name.
- * @param cfOptions Column family options.
- * @param options Options for the column family options (for resource
management purposes).
+ * @param db Db.
+ * @param handle Column family handle.
*/
- public ColumnFamily(
- RocksDB db,
- ColumnFamilyHandle handle,
- String cfName,
- ColumnFamilyOptions cfOptions,
- @Nullable Options options
- ) {
+ private ColumnFamily(RocksDB db, ColumnFamilyHandle handle) throws
RocksDBException {
this.db = db;
- this.cfName = cfName;
- this.cfOptions = cfOptions;
- this.options = options;
this.cfHandle = handle;
+ this.cfName = new String(cfHandle.getName(), StandardCharsets.UTF_8);
}
- /** {@inheritDoc} */
- @Override
- public void close() throws Exception {
- // cfHandle is closed by the owning RocksDB instance
- IgniteUtils.closeAll(cfOptions, options);
+ /**
+ * Creates a new Column Family in the provided RocksDB instance.
+ *
+ * @param db RocksDB instance.
+ * @param descriptor Column Family descriptor.
+ * @return new Column Family.
+ * @throws RocksDBException If an error has occurred during creation.
+ */
+ public static ColumnFamily createNew(RocksDB db, ColumnFamilyDescriptor
descriptor) throws RocksDBException {
+ ColumnFamilyHandle cfHandle = db.createColumnFamily(descriptor);
+
+ return new ColumnFamily(db, cfHandle);
+ }
+
+ /**
+ * Creates a wrapper around an already created Column Family.
+ *
+ * @param db RocksDB instance.
+ * @param handle Column Family handle.
+ * @return Column Family wrapper.
+ * @throws RocksDBException If an error has occurred during creation.
+ */
+ public static ColumnFamily createExisting(RocksDB db, ColumnFamilyHandle
handle) throws RocksDBException {
Review comment:
cool, I like this approach
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]