2
我有一個accumulo命名記錄的表,每個row_id有幾個族和限定符,它看起來就像在accumulo shell中一樣。用scala對accumulo表進行迭代
[email protected] records> scan
2016-10-17 16:27:55,359 [Shell.audit] INFO : [email protected] records> scan
E001 department:sales [] 0
E001 hire_date:20160101 [] 0
E001 name:bob [] 0
E001 name:jerry [] 0
E002 department:marketing [] 0
E002 hire_date:20160202 [] 0
E002 name:sarah [] 0
E003 department:engineering [] 0
E003 hire_date:20160303 [] 0
E003 name:joe [] 0
我希望能夠用scala連接器掃描這幾行。所需的進口後,我的代碼如下所示:
var opts = new ClientOnRequiredTable()
var bsOpts = new BatchScannerOpts()
opts.parseArgs("test", Array("-t", "records","-u", "michaelp", "-p", "****", "-z", "zookeeper:2181", "-i", "accumulo"), bsOpts)
var connector = opts.getConnector()
var batchReader = connector.createBatchScanner("records", opts.auths, bsOpts.scanThreads)
batchReader.setTimeout(bsOpts.scanTimeout, TimeUnit.MILLISECONDS)
var x = new Range()
var y = new LinkedList[Range]
y.add(x)
batchReader.setRanges(y)
我通過在一個空的範圍內讓每一個行的表。問題是當我嘗試遍歷結果。它堅持在第一行。
scala> while (batchReader.iterator.hasNext()) {println(batchReader.iterator.next.getKey().toString())}
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
E001 department:sales [] 1476720996135 false
...
那麼爲什麼迭代器不能一起移動呢?
這是正確的答案,將在一秒內複選標記。謝謝 – Mike