Skip to content

Commit

Permalink
feat(core): add new cap shared (#5328)
Browse files Browse the repository at this point in the history
  • Loading branch information
TennyZhuang authored Nov 16, 2024
1 parent 084892f commit a2db7f2
Show file tree
Hide file tree
Showing 81 changed files with 159 additions and 4 deletions.
4 changes: 4 additions & 0 deletions bindings/c/include/opendal.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,10 @@ typedef struct opendal_capability {
* If it is not set, this will be zero
*/
uintptr_t batch_max_operations;
/**
* If operator supports shared.
*/
bool shared;
/**
* If operator supports blocking.
*/
Expand Down
4 changes: 4 additions & 0 deletions bindings/c/src/operator_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ pub struct opendal_capability {
/// If it is not set, this will be zero
pub batch_max_operations: usize,

/// If operator supports shared.
pub shared: bool,

/// If operator supports blocking.
pub blocking: bool,
}
Expand Down Expand Up @@ -263,6 +266,7 @@ impl From<core::Capability> for opendal_capability {
batch: value.batch,
batch_delete: value.batch_delete,
batch_max_operations: value.batch_max_operations.unwrap_or(0),
shared: value.shared,
blocking: value.blocking,
}
}
Expand Down
4 changes: 4 additions & 0 deletions bindings/go/operator_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ func (c *Capability) BatchMaxOperations() uint {
return c.inner.batchMaxOperations
}

func (c *Capability) Shared() bool {
return c.inner.shared == 1
}

func (c *Capability) Blocking() bool {
return c.inner.blocking == 1
}
Expand Down
2 changes: 2 additions & 0 deletions bindings/go/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ var (
&ffi.TypeUint8, // batch
&ffi.TypeUint8, // batch_delete
&ffi.TypePointer, // batch_max_operations
&ffi.TypeUint8, // shared
&ffi.TypeUint8, // blocking
nil,
}[0],
Expand Down Expand Up @@ -204,6 +205,7 @@ type opendalCapability struct {
batch uint8
batchDelete uint8
batchMaxOperations uint
shared uint8
blocking uint8
}

Expand Down
3 changes: 2 additions & 1 deletion bindings/java/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn make_operator_info<'a>(env: &mut JNIEnv<'a>, info: OperatorInfo) -> Result<JO
fn make_capability<'a>(env: &mut JNIEnv<'a>, cap: Capability) -> Result<JObject<'a>> {
let capability = env.new_object(
"org/apache/opendal/Capability",
"(ZZZZZZZZZZZZZZZJJZZZZZZZZZZZZZZJZ)V",
"(ZZZZZZZZZZZZZZZJJZZZZZZZZZZZZZZJZZ)V",
&[
JValue::Bool(cap.stat as jboolean),
JValue::Bool(cap.stat_with_if_match as jboolean),
Expand Down Expand Up @@ -128,6 +128,7 @@ fn make_capability<'a>(env: &mut JNIEnv<'a>, cap: Capability) -> Result<JObject<
JValue::Bool(cap.batch as jboolean),
JValue::Bool(cap.batch_delete as jboolean),
JValue::Long(convert::usize_to_jlong(cap.batch_max_operations)),
JValue::Bool(cap.shared as jboolean),
JValue::Bool(cap.blocking as jboolean),
],
)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ public class Capability {
*/
public final long batchMaxOperations;

/**
* If operator supports shared.
*/
public final boolean shared;

/**
* If operator supports blocking.
*/
Expand Down Expand Up @@ -223,7 +228,8 @@ public Capability(
boolean batch,
boolean batchDelete,
long batchMaxOperations,
boolean blocking) {
boolean blocking,
boolean shared) {
this.stat = stat;
this.statWithIfMatch = statWithIfMatch;
this.statWithIfNoneMatch = statWithIfNoneMatch;
Expand Down Expand Up @@ -257,5 +263,6 @@ public Capability(
this.batchDelete = batchDelete;
this.batchMaxOperations = batchMaxOperations;
this.blocking = blocking;
this.shared = shared;
}
}
2 changes: 2 additions & 0 deletions bindings/nodejs/generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ export class Capability {
get batchDelete(): boolean
/** The max operations that operator supports in batch. */
get batchMaxOperations(): bigint | null
/** If operator supports shared. */
get shared(): boolean
/** If operator supports blocking. */
get blocking(): boolean
}
Expand Down
6 changes: 6 additions & 0 deletions bindings/nodejs/src/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,12 @@ impl Capability {
self.0.batch_max_operations
}

/// If operator supports shared.
#[napi(getter)]
pub fn shared(&self) -> bool {
self.0.shared
}

/// If operator supports blocking.
#[napi(getter)]
pub fn blocking(&self) -> bool {
Expand Down
1 change: 1 addition & 0 deletions bindings/python/python/opendal/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,5 @@ class Capability:
batch_delete: bool
batch_max_operations: Optional[int]

shared: bool
blocking: bool
4 changes: 4 additions & 0 deletions bindings/python/src/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ pub struct Capability {
/// The max operations that operator supports in batch.
pub batch_max_operations: Option<usize>,

/// If operator supports shared.
pub shared: bool,

/// If operator supports blocking.
pub blocking: bool,
}
Expand Down Expand Up @@ -147,6 +150,7 @@ impl Capability {
batch: capability.batch,
batch_delete: capability.batch_delete,
batch_max_operations: capability.batch_max_operations,
shared: capability.shared,
blocking: capability.blocking,
}
}
Expand Down
3 changes: 2 additions & 1 deletion bindings/ruby/src/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ define_accessors!(Capability, {
batch: bool,
batch_delete: bool,
batch_max_operations: Option<usize>,
blocking: bool
shared: bool,
blocking: bool,
});

// includes class into the Ruby module
Expand Down
5 changes: 5 additions & 0 deletions core/src/raw/adapters/typed_kv/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ pub struct Capability {
pub delete: bool,
/// If typed_kv operator supports scan natively.
pub scan: bool,
/// If typed_kv operator supports shared access.
pub shared: bool,
}

impl Debug for Capability {
Expand All @@ -148,6 +150,9 @@ impl Debug for Capability {
if self.scan {
s.push("Scan");
}
if self.shared {
s.push("Shared");
}

write!(f, "{{ {} }}", s.join(" | "))
}
Expand Down
4 changes: 4 additions & 0 deletions core/src/raw/adapters/typed_kv/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ impl<S: Adapter> Access for Backend<S> {
cap.list_with_recursive = true;
}

if kv_cap.shared {
cap.shared = true;
}

cap.blocking = true;

am.set_native_capability(cap);
Expand Down
2 changes: 1 addition & 1 deletion core/src/services/aliyun_drive/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl Access for AliyunDriveBackend {
rename: true,
list: true,
list_with_limit: true,

shared: true,
..Default::default()
});
am.into()
Expand Down
2 changes: 2 additions & 0 deletions core/src/services/alluxio/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ impl Access for AlluxioBackend {

list: true,

shared: true,

..Default::default()
});

Expand Down
1 change: 1 addition & 0 deletions core/src/services/atomicserver/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ impl kv::Adapter for Adapter {
read: true,
write: true,
delete: true,
shared: true,
..Default::default()
},
)
Expand Down
2 changes: 2 additions & 0 deletions core/src/services/azblob/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ impl Access for AzblobBackend {
batch_delete: true,
batch_max_operations: Some(self.core.batch_max_operations),

shared: true,

..Default::default()
});

Expand Down
2 changes: 2 additions & 0 deletions core/src/services/azdls/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ impl Access for AzdlsBackend {

list: true,

shared: true,

..Default::default()
});

Expand Down
2 changes: 2 additions & 0 deletions core/src/services/azfile/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ impl Access for AzfileBackend {

list: true,

shared: true,

..Default::default()
});

Expand Down
2 changes: 2 additions & 0 deletions core/src/services/b2/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ impl Access for B2Backend {
presign_write: true,
presign_stat: true,

shared: true,

..Default::default()
});

Expand Down
1 change: 1 addition & 0 deletions core/src/services/cacache/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl kv::Adapter for Adapter {
write: true,
delete: true,
blocking: true,
shared: false,
..Default::default()
},
)
Expand Down
2 changes: 2 additions & 0 deletions core/src/services/chainsafe/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ impl Access for ChainsafeBackend {

list: true,

shared: true,

..Default::default()
});

Expand Down
1 change: 1 addition & 0 deletions core/src/services/cloudflare_kv/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ impl kv::Adapter for Adapter {
read: true,
write: true,
list: true,
shared: true,

..Default::default()
},
Expand Down
2 changes: 2 additions & 0 deletions core/src/services/compfs/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ impl Access for CompfsBackend {
copy: true,
rename: true,

shared: true,

..Default::default()
});

Expand Down
2 changes: 2 additions & 0 deletions core/src/services/cos/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ impl Access for CosBackend {
presign_read: true,
presign_write: true,

shared: true,

..Default::default()
});

Expand Down
1 change: 1 addition & 0 deletions core/src/services/d1/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ impl kv::Adapter for Adapter {
// Cloudflare D1 supports 1MB as max in write_total.
// refer to https://developers.cloudflare.com/d1/platform/limits/
write_total_max_size: Some(1000 * 1000),
shared: true,
..Default::default()
},
)
Expand Down
1 change: 1 addition & 0 deletions core/src/services/dashmap/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl typed_kv::Adapter for Adapter {
set: true,
scan: true,
delete: true,
shared: false,
},
)
}
Expand Down
2 changes: 2 additions & 0 deletions core/src/services/dbfs/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ impl Access for DbfsBackend {

list: true,

shared: true,

..Default::default()
});
am.into()
Expand Down
2 changes: 2 additions & 0 deletions core/src/services/dropbox/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ impl Access for DropboxBackend {
batch: true,
batch_delete: true,

shared: true,

..Default::default()
});
ma.into()
Expand Down
1 change: 1 addition & 0 deletions core/src/services/etcd/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ impl kv::Adapter for Adapter {
read: true,
write: true,
list: true,
shared: true,

..Default::default()
},
Expand Down
1 change: 1 addition & 0 deletions core/src/services/foundationdb/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl kv::Adapter for Adapter {
read: true,
write: true,
delete: true,
shared: true,
..Default::default()
},
)
Expand Down
2 changes: 2 additions & 0 deletions core/src/services/fs/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ impl Access for FsBackend {
rename: true,
blocking: true,

shared: true,

..Default::default()
});

Expand Down
2 changes: 2 additions & 0 deletions core/src/services/ftp/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ impl Access for FtpBackend {

list: true,

shared: true,

..Default::default()
});

Expand Down
2 changes: 2 additions & 0 deletions core/src/services/gcs/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ impl Access for GcsBackend {
presign_read: true,
presign_write: true,

shared: true,

..Default::default()
});
am.into()
Expand Down
3 changes: 3 additions & 0 deletions core/src/services/gdrive/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ impl Access for GdriveBackend {
delete: true,
rename: true,
copy: true,

shared: true,

..Default::default()
});

Expand Down
2 changes: 2 additions & 0 deletions core/src/services/ghac/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ impl Access for GhacBackend {
write_can_multi: true,
delete: true,

shared: true,

..Default::default()
});
am.into()
Expand Down
2 changes: 2 additions & 0 deletions core/src/services/github/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ impl Access for GithubBackend {
list: true,
list_with_recursive: true,

shared: true,

..Default::default()
});

Expand Down
Loading

0 comments on commit a2db7f2

Please sign in to comment.