Can you put the following code in a JUnit test ? Thanks
On Wed, Jan 30, 2013 at 7:47 PM, aasoj j <[email protected]> wrote: > Hi, > > I am evaluating reading hfile directly. In one of my test cases, I call > close on the hfile Reader and also request block eviction. Even after > calling close(), a newly created scanner continues to serve data. I > expected it to fail. Please clarify my understanding. Here is the sample > code > > // cerate a hfile, on disk and put 2 keys > > Path hfilePath = new Path("/tmp/test-hfile"); > > Writer writer = HFile.getWriterFactory(conf, cacheConf).withPath(fs, > hfilePath).create(); > > writer.append("key-1".getBytes(), "value".getBytes()); > > writer.append("key-2".getBytes(), "value".getBytes()); > > writer.close(); > > > // create the reader, close it and request block eviction > > Reader reader = HFile.createReader(fs, hfilePath, cacheConf); > > reader.close(true); // evict blocks if at all and close reader > > > // as reader is closed, scanner should fail, but it works > > HFileScanner scanner = reader.getScanner(false, true); // do not cache > blocks > > boolean found = scanner.seekTo(); > > System.out.println(found); // outputs true > > ByteBuffer key = scanner.getKey(); > > System.out.println(new String(key.array(), key.arrayOffset(), > key.remaining())); // prints key-1 > > > Thanks in advance > > Regards > -aasoj >
