2

根据文档,最好关闭https://github.com/OpenHFT/Chronicle-Map/blob/master/docs/CM_Tutorial.adoc#close-chroniclemap

我不能,出于某种原因:

Map<String, String> lexicalizationGraph = ChronicleMap
                .of(String.class, String.class)
                .name("lexicalizations-chronicle-map")
                .constantKeySizeBySample("bn:14271053n")
                .averageValue("average size of value")
                .entries(1_000_000_000L)
                .createPersistedTo(file);

然后:

lexicalizationGraph.close();

它给了我以下错误:

symbol:   method close()
  location: variable lexicalizationGraph of type java.util.Map<java.lang.String,java.lang.String>

我该如何关闭它?

4

1 回答 1

3

close方法在 中定义ChronicleMap,而不是Map。要访问它,您必须将变量定义为ChronicleMap(或在需要时显式转换它close(),但不要这样做):

ChronicleMap<String, String> lexicalizationGraph = ChronicleMap 
                .of(String.class, String.class)
                .name("lexicalizations-chronicle-map")
                .constantKeySizeBySample("bn:14271053n")
                .averageValue("average size of value")
                .entries(1_000_000_000L)
                .createPersistedTo(file);
于 2020-01-17T13:59:37.817 回答