hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aasoj j <aas....@gmail.com>
Subject Hfile Reader/Scanner continues to serve data after close
Date Thu, 31 Jan 2013 03:47:36 GMT
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