Package org.apache.jackrabbit.oak.plugins.segment

Examples of org.apache.jackrabbit.oak.plugins.segment.Segment


                        long dataSize = 0;
                        int bulkCount = 0;
                        long bulkSize = 0;
                        for (UUID uuid : store.getSegmentIds()) {
                            if (SegmentIdFactory.isDataSegmentId(uuid)) {
                                Segment segment = store.readSegment(uuid);
                                dataCount++;
                                dataSize += segment.size();
                                idmap.put(uuid, segment.getReferencedIds());
                            } else if (SegmentIdFactory.isBulkSegmentId(uuid)) {
                                bulkCount++;
                                bulkSize += store.readSegment(uuid).size();
                                idmap.put(uuid, Collections.<UUID>emptyList());
                            }
View Full Code Here


        if (uuid == null) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }

        Segment segment = getSegmentStore().readSegment(uuid);
        if (segment == null) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }

        response.setContentType("application/octet-stream");
        segment.writeTo(response.getOutputStream());
    }
View Full Code Here

        try {
            URL url = new URL(base, "/s/" + id);
            InputStream stream = url.openStream();
            try {
                byte[] data = ByteStreams.toByteArray(stream);
                return new Segment(this, factory, id, ByteBuffer.wrap(data));
            } finally {
                stream.close();
            }
        } catch (MalformedURLException e) {
            throw new IllegalStateException(e);
View Full Code Here

                    ro.limit(ro.position() + length);
                    ByteBuffer data = ro.slice();
                    ro.limit(rw.limit());

                    Segment segment = new Segment(
                            this, segmentId, data, referencedSegmentIds,
                            Collections.<String, RecordId>emptyMap(),
                            Collections.<Template, RecordId>emptyMap());
                    segments.put(segmentId, segment);
View Full Code Here

        return journal;
    }

    @Override
    public Segment readSegment(UUID id) {
        Segment segment = segments.get(id);
        if (segment != null) {
            return segment;
        } else {
            throw new IllegalArgumentException("Segment not found: " + id);
        }
View Full Code Here

        ro.limit(rw.limit());

        rw.position((rw.position() + 0x1ff) & ~0x1ff);
        ro.position(rw.position());

        Segment segment = new Segment(
                this, segmentId, buffer,
                referencedSegmentIds, strings, templates);
        checkState(segments.put(segmentId, segment) == null);
    }
View Full Code Here

            Collection<UUID> referencedSegmentIds,
            Map<String, RecordId> strings, Map<Template, RecordId> templates) {
        byte[] d = new byte[length];
        System.arraycopy(data, offset, d, 0, length);

        cache.addSegment(new Segment(
                this, segmentId, ByteBuffer.wrap(data), referencedSegmentIds,
                Collections.<String, RecordId>emptyMap(),
                Collections.<Template, RecordId>emptyMap()));

        insertSegment(segmentId, d, referencedSegmentIds);
View Full Code Here

        List<?> list = (List<?>) segment.get("uuids");
        List<UUID> uuids = Lists.newArrayListWithCapacity(list.size());
        for (Object object : list) {
            uuids.add(UUID.fromString(object.toString()));
        }
        return new Segment(
                this, segmentId, ByteBuffer.wrap(data), uuids,
                Collections.<String, RecordId>emptyMap(),
                Collections.<Template, RecordId>emptyMap());
    }
View Full Code Here

        return journal;
    }

    @Override
    public Segment readSegment(UUID id) {
        Segment segment = segments.get(id);
        if (segment != null) {
            return segment;
        } else {
            throw new IllegalArgumentException("Segment not found: " + id);
        }
View Full Code Here

            UUID segmentId, byte[] data, int offset, int length,
            Collection<UUID> referencedSegmentIds,
            Map<String, RecordId> strings, Map<Template, RecordId> templates) {
        byte[] buffer = new byte[length];
        System.arraycopy(data, offset, buffer, 0, length);
        Segment segment = new Segment(
                this, segmentId, ByteBuffer.wrap(buffer),
                referencedSegmentIds, strings, templates);
        if (segments.putIfAbsent(segment.getSegmentId(), segment) != null) {
            throw new IllegalStateException(
                    "Segment override: " + segment.getSegmentId());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.plugins.segment.Segment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.