Exemplo n.º 1
0
  /** Tests setting the lower case configuration. */
  @Test
  public void testNotLowerCase() {
    // Add a new value that we won't lower case
    CKeyValue keyValue =
        new CKeyValue(
            rowId.getBytes(),
            colFam1.getBytes(),
            colQual1.getBytes(),
            "That was the old Fry. He's dead now.".getBytes());
    Put put = new Put(keyValue);

    // Set the splitable indicator to false
    TermBasedIndex.setToLower(false, conf);

    // Insert the data
    termIndex.handlePut(put);

    // Get Fry back
    byte[] fryBytes = "Fry".getBytes();

    // The end byte object should look like: steve\x01
    // This represents the next possible value which is allowable
    // since we pad the value with 6 null bytes.
    byte[] end = new byte[fryBytes.length + 1];
    System.arraycopy(fryBytes, 0, end, 0, fryBytes.length);
    end[end.length - 1] = 0x01;

    SeekingCurrentIterator indexIterator = termIndex.handleGet(fryBytes, end);

    // Test the returned data
    int count = 0;
    while (indexIterator.hasNext()) {
      Result result = indexIterator.next();
      count++;

      assertTrue(Bytes.compareTo(result.getRecordId(), rowIdBytes) == 0);
    }

    // Test if we have the expected number of results
    assertTrue(count == 1);
  }