我正在将 HBase 代码更新为0.98.10,1.1.5但编译器显示 myWalObserver 不再实现原始接口WALObserver。
编译器输出:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-
plugin:3.1:compile (default-compile) on project observer: Compilation failure
[ERROR] /Users/zhangsong.zs/git/HBaseObserver/src/main/java/com/gavin/observer/
DataSyncWALObserver.java:[39,8] com.gavin.observer.DataSyncWALObserver
is not abstractand does not override abstract method
postWALWrite(org.apache.hadoop.hbase.coprocessor.ObserverContext<? extends org.apache.hadoop.hbase.coprocessor.WALCoprocessorEnvironment>,
org.apache.hadoop.hbase.HRegionInfo,org.apache.hadoop.hbase.wal.WALKey,
org.apache.hadoop.hbase.regionserver.wal.WALEdit) in
org.apache.hadoop.hbase.coprocessor.WALObserver
Run Code Online (Sandbox Code Playgroud)
所以在版本相同的接口中添加了一些新的API 1.1.5,并且旧的API被弃用。旧代码不再起作用,这对开发人员不利。
所以我想问:我是否还必须实现已经弃用的旧接口方法?
我有一个系统verilog接口
interface add_sub_if(
input bit clk,
input [7:0] a,
input [7:0] b,
input doAdd,
input [8:0] result
);
clocking dut_cb @(posedge clk);
output a;
output b;
output doAdd;
input result;
endclocking // cb
modport dut(clocking dut_cb);
endinterface: add_sub_if
Run Code Online (Sandbox Code Playgroud)
我有一个使用这个接口的 SV 模块
module dummy(add_sub_if.dut _if);
....
endmodule: dummy
Run Code Online (Sandbox Code Playgroud)
将其连接到我的 TB 中的理想方式是什么?
如果我实例化接口,我需要创建电线。
如果我使用绑定,那么我还需要对各个信号进行端口映射,这比使用接口的便利性要好。
另一个附加问题是,如何将一个这样的接口分配给另一个接口?
提前致谢,
拉吉迪普
我正在使用 laravel 5.* (而且我也使用 Laravel 4),我不明白为什么注入接口而不是具体类更好。
有什么好处?
我注入接口是因为我读到它好得多,但是我不明白为什么。
谢谢!
我想在 golang 中调用一个接受接口切片作为参数的方法,但我发现我无法将其传递为这样的写法:
type Base interface {
Run()
}
type A struct {
name string
}
func (a *A) Run() {
fmt.Printf("%s is running\n", a.name)
}
func foo1(b Base) {
b.Run()
}
func foo2(s []Base) {
for _, b := range s {
b.Run()
}
}
func TestInterface(t *testing.T) {
dog := &A{name: "a dog"}
foo1(dog)
// cat := A{name: "a cat"}
// foo1(cat)
s := []*A{dog}
foo2(s)
}
Run Code Online (Sandbox Code Playgroud)
我收到这样的错误:
cannot use s (type []*A) as type []Base in argument …Run Code Online (Sandbox Code Playgroud) 我正在创建一个界面。咱们来说说下面的
internal interface MyInterface
{
string Prop { get; }
}
Run Code Online (Sandbox Code Playgroud)
这是一个内部接口。我打算在项目中使用它,并且不想公开暴露Prop。然而,当我尝试将这个接口实现到一个类中时,我被迫将该Prop属性公开。我不明白为什么当接口本身是内部的并且只能在内部使用时我需要公开这个属性。
我是 Go 新手,由于某种原因我所做的事情对我来说似乎不太直接。
这是我的代码:
for _, column := range resp.Values {
for _, word := range column {
s := make([]string, 1)
s[0] = word
fmt.Print(s, "\n")
}
}
Run Code Online (Sandbox Code Playgroud)
我收到错误:
Cannot use word (type interface {}) as type string in assignment: need type assertion
resp.Values是一个数组的数组,所有数组都填充有字符串。
reflect.TypeOf(resp.Values)返回[][]interface {},
reflect.TypeOf(resp.Values[0])(即column)返回[]interface {},
reflect.TypeOf(resp.Values[0][0])(即word)返回string。
我的最终目标是让每个单词都有自己的数组,所以不要:
[[Hello, Stack], [Overflow, Team]], 我会:
[[[Hello], [Stack]], [[Overflow], [Team]]]
考虑以下代码:
package main
import "fmt"
// 5
type I interface {
Foo() string
}
type a struct {
i int
}
func (s a) Foo() string {
return "We are here!"
}
func (s a) Bar() string {
return "Major Tom!"
}
// 20
func main() {
var x I = &a{i: 42}
fmt.Println(x.Foo())
fmt.Println(x.(*a).Bar())
}
Run Code Online (Sandbox Code Playgroud)
main 的最后一个语句给了我底层结构,但我需要导出这个结构才能返回它。
如果我在库中使用一个包,其中导出的唯一符号是接口(在上面的示例中,第 5-20 行之间是大 I,小 a),那么当我处于另一个包或文件。
由于原始结构存储在接口中,是否有一种简单的方法来获取其引用并使用尚未在接口中声明且仅附加到结构的方法。
我目前正在学习java集合。我已经看到了Set接口及其子接口和具体实现类的类层次结构图。
没有对实线箭头和虚线箭头的含义进行解释。
根据我自己的判断,我假设实线箭头表示extends,虚线箭头表示Implements,但我的假设正确吗?
有没有关于这些符号的含义和用法的官方文档?
当扩展抽象类时,我理解为什么你必须重写一些方法。但当涉及到接口时,我不明白为什么必须这样做。如果一个接口的所有方法都必须实现,那么重写它们有什么用呢?
我正在谈论@Override注释。
我在 TypeScript 中有这个对象:
validationRules: ValidationRuleInterface = {
id: ['integer', 'required'],
name: ['string', 'required', 'people_name'],
city: ['string', 'nullable'],
};
Run Code Online (Sandbox Code Playgroud)
我想在数组中定义可接受的值。像这样的东西:
type Rule = string<'required' | 'nullable' | 'string' | 'integer' | 'people_name', null>;
interface ValidationRuleInterface {
[key: string]: Rule[]
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在 TypeScript 中定义数组的可能值?
interface ×10
go ×3
java ×3
api ×1
arrays ×1
c# ×1
class ×1
deprecated ×1
hbase ×1
internal ×1
java-8 ×1
laravel-5 ×1
methods ×1
overriding ×1
php ×1
properties ×1
types ×1
typescript ×1
uvm ×1