org.apache.hadoop.util
Class StringInterner

java.lang.Object
  extended by org.apache.hadoop.util.StringInterner

@InterfaceAudience.Public
@InterfaceStability.Stable
public class StringInterner
extends Object

Provides equivalent behavior to String.intern() to optimize performance, whereby does not consume memory in the permanent generation.


Constructor Summary
StringInterner()
           
 
Method Summary
static String strongIntern(String sample)
          Interns and returns a reference to the representative instance for any of a collection of string instances that are equal to each other.
static String weakIntern(String sample)
          Interns and returns a reference to the representative instance for any of a collection of string instances that are equal to each other.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringInterner

public StringInterner()
Method Detail

strongIntern

public static String strongIntern(String sample)
Interns and returns a reference to the representative instance for any of a collection of string instances that are equal to each other. Retains strong reference to the instance, thus preventing it from being garbage-collected.

Parameters:
sample - string instance to be interned
Returns:
strong reference to interned string instance

weakIntern

public static String weakIntern(String sample)
Interns and returns a reference to the representative instance for any of a collection of string instances that are equal to each other. Retains weak reference to the instance, and so does not prevent it from being garbage-collected.

Parameters:
sample - string instance to be interned
Returns:
weak reference to interned string instance


Copyright © 2014 Apache Software Foundation. All Rights Reserved.