| | |
| | | PhaseTwoProgressReporter progressReporter, boolean dn2idAlreadyImported) |
| | | { |
| | | final EntryContainer entryContainer = entryContainers.get(treeName.getBaseDN()); |
| | | final ID2Count id2count = entryContainer.getID2ChildrenCount(); |
| | | final ID2ChildrenCount id2count = entryContainer.getID2ChildrenCount(); |
| | | |
| | | return new DN2IDImporterTask(progressReporter, importer, tempDir, bufferPool, entryContainer.getDN2ID(), chunk, |
| | | id2count, newCollector(entryContainer, id2count.getName()), dn2idAlreadyImported); |
| | |
| | | |
| | | /** |
| | | * This task optionally copy the dn2id chunk into the database and takes advantages of it's cursoring to compute the |
| | | * {@link ID2Count} index. |
| | | * {@link ID2ChildrenCount} index. |
| | | */ |
| | | private static final class DN2IDImporterTask implements Callable<Void> |
| | | { |
| | |
| | | private final File tempDir; |
| | | private final BufferPool bufferPool; |
| | | private final DN2ID dn2id; |
| | | private final ID2Count id2count; |
| | | private final ID2ChildrenCount id2count; |
| | | private final Collector<?, ByteString> id2countCollector; |
| | | private final Chunk dn2IdSourceChunk; |
| | | private final Chunk dn2IdDestination; |
| | | |
| | | DN2IDImporterTask(PhaseTwoProgressReporter progressReporter, Importer importer, File tempDir, BufferPool bufferPool, |
| | | DN2ID dn2id, Chunk dn2IdChunk, ID2Count id2count, Collector<?, ByteString> id2countCollector, |
| | | DN2ID dn2id, Chunk dn2IdChunk, ID2ChildrenCount id2count, Collector<?, ByteString> id2countCollector, |
| | | boolean dn2idAlreadyImported) |
| | | { |
| | | this.reporter = progressReporter; |
| | |
| | | else if (isID2ChildrenCount(treeName)) |
| | | { |
| | | // key conflicts == sum values |
| | | return new AddLongCollector(entryContainer.getID2ChildrenCount()); |
| | | return ID2ChildrenCount.getSumLongCollectorInstance(); |
| | | } |
| | | else if (isDN2ID(treeName) || isDN2URI(treeName) || isVLVIndex(entryContainer, treeName)) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * {@link Collector} that accepts {@code long} values encoded into {@link ByteString} objects and produces a |
| | | * {@link ByteString} representing the sum of the supplied {@code long}s. |
| | | */ |
| | | static final class AddLongCollector implements Collector<Long, ByteString> |
| | | { |
| | | private final ID2Count id2count; |
| | | |
| | | AddLongCollector(ID2Count id2count) |
| | | { |
| | | this.id2count = id2count; |
| | | } |
| | | |
| | | @Override |
| | | public Long get() |
| | | { |
| | | return 0L; |
| | | } |
| | | |
| | | @Override |
| | | public Long accept(Long resultContainer, ByteString value) |
| | | { |
| | | return resultContainer + id2count.fromValue(value); |
| | | } |
| | | |
| | | @Override |
| | | public ByteString merge(Long resultContainer) |
| | | { |
| | | return id2count.toValue(resultContainer); |
| | | } |
| | | } |
| | | |
| | | private static MeteredCursor<ByteString, ByteString> asProgressCursor( |
| | | SequentialCursor<ByteString, ByteString> delegate, String metricName, long totalSize) |
| | | { |