 import SPARQLSyntax
 import Kineo
 import Diomede
+import DiomedeQuadStore
 
 /// Parse the supplied RDF files and load the resulting RDF triples into the database's
 /// QuadStore in the supplied named graph (or into a graph named with the corresponding

var count = 0

do {
    let qs  = try quadStore(config)
    if let op = args.next() {
        if op == "load" || op == "create" {
        } else if op == "dataset" {

    return readLine()
}

private func humanReadable(count: Int) -> String {
    var names = ["", "k", "m", "b"]
    var unit = names.remove(at: 0)
    var size = count
    while !names.isEmpty && size >= 1000 {
        unit = names.remove(at: 0)
        size /= 1000
    }
    return "\(size)\(unit)"
}

func quadStore(_ config: QuadStoreConfiguration, verbose: Bool) throws -> AnyMutableQuadStore {
//    print("Using AnyQuadStore")
    let mqs = try config.anymutablestore()
    
    if verbose {
        if let d = mqs._store as? DiomedeQuadStore {
            d.progressHandler = { (status) in
                switch status {
                case let .loadProgress(count: i, rate: tps):
                    let s = String(format: "\(humanReadable(count: i)) triples (%.1f t/s)", tps)
                    print("\(s)")
                @unknown default:
                    break
                }
            }
        }
    }
    
    if case let .loadFiles(defaultFiles, namedFiles) = config.initialize {
        let graph = Term(iri: "tag:kasei.us,2018:default-graph")
        _ = try parse(into: mqs, files: defaultFiles, version: startSecond, graph: graph, verbose: verbose)
