accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwa...@apache.org
Subject [accumulo-website] branch master updated: Updated client docs with 2.0 API changes (#160)
Date Mon, 25 Feb 2019 22:21:09 GMT
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 f665f04  Updated client docs with 2.0 API changes (#160)
f665f04 is described below

commit f665f04447bb7b74f1ce033e3e896690d9d6cff0
Author: Mike Walch <mwalch@apache.org>
AuthorDate: Mon Feb 25 17:21:05 2019 -0500

    Updated client docs with 2.0 API changes (#160)
    
    * Limited use of Text
    * Used new 2.0 API where possible
---
 _docs-2/development/mapreduce.md        |  2 +-
 _docs-2/getting-started/clients.md      |  2 +-
 _docs-2/getting-started/table_design.md | 49 ++++++++++++++++-----------------
 3 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/_docs-2/development/mapreduce.md b/_docs-2/development/mapreduce.md
index f5877e4..c312183 100644
--- a/_docs-2/development/mapreduce.md
+++ b/_docs-2/development/mapreduce.md
@@ -79,7 +79,7 @@ Follow the steps below to create a MapReduce job that reads from an Accumulo
tab
     [AccumuloInputFormat] has optional settings.
     ```java
     List<Range> ranges = new ArrayList<Range>();
-    List<Pair<Text,Text>> columns = new ArrayList<Pair<Text,Text>>();
+    Collection<IteratorSetting.Column> columns = new ArrayList<IteratorSetting.Column>();
     // populate ranges & columns
     IteratorSetting is = new IteratorSetting(30, RexExFilter.class);
     RegExFilter.setRegexs(is, ".*suffix", null, null, null, true);
diff --git a/_docs-2/getting-started/clients.md b/_docs-2/getting-started/clients.md
index 68ac3ce..ec769d0 100644
--- a/_docs-2/getting-started/clients.md
+++ b/_docs-2/getting-started/clients.md
@@ -240,7 +240,7 @@ Authorizations auths = new Authorizations("public");
 
 try (Scanner scan = client.createScanner("table", auths)) {
   scan.setRange(new Range("harry","john"));
-  scan.fetchColumnFamily(new Text("attributes"));
+  scan.fetchColumnFamily("attributes");
 
   for (Entry<Key,Value> entry : scan) {
     Text row = entry.getKey().getRow();
diff --git a/_docs-2/getting-started/table_design.md b/_docs-2/getting-started/table_design.md
index e03d7b3..b029b2b 100644
--- a/_docs-2/getting-started/table_design.md
+++ b/_docs-2/getting-started/table_design.md
@@ -21,11 +21,9 @@ name in the column family, and a blank column qualifier:
 
 ```java
 Mutation m = new Mutation(userid);
-final String column_qualifier = "";
-m.put("age", column_qualifier, age);
-m.put("address", column_qualifier, address);
-m.put("balance", column_qualifier, account_balance);
-
+m.at().family("age").put(age);
+m.at().family("address").put(address);
+m.at().family("balance").put(account_balance);
 writer.add(m);
 ```
 
@@ -38,7 +36,7 @@ AccumuloClient client = Accumulo.newClient()
 Range r = new Range(userid, userid); // single row
 Scanner s = client.createScanner("userdata", auths);
 s.setRange(r);
-s.fetchColumnFamily(new Text("age"));
+s.fetchColumnFamily("age");
 
 for (Entry<Key,Value> entry : s) {
   System.out.println(entry.getValue().toString());
@@ -102,7 +100,7 @@ Date hour = new Date(epoch - (epoch % 3600000));
 
 // encode the rowId so that it is sorted lexicographically
 Mutation mutation = new Mutation(dateEncoder.encode(hour));
-mutation.put(new Text("colf"), new Text("colq"), new Value(new byte[]{}));
+mutation.at().family("colf").qualifier("colq").put(new byte[]{});
 ```
 
 If we want to return the most recent date first, we can reverse the sort order
@@ -119,7 +117,7 @@ Date hour = new Date(epoch - (epoch % 3600000));
 
 // encode the rowId so that it sorts in reverse lexicographic order
 Mutation mutation = new Mutation(reverseEncoder.encode(hour));
-mutation.put(new Text("colf"), new Text("colq"), new Value(new byte[]{}));
+mutation.at().family("colf").qualifier("colq").put(new byte[]{});
 ```
 
 ### Indexing
@@ -153,26 +151,26 @@ and returns an Iterator over all the rows retrieved. The rows returned
are NOT i
 sorted order, as is the case with the basic Scanner interface.
 
 ```java
-// first we scan the index for IDs of rows matching our query
-Text term = new Text("mySearchTerm");
-
 HashSet<Range> matchingRows = new HashSet<Range>();
 
-Scanner indexScanner = createScanner("index", auths);
-indexScanner.setRange(new Range(term, term));
+// first we scan the index for IDs of rows matching our query
+try (Scanner indexScanner = client.createScanner("index", auths)) {
+  indexScanner.setRange(Range.exact("mySearchTerm");
 
-// we retrieve the matching rowIDs and create a set of ranges
-for (Entry<Key,Value> entry : indexScanner) {
+  // we retrieve the matching rowIDs and create a set of ranges
+  for (Entry<Key,Value> entry : indexScanner) {
     matchingRows.add(new Range(entry.getKey().getColumnQualifier()));
+  }
 }
 
 // now we pass the set of rowIDs to the batch scanner to retrieve them
-BatchScanner bscan = client.createBatchScanner("table", auths, 10);
-bscan.setRanges(matchingRows);
-bscan.fetchColumnFamily(new Text("attributes"));
+try (BatchScanner bscan = client.createBatchScanner("table", auths, 10)) {
+  bscan.setRanges(matchingRows);
+  bscan.fetchColumnFamily("attributes");
 
-for (Entry<Key,Value> entry : bscan) {
+  for (Entry<Key,Value> entry : bscan) {
     System.out.println(entry.getValue());
+  }
 }
 ```
 
@@ -279,16 +277,17 @@ BatchScanner within user query code as follows:
 ```java
 Text[] terms = {new Text("the"), new Text("white"), new Text("house")};
 
-BatchScanner bscan = client.createBatchScanner(table, auths, 20);
+try (BatchScanner bscan = client.createBatchScanner(table, auths, 20)) {
 
-IteratorSetting iter = new IteratorSetting(20, "ii", IntersectingIterator.class);
-IntersectingIterator.setColumnFamilies(iter, terms);
+  IteratorSetting iter = new IteratorSetting(20, "ii", IntersectingIterator.class);
+  IntersectingIterator.setColumnFamilies(iter, terms);
 
-bscan.addScanIterator(iter);
-bscan.setRanges(Collections.singleton(new Range()));
+  bscan.addScanIterator(iter);
+  bscan.setRanges(Collections.singleton(new Range()));
 
-for (Entry<Key,Value> entry : bscan) {
+  for (Entry<Key,Value> entry : bscan) {
     System.out.println(" " + entry.getKey().getColumnQualifier());
+  }
 }
 ```
 


Mime
View raw message