Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 46DD5200D34 for ; Fri, 3 Nov 2017 22:08:21 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 45728160BFB; Fri, 3 Nov 2017 21:08:21 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8F76A160BDE for ; Fri, 3 Nov 2017 22:08:20 +0100 (CET) Received: (qmail 50240 invoked by uid 500); 3 Nov 2017 21:08:19 -0000 Mailing-List: contact notifications-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jira@apache.org Delivered-To: mailing list notifications@accumulo.apache.org Received: (qmail 50229 invoked by uid 99); 3 Nov 2017 21:08:19 -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; Fri, 03 Nov 2017 21:08:19 +0000 From: GitBox To: notifications@accumulo.apache.org Subject: [GitHub] keith-turner commented on a change in pull request #35: ACCUMULO-4734 Content for getting-started and basic-read-write Message-ID: <150974329915.10043.10459516452983559887.gitbox@gitbox.apache.org> archived-at: Fri, 03 Nov 2017 21:08:21 -0000 keith-turner commented on a change in pull request #35: ACCUMULO-4734 Content for getting-started and basic-read-write URL: https://github.com/apache/accumulo-website/pull/35#discussion_r148893773 ########## File path: tour/basic-read-write.md ########## @@ -1,5 +1,67 @@ --- -title: Basic Reading & Writing +title: Writing and Reading --- +Accumulo is a big data key/value store. Writing data to Accumulo is flexible and fast. Like any database, Accumulo stores +data in tables and rows. Each row in an Accumulo table can hold many key/value pairs. -Talk about reading and writing. +1. Start by connecting to Mini Accumulo and create a table called "superheroes". For now, connect as the root user. +```java +Connector conn = mac.getConnector("root", "tourguide"); +conn.tableOperations().create("superheroes"); +``` + +2. Create a Mutation object for row1 +```java +Mutation mutation = new Mutation("row1"); +``` +A Mutation is an object that holds all changes to a row in a table. Each row has a unique row ID. + +3. Create key/value pairs for Batman. +```java +mutation.put("name", "", "Batman"); +mutation.put("real-name", "", "Bruce Wayne"); +mutation.put("wearsCape?", "", "true"); +mutation.put("flies?", "", "false"); +``` +Every Mutation in Accumulo is atomic. This means that all the changes to a single row will happen at once. The Mutation +object conveniently allows us to put all the changes for the row in one spot. + +4. Create a BatchWriter to the superhero table and add your mutation to it. +```java +BatchWriter writer = conn.createBatchWriter("superheroes", new BatchWriterConfig()); +writer.addMutation(mutation); +writer.close(); +``` +Accumulo is very efficient, so it prefers data to arrive in batches. The BatchWriter will take care of this for us. +Once we are finished, closing the BatchWriter will tell Accumulo everything is good to go. Review comment: could also cover this information later in the tour... keep the starting page simple ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services