### Question:
StringDictionaryEncoder extends DictionaryEncoder { @Override public int size() { return numElements; } StringDictionaryEncoder(MemoryEstimate memoryEstimate);  StringDictionaryEncoder(boolean sortKeys, boolean sortByStride,
      MemoryEstimate memoryEstimate); int add(Text value, int indexStride); void visit(Visitor<Text> visitor); void getText(Text result, int originalPosition); @Override void clear(); long getCharacterSize(); int getUncompressedLength(); @Override int size(); void cleanup();  }### Answer:
@Test public void test2() throws Exception { String [] v = new String[] {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}; StringDictionaryEncoder dict = buildDictionary(v, true); assertEquals(26, dict.size()); checkContent(dict, v, new int[]{0,1,2, 3,4,5, 6,7,8, 9,10,11, 12,13,14, 15,16,17, 18,19,20, 21,22,23, 24,25}); }
@Test public void test3() throws Exception { String [] v = new String[] {"z", "y", "x", "w", "v", "u", "t", "s", "r", "q", "p", "o", "n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b", "a"}; StringDictionaryEncoder dict = buildDictionary(v, true); assertEquals(26, dict.size()); Arrays.sort(v); checkContent(dict, v, new int[]{25,24,23, 22,21,20, 19,18,17, 16,15,14, 13,12,11, 10,9,8, 7,6,5, 4,3,2, 1,0}); }
@Test public void test4() throws Exception { String [] v = new String[] {"z", "y", "x", "w", "v", "u", "t", "s", "r", "q", "p", "o", "n", "m", "l", "k", "j", "i", "h", "g", "f", "e", "d", "c", "b", "a"}; StringDictionaryEncoder dict = buildDictionary(v, false); assertEquals(26, dict.size()); checkContent(dict, v, new int[]{0,1,2, 3,4,5, 6,7,8, 9,10,11, 12,13,14, 15,16,17, 18,19,20, 21,22,23, 24,25}); }