From commits-return-22542-archive-asf-public=cust-asf.ponee.io@accumulo.apache.org Tue Jan 29 21:34:57 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id BE6C018067E for ; Tue, 29 Jan 2019 22:34:56 +0100 (CET) Received: (qmail 75028 invoked by uid 500); 29 Jan 2019 21:34:55 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 75019 invoked by uid 99); 29 Jan 2019 21:34:55 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jan 2019 21:34:55 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 4D5BA8570D; Tue, 29 Jan 2019 21:34:55 +0000 (UTC) Date: Tue, 29 Jan 2019 21:34:55 +0000 To: "commits@accumulo.apache.org" Subject: [accumulo-website] branch master updated: Update client documentation (#144) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <154879769522.32645.14155061959855153317@gitbox.apache.org> From: mwalch@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: accumulo-website X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 41854abf6c025dc4f32fae6e963c63a5073e2a9e X-Git-Newrev: 77812b47d32383b4a3eb6f86c2a650a3e8d12411 X-Git-Rev: 77812b47d32383b4a3eb6f86c2a650a3e8d12411 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. mwalch pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/accumulo-website.git The following commit(s) were added to refs/heads/master by this push: new 77812b4 Update client documentation (#144) 77812b4 is described below commit 77812b47d32383b4a3eb6f86c2a650a3e8d12411 Author: Mike Walch AuthorDate: Tue Jan 29 16:34:50 2019 -0500 Update client documentation (#144) --- _docs-2/getting-started/clients.md | 75 +++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/_docs-2/getting-started/clients.md b/_docs-2/getting-started/clients.md index cff9086..68ac3ce 100644 --- a/_docs-2/getting-started/clients.md +++ b/_docs-2/getting-started/clients.md @@ -115,19 +115,12 @@ changes to the columns of a single row. The changes are made atomically in the TabletServer. Clients then add Mutations to a [BatchWriter] which submits them to the appropriate TabletServers. -Mutations can be created thus: +The code below shows how a Mutation is created. ```java -Text rowID = new Text("row1"); -Text colFam = new Text("myColFam"); -Text colQual = new Text("myColQual"); -ColumnVisibility colVis = new ColumnVisibility("public"); -long timestamp = System.currentTimeMillis(); - -Value value = new Value("myValue".getBytes()); - -Mutation mutation = new Mutation(rowID); -mutation.put(colFam, colQual, colVis, timestamp, value); +Mutation mutation = new Mutation("row1"); +mutation.at().family("myColFam1").qualifier("myColQual1").visibility("public").put("myValue1"); +mutation.at().family("myColFam2").qualifier("myColQual2").visibility("public").put("myValue2"); ``` ### BatchWriter @@ -138,16 +131,14 @@ amortize network overhead. Care must be taken to avoid changing the contents of any Object passed to the BatchWriter since it keeps objects in memory while batching. -Mutations are added to a BatchWriter thus: +The code below shows how a Mutation is added to a BatchWriter: ```java -// BatchWriterConfig has reasonable defaults -BatchWriterConfig config = new BatchWriterConfig(); -config.setMaxMemory(10000000L); // bytes available to batchwriter for buffering mutations - -BatchWriter writer = client.createBatchWriter("table", config) -writer.addMutation(mutation); -writer.close(); +try (BatchWriter writer = client.createBatchWriter("mytable")) { + Mutation m = new Mutation("row1"); + m.at().family("myfam").qualifier("myqual").visibility("public").put("myval"); + writer.addMutation(m); +} ``` For more example code, see the [batch writing and scanning example][batch]. @@ -224,21 +215,37 @@ to efficiently return ranges of consecutive keys and their associated values. ### Scanner -To retrieve data, Clients use a [Scanner], which acts like an Iterator over -keys and values. Scanners can be configured to start and stop at particular keys, and +To retrieve data, create a [Scanner] using [AccumuloClient]. A Scanner acts like an Iterator over +keys and values in the table. + +If a [Scanner] is created without [Authorizations], it uses all [Authorizations] granted +to the user that created the [AccumuloClient]: + +```java +Scanner s = client.createScanner("table"); +``` + +A scanner can also be created to only use a subset of a user's [Authorizations]. + +```java +Scanner s = client.createScanner("table", new Authorizations("public")); +``` + +Scanners can be configured to start and stop at particular keys, and to return a subset of the columns available. ```java -// specify which visibilities we are allowed to see +// return data with visibilities that match specified auths Authorizations auths = new Authorizations("public"); -Scanner scan = client.createScanner("table", auths); -scan.setRange(new Range("harry","john")); -scan.fetchColumnFamily(new Text("attributes")); +try (Scanner scan = client.createScanner("table", auths)) { + scan.setRange(new Range("harry","john")); + scan.fetchColumnFamily(new Text("attributes")); -for (Entry entry : scan) { - Text row = entry.getKey().getRow(); - Value value = entry.getValue(); + for (Entry entry : scan) { + Text row = entry.getKey().getRow(); + Value value = entry.getValue(); + } } ``` @@ -281,12 +288,13 @@ TabletServers in parallel. ArrayList ranges = new ArrayList(); // populate list of ranges ... -BatchScanner bscan = client.createBatchScanner("table", auths, 10); -bscan.setRanges(ranges); -bscan.fetchColumnFamily("attributes"); +try (BatchScanner bscan = client.createBatchScanner("table", auths, 10)) { + bscan.setRanges(ranges); + bscan.fetchColumnFamily("attributes"); -for (Entry entry : bscan) { - System.out.println(entry.getValue()); + for (Entry entry : bscan) { + System.out.println(entry.getValue()); + } } ``` @@ -371,3 +379,4 @@ This page covers Accumulo client basics. Below are links to additional document [isolation]: https://github.com/apache/accumulo-examples/blob/master/docs/isolation.md [accumulo-client.properties]: {% durl configuration/files#accumulo-clientproperties %} [table.durability]: {% purl table.durability %} +[Authorizations]: {% jurl org.apache.accumulo.core.security.Authorizations %}