Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-13779

Calling table.exists() before table.get() end up with an empty Result

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.1.0, 1.2.0, 0.98.12.1, 2.0.0
    • 0.98.13, 1.0.2, 1.2.0, 1.1.1, 2.0.0
    • Client
    • None

    Description

      If we call exists() before a get() the result returned by the get() will be empty.
      simple test to verify it:

      Put put = new Put(ROW);
      put.add(FAMILY, QUALIFIER, VALUE);
      table.put(put);
      
      Get get = new Get(ROW);
      
      boolean exist = table.exists(get);
      exist = table.exists(get);
      assertEquals(true, exist);
      
      Result result = table.get(get);
      // this will fail saying that the Result is empty
      // if we remove the exist everything is fine
      assertEquals(false, result.isEmpty()); 
      assertTrue(Bytes.equals(VALUE, result.getValue(FAMILY, QUALIFIER)));
      

      if we use a different Get instance for the get everything works

      ...
      get = new Get(ROW);
      Result result = table.get(get);
      assertEquals(false, result.isEmpty()); 
      

      HTable.exists() set the checkExistenceOnly flag in the Get so that object is not reusable by a table.get()

        public boolean exists(final Get get) throws IOException {
          get.setCheckExistenceOnly(true);
          Result r = get(get);
          assert r.getExists() != null;
          return r.getExists();
        }
      

      Attachments

        1. HBASE-13779-test.patch
          1 kB
          Matteo Bertozzi
        2. HBASE-13779-v0.patch
          9 kB
          Matteo Bertozzi
        3. HBASE-13779-v0.patch
          9 kB
          Michael Stack
        4. 13779-addendum.txt
          0.7 kB
          Ted Yu
        5. HBASE-13779-addendum.patch
          4 kB
          Matteo Bertozzi

        Issue Links

          Activity

            People

              mbertozzi Matteo Bertozzi
              mbertozzi Matteo Bertozzi
              Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: