Package io.crate.blob

Examples of io.crate.blob.DigestBlob


        File filePath = new File(container.getTmpDirectory(), String.format("%s.%s", digest, transferId.toString()));
        if (filePath.exists()) {
            filePath.delete();
        }

        DigestBlob digestBlob = DigestBlob.resumeTransfer(
            container, digest, transferId, currentPos);

        BytesArray contentHead = new BytesArray("A".getBytes());
        digestBlob.addToHead(contentHead);

        BytesArray contentTail = new BytesArray("CDEFGHIJKL".getBytes());
        digestBlob.addContent(contentTail, false);

        contentHead = new BytesArray("B".getBytes());
        digestBlob.addToHead(contentHead);

        contentTail = new BytesArray("MNO".getBytes());
        digestBlob.addContent(contentTail, true);

        byte[] buffer = new byte[15];
        FileInputStream stream = new FileInputStream(digestBlob.file());
        stream.read(buffer, 0, 15);
        assertEquals("ABCDEFGHIJKLMNO", new BytesArray(buffer).toUtf8().trim());
        File file = digestBlob.commit();
        assertTrue(file.exists());
        file.delete();
    }
View Full Code Here


    @Test
    public void testResumeDigestBlobAddHeadAfterContent() throws IOException {
        UUID transferId = UUID.randomUUID();
        BlobContainer container = new BlobContainer(tmpDir.toFile());
        DigestBlob digestBlob = DigestBlob.resumeTransfer(
            container, "417de3231e23dcd6d224ff60918024bc6c59aa58", transferId, 2);

        BytesArray contentTail = new BytesArray("CDEFGHIJKLMN".getBytes());
        digestBlob.addContent(contentTail, false);

        BytesArray contentHead = new BytesArray("AB".getBytes());
        digestBlob.addToHead(contentHead);

        contentTail = new BytesArray("O".getBytes());
        digestBlob.addContent(contentTail, true);

        byte[] buffer = new byte[15];
        FileInputStream stream = new FileInputStream(digestBlob.file());
        stream.read(buffer, 0, 15);
        assertEquals("ABCDEFGHIJKLMNO", new BytesArray(buffer).toUtf8().trim());
        File file = digestBlob.commit();
        assertTrue(file.exists());
        file.delete();
    }
View Full Code Here

TOP

Related Classes of io.crate.blob.DigestBlob

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.