/** * Write the string table to the fsimage. * @throws IOException */ private void writeStringTableSection() throws IOException { FsImageProto.StringTableSection sectionHeader = FsImageProto.StringTableSection.newBuilder(). setNumEntry(stringTable.size()).build(); if (LOG.isDebugEnabled()) { LOG.debug(SectionName.STRING_TABLE.name() + " writing header: {" + TextFormat.printToString(sectionHeader) + "}"); } sectionHeader.writeDelimitedTo(out); // The entries don't have to be in any particular order, so iterating // over the hash table is fine. for (Map.Entry<String, Integer> entry : stringTable.entrySet()) { FsImageProto.StringTableSection.Entry stEntry = FsImageProto.StringTableSection.Entry.newBuilder(). setStr(entry.getKey()). setId(entry.getValue()). build(); if (LOG.isTraceEnabled()) { LOG.trace("Writing string table entry: {" + TextFormat.printToString(stEntry) + "}"); } stEntry.writeDelimitedTo(out); } recordSectionLength(SectionName.STRING_TABLE.name()); }
private void saveStringTableSection(FileSummary.Builder summary) throws IOException { OutputStream out = sectionOutputStream; SerialNumberManager.StringTable stringTable = SerialNumberManager.getStringTable(); StringTableSection.Builder b = StringTableSection.newBuilder() .setNumEntry(stringTable.size()) .setMaskBits(stringTable.getMaskBits()); b.build().writeDelimitedTo(out); for (Entry<Integer, String> e : stringTable) { StringTableSection.Entry.Builder eb = StringTableSection.Entry .newBuilder().setId(e.getKey()).setStr(e.getValue()); eb.build().writeDelimitedTo(out); } commitSection(summary, SectionName.STRING_TABLE); } }
void writeStringTableSection() throws IOException { StringTableSection.Builder b = StringTableSection.newBuilder(); Map<Integer, String> u = ugis.ugiMap(); b.setNumEntry(u.size()); StringTableSection s = b.build(); OutputStream sec = beginSection(raw); s.writeDelimitedTo(sec); for (Map.Entry<Integer, String> e : u.entrySet()) { StringTableSection.Entry.Builder x = StringTableSection.Entry.newBuilder() .setId(e.getKey()) .setStr(e.getValue()); x.build().writeDelimitedTo(sec); } endSection(sec, SectionName.STRING_TABLE); }
private void saveStringTableSection(FileSummary.Builder summary) throws IOException { OutputStream out = sectionOutputStream; StringTableSection.Builder b = StringTableSection.newBuilder() .setNumEntry(saverContext.stringMap.size()); b.build().writeDelimitedTo(out); for (Entry<String, Integer> e : saverContext.stringMap.entrySet()) { StringTableSection.Entry.Builder eb = StringTableSection.Entry .newBuilder().setId(e.getValue()).setStr(e.getKey()); eb.build().writeDelimitedTo(out); } commitSection(summary, SectionName.STRING_TABLE); } }
private void saveStringTableSection(FileSummary.Builder summary) throws IOException { OutputStream out = sectionOutputStream; StringTableSection.Builder b = StringTableSection.newBuilder() .setNumEntry(saverContext.stringMap.size()); b.build().writeDelimitedTo(out); for (Entry<String, Integer> e : saverContext.stringMap.entrySet()) { StringTableSection.Entry.Builder eb = StringTableSection.Entry .newBuilder().setId(e.getValue()).setStr(e.getKey()); eb.build().writeDelimitedTo(out); } commitSection(summary, SectionName.STRING_TABLE); } }