Search in sources :

Example 1 with RecordType

use of org.apache.jackrabbit.oak.segment.RecordType in project jackrabbit-oak by apache.

the class AbstractFileStore method readBinaryReferences.

static Set<String> readBinaryReferences(final Segment segment) {
    final Set<String> binaryReferences = new HashSet<>();
    segment.forEachRecord(new RecordConsumer() {

        @Override
        public void consume(int number, RecordType type, int offset) {
            if (type == RecordType.BLOB_ID) {
                binaryReferences.add(SegmentBlob.readBlobId(segment, number));
            }
        }
    });
    return binaryReferences;
}
Also used : RecordType(org.apache.jackrabbit.oak.segment.RecordType) RecordConsumer(org.apache.jackrabbit.oak.segment.Segment.RecordConsumer) HashSet(java.util.HashSet)

Example 2 with RecordType

use of org.apache.jackrabbit.oak.segment.RecordType in project jackrabbit-oak by apache.

the class SegmentTarFactory method hasExternalBlobReferences.

@Override
public boolean hasExternalBlobReferences() throws IOException {
    final FileStoreBuilder builder = fileStoreBuilder(new File(dir, "segmentstore"));
    builder.withMaxFileSize(256);
    builder.withMemoryMapping(false);
    ReadOnlyFileStore fs;
    try {
        fs = builder.buildReadOnly();
    } catch (InvalidFileStoreVersionException e) {
        throw new IOException(e);
    }
    try {
        for (SegmentId id : fs.getSegmentIds()) {
            if (!id.isDataSegmentId()) {
                continue;
            }
            id.getSegment().forEachRecord(new Segment.RecordConsumer() {

                @Override
                public void consume(int number, RecordType type, int offset) {
                    // see java.nio.file.FileVisitor
                    if (type == RecordType.BLOB_ID) {
                        throw new ExternalBlobFound();
                    }
                }
            });
        }
        return false;
    } catch (ExternalBlobFound e) {
        return true;
    } finally {
        fs.close();
    }
}
Also used : FileStoreBuilder(org.apache.jackrabbit.oak.segment.file.FileStoreBuilder) RecordType(org.apache.jackrabbit.oak.segment.RecordType) InvalidFileStoreVersionException(org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException) SegmentId(org.apache.jackrabbit.oak.segment.SegmentId) ReadOnlyFileStore(org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore) IOException(java.io.IOException) File(java.io.File) Segment(org.apache.jackrabbit.oak.segment.Segment)

Example 3 with RecordType

use of org.apache.jackrabbit.oak.segment.RecordType in project jackrabbit-oak by apache.

the class DebugStore method analyseSegment.

private static void analyseSegment(final Segment segment, final RecordUsageAnalyser analyser) {
    final List<RecordId> ids = newArrayList();
    segment.forEachRecord(new RecordConsumer() {

        @Override
        public void consume(int number, RecordType type, int offset) {
            if (type == NODE) {
                ids.add(new RecordId(segment.getSegmentId(), number));
            }
        }
    });
    for (RecordId id : ids) {
        try {
            analyser.analyseNode(id);
        } catch (Exception e) {
            System.err.format("Error while processing node at %s", id);
            e.printStackTrace();
        }
    }
}
Also used : RecordType(org.apache.jackrabbit.oak.segment.RecordType) RecordId(org.apache.jackrabbit.oak.segment.RecordId) RecordConsumer(org.apache.jackrabbit.oak.segment.Segment.RecordConsumer)

Example 4 with RecordType

use of org.apache.jackrabbit.oak.segment.RecordType in project jackrabbit-oak by apache.

the class AbstractFileStore method populateTarBinaryReferences.

static void populateTarBinaryReferences(final Segment segment, final TarWriter w) {
    final int generation = segment.getGcGeneration();
    final UUID id = segment.getSegmentId().asUUID();
    segment.forEachRecord(new RecordConsumer() {

        @Override
        public void consume(int number, RecordType type, int offset) {
            if (type == RecordType.BLOB_ID) {
                w.addBinaryReference(generation, id, SegmentBlob.readBlobId(segment, number));
            }
        }
    });
}
Also used : RecordType(org.apache.jackrabbit.oak.segment.RecordType) UUID(java.util.UUID) RecordConsumer(org.apache.jackrabbit.oak.segment.Segment.RecordConsumer)

Aggregations

RecordType (org.apache.jackrabbit.oak.segment.RecordType)4 RecordConsumer (org.apache.jackrabbit.oak.segment.Segment.RecordConsumer)3 File (java.io.File)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 UUID (java.util.UUID)1 RecordId (org.apache.jackrabbit.oak.segment.RecordId)1 Segment (org.apache.jackrabbit.oak.segment.Segment)1 SegmentId (org.apache.jackrabbit.oak.segment.SegmentId)1 FileStoreBuilder (org.apache.jackrabbit.oak.segment.file.FileStoreBuilder)1 InvalidFileStoreVersionException (org.apache.jackrabbit.oak.segment.file.InvalidFileStoreVersionException)1 ReadOnlyFileStore (org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore)1