Return-Path: X-Original-To: apmail-hbase-user-archive@www.apache.org Delivered-To: apmail-hbase-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 08AF89D0A for ; Mon, 12 Mar 2012 15:15:09 +0000 (UTC) Received: (qmail 46825 invoked by uid 500); 12 Mar 2012 15:15:07 -0000 Delivered-To: apmail-hbase-user-archive@hbase.apache.org Received: (qmail 46758 invoked by uid 500); 12 Mar 2012 15:15:07 -0000 Mailing-List: contact user-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hbase.apache.org Delivered-To: mailing list user@hbase.apache.org Delivered-To: moderator for user@hbase.apache.org Received: (qmail 74866 invoked by uid 99); 12 Mar 2012 11:12:34 -0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :x-gm-message-state; bh=lJUADOMs6mdkp7EiQW5lTqRi27U9g7XcYe/h4UhwivU=; b=A2HEHQW5h0KM3oWBNsjj93Akkiz6ybvgNlMT4Fjg6Zgfv+MEfzOglCEZevx+Vq3oty qvZ/xbq5gVqFGFa46zfcOMzKAwr5dCuxHXx9WsMpPx0TyNyTgXcfuWUsi6AjadPxirF8 482aXRyJu7y/RKgkPyi422FbbBuFoNGk9WHuZcNm4D9DPqNirL9ceI8084Qxi3cBTxhY lG5OGIpuuQnjoyRbpy+BTX1U4TnL662WZushHhPcOTJ1lahaJnZ44sp5cBgIpDdnDvGA RxfWWO8mgwiEI30KQrWQWcRxMF+llTZjAu/18zYVdx3lWFFeMqdqD2jxHmlkMbbwKMO4 5htg== MIME-Version: 1.0 Date: Mon, 12 Mar 2012 12:12:07 +0100 Message-ID: Subject: When creating and loading HFile programmatically to HBase new entries are unavailable From: =?ISO-8859-1?Q?Nicolas_Thi=E9baud?= To: user@hbase.apache.org Content-Type: multipart/alternative; boundary=f46d044784971880db04bb09d0e4 X-Gm-Message-State: ALoCoQkbiJBfIKTB36iTKzMQFdVHRBtDRNm21k/sqsWlfy/A4fZmpC+rYb1NLapfFfjCqGX3wg/j X-Virus-Checked: Checked by ClamAV on apache.org --f46d044784971880db04bb09d0e4 Content-Type: text/plain; charset=ISO-8859-1 I'm trying to create HFiles programmatically and loading them in a running HBase instance. I found a lot of info in HFileOutputFormat and in LoadIncrementalHFiles I managed to create the new HFile, send it to the cluster. In the cluster web interface the new store file appears but the new keyrange is unavailable for query. InputStream stream = ProgrammaticHFileGeneration.class.getResourceAsStream("ga-hourly.txt"); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); String line = null; Map rowValues = new HashMap(); while((line = reader.readLine())!=null) { String[] vals = line.split(","); String row = new StringBuilder(vals[0]).append(".").append(vals[1]).append(".").append(vals[2]).append(".").append(vals[3]).toString(); rowValues.put(row.getBytes(), line); } List keys = new ArrayList(rowValues.keySet()); Collections.sort(keys, byteArrComparator); HBaseTestingUtility testingUtility = new HBaseTestingUtility(); testingUtility.startMiniCluster(); testingUtility.createTable("table".getBytes(), "data".getBytes()); Writer writer = new HFile.Writer(testingUtility.getTestFileSystem(), new Path("/tmp/hfiles/data/hfile"), HFile.DEFAULT_BLOCKSIZE, Compression.Algorithm.NONE, KeyValue.KEY_COMPARATOR); for(byte[] key:keys) { writer.append(new KeyValue(key, "data".getBytes(), "d".getBytes(), rowValues.get(key).getBytes())); } writer.appendFileInfo(StoreFile.BULKLOAD_TIME_KEY, Bytes.toBytes(System.currentTimeMillis())); writer.appendFileInfo(StoreFile.MAJOR_COMPACTION_KEY, Bytes.toBytes(true)); writer.close(); Configuration conf = testingUtility.getConfiguration(); LoadIncrementalHFiles loadTool = new LoadIncrementalHFiles(conf); HTable hTable = new HTable(conf, "table".getBytes()); loadTool.doBulkLoad(new Path("/tmp/hfiles"), hTable); ResultScanner scanner = hTable.getScanner("data".getBytes()); Result next = null; System.out.println("Scanning"); while((next = scanner.next()) != null) { System.out.format("%s %s\n", new String(next.getRow()), new String(next.getValue("data".getBytes(), "d".getBytes()))); } What am I doing wrong ? I managed running M/R to Hbase, but I really want the programmatic use case working.. --f46d044784971880db04bb09d0e4--