hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Yu <yuzhih...@gmail.com>
Subject Re: Hfile Reader/Scanner continues to serve data after close
Date Sat, 02 Mar 2013 16:26:08 GMT
Can you put the following code in a JUnit test ?

Thanks

On Wed, Jan 30, 2013 at 7:47 PM, aasoj j <aas.ojj@gmail.com> 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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message