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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.0, 1.2.0, 0.98.12.1, 2.0.0
    • Fix Version/s: 0.98.13, 1.0.2, 1.2.0, 1.1.1, 2.0.0
    • Component/s: Client
    • Labels:
      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-v0.patch
          9 kB
          Matteo Bertozzi
        2. HBASE-13779-v0.patch
          9 kB
          stack
        3. HBASE-13779-test.patch
          1 kB
          Matteo Bertozzi
        4. HBASE-13779-addendum.patch
          4 kB
          Matteo Bertozzi
        5. 13779-addendum.txt
          0.7 kB
          Ted Yu

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: