我试图explain
在查询中解释mysql(以两种不同的方式编写),这是表:
create table text_mess(
datamess timestamp(3) DEFAULT 0,
sender bigint ,
recipient bigint ,
roger boolean,
msg char(255),
foreign key(recipient)
references users (tel)
on delete cascade
on update cascade,
primary key(datamess,sender)
)
engine = InnoDB
Run Code Online (Sandbox Code Playgroud)
这是第一种查询类型:
EXPLAIN
select /*!STRAIGHT_JOIN*/datamess, sender,recipient,roger,msg
from text_mess join (select max(datamess)as dmess
from text_mess
where roger = true
group by sender,recipient) as max
on text_mess.datamess=max.dmess ;
Run Code Online (Sandbox Code Playgroud)
这是第二个:
EXPLAIN
select /*!STRAIGHT_JOIN*/datamess, sender,recipient,roger,msg
from (select max(datamess)as dmess
from text_mess
where roger = true
group by sender,recipient) …
Run Code Online (Sandbox Code Playgroud) 有谁知道如何使用 Swift 语言将自定义输入源附加到运行循环?我正在关注这个文档:特别是运行循环:“配置运行循环源”,但我还没有弄清楚如何快速使用它。
我正在尝试了解Swift中指针的使用,尤其是:Unsafe[Mutable]Pointer
和UnsafeRaw[Mutable]Pointer
。关于这个问题,我有几个问题。
是UnsafePointer <T>
等于const T * Pointer
在?和UnsafeMutablePointer <T>
等于T * Pointer
在C 2
Unsafe[Mutable]Pointer
和之间有什么区别UnsafeRaw[Mutable]Pointer
?
为什么编译
func receive(pointer: UnsafePointer<Int> ) {
print("param value is: \(pointer.pointee)")
}
var a: Int = 1
receive(pointer: &a) // prints 1
Run Code Online (Sandbox Code Playgroud)
但这给我一个错误?
var a: Int = 1
var pointer: UnsafePointer<Int> = &a // error : Cannot pass immutable value of type 'Int' as inout argument
Run Code Online (Sandbox Code Playgroud) 我想弄清楚 NSMapTable 是如何工作的所以我在操场上尝试以下代码:
class Person {
var name: String
init(name: String ) {
self.name = name
print("\(name) is being initialized")
}
deinit {
print("\(name) is being deinitialized")
}
}
var hobyePerson : NSMapTable? = NSMapTable<Person, NSMutableString>
(keyOptions: .weakMemory, valueOptions: .weakMemory)
var rob : Person? = Person(name: "Rob Appleseed") // print : Rob Appleseed is being initialized
hobyePerson?.setObject("golf", forKey: rob)
hobyePerson?.count // return : 1
rob = nil // print : Rob Appleseed is being deinitialized
hobyePerson?.count // return : 1 …
Run Code Online (Sandbox Code Playgroud) 我正在学习本教程,特别是在使用Swift语言转换此函数时遇到问题:
- (id)init
{
CFRunLoopSourceContext context = {0, self, NULL, NULL, NULL, NULL, NULL,
&RunLoopSourceScheduleRoutine,
RunLoopSourceCancelRoutine,
RunLoopSourcePerformRoutine};
runLoopSource = CFRunLoopSourceCreate(NULL, 0, &context);
commands = [[NSMutableArray alloc] init];
return self;
}
Run Code Online (Sandbox Code Playgroud)
对此,在init函数中是context
变量给我带来的问题.
在上面的代码中,context是一个类型的变量:CFRunLoopSourceContext
在apple文档中初始化这个对象是这样的
所以,我在初始化时,使用了以下代码,专注于schedule
参数:
var context = CFRunLoopSourceContext(version: 0, info: bridge(obj: self) ,
retain: nil,
release: nil,
copyDescription: nil,
equal: nil,
hash: nil,
schedule: RunLoopSourceScheduleRoutine,
cancel: nil,
perform: nil)
Run Code Online (Sandbox Code Playgroud)
功能RunLoopSourceScheduleRoutine
如下:
func RunLoopSourceScheduleRoutine(info:UnsafeMutableRawPointer? ,rl:CFRunLoop? , mode:CFRunLoopMode?) {
let obj : RunLoopSource …
Run Code Online (Sandbox Code Playgroud)