小编ema*_*cos的帖子

在mysql查询中理解EXPLAIN

我试图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)

mysql explain

7
推荐指数
1
解决办法
1461
查看次数

将自定义输入源附加到 Swift 中的运行循环

有谁知道如何使用 Swift 语言将自定义输入源附加到运行循环?我正在关注这个文档:特别是运行循环:“配置运行循环源”,但我还没有弄清楚如何快速使用它。

multithreading input nsrunloop swift

5
推荐指数
0
解决办法
411
查看次数

Swift中的指针

我正在尝试了解Swift中指针的使用,尤其是:Unsafe[Mutable]PointerUnsafeRaw[Mutable]Pointer。关于这个问题,我有几个问题。

  1. UnsafePointer <T>等于const T * Pointer在?和UnsafeMutablePointer <T>等于T * Pointer在C 2

  2. Unsafe[Mutable]Pointer和之间有什么区别UnsafeRaw[Mutable]Pointer

  3. 为什么编译

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)

pointers unsafe-pointers swift unsafemutablepointer

5
推荐指数
1
解决办法
7371
查看次数

NSMapTable 的工作原理

我想弄清楚 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)

weak-references ios strong-references swift

5
推荐指数
2
解决办法
2479
查看次数

函数指针在swift中

我正在学习本教程,特别是在使用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)

pointers function objective-c ios swift

2
推荐指数
1
解决办法
2442
查看次数