Search in sources :

Example 1 with StoreLargeAssociated

use of io.zulia.client.command.StoreLargeAssociated in project zuliasearch by zuliaio.

the class ZuliaCmdUtil method storeAssociatedDoc.

private static void storeAssociatedDoc(String index, ZuliaWorkPool workPool, String id, String filename, Document meta, byte[] associatedBytes) throws Exception {
    if (associatedBytes.length > 32 * 1024 * 1024) {
        workPool.storeLargeAssociated(new StoreLargeAssociated(id, index, filename, associatedBytes).setMeta(meta));
    } else {
        Store associatedDocStore = new Store(id, index);
        associatedDocStore.addAssociatedDocument(AssociatedBuilder.newBuilder().setDocument(associatedBytes).setMetadata(meta).setFilename(filename));
        workPool.store(associatedDocStore);
    }
}
Also used : Store(io.zulia.client.command.Store) StoreLargeAssociated(io.zulia.client.command.StoreLargeAssociated)

Example 2 with StoreLargeAssociated

use of io.zulia.client.command.StoreLargeAssociated in project zuliasearch by zuliaio.

the class ZuliaStoreFile method main.

public static void main(String[] args) {
    LogUtil.init();
    ZuliaStoreFileArgs zuliaStoreFileArgs = new ZuliaStoreFileArgs();
    JCommander jCommander = JCommander.newBuilder().addObject(zuliaStoreFileArgs).build();
    try {
        jCommander.parse(args);
        ZuliaPoolConfig zuliaPoolConfig = new ZuliaPoolConfig().addNode(zuliaStoreFileArgs.address, zuliaStoreFileArgs.port).setNodeUpdateEnabled(false);
        ZuliaWorkPool workPool = new ZuliaWorkPool(zuliaPoolConfig);
        // String uniqueId, String indexName, String fileName, File fileToStore
        File fileToStore = new File(zuliaStoreFileArgs.fileToStore);
        if (!fileToStore.exists()) {
            System.err.println("File " + fileToStore.getAbsolutePath() + " does not exist");
            System.exit(3);
        }
        StoreLargeAssociated storeLargeAssociated = new StoreLargeAssociated(zuliaStoreFileArgs.id, zuliaStoreFileArgs.index, zuliaStoreFileArgs.fileName, Files.readAllBytes(fileToStore.toPath()));
        workPool.storeLargeAssociated(storeLargeAssociated);
    } catch (ParameterException e) {
        System.err.println(e.getMessage());
        jCommander.usage();
        System.exit(2);
    } catch (UnsupportedOperationException e) {
        System.err.println("Error: " + e.getMessage());
        System.exit(2);
    } catch (Exception e) {
        System.err.println("Error: " + e.getMessage());
        e.printStackTrace();
        System.exit(1);
    }
}
Also used : ZuliaWorkPool(io.zulia.client.pool.ZuliaWorkPool) ZuliaPoolConfig(io.zulia.client.config.ZuliaPoolConfig) JCommander(com.beust.jcommander.JCommander) ParameterException(com.beust.jcommander.ParameterException) StoreLargeAssociated(io.zulia.client.command.StoreLargeAssociated) File(java.io.File) ParameterException(com.beust.jcommander.ParameterException)

Example 3 with StoreLargeAssociated

use of io.zulia.client.command.StoreLargeAssociated in project zuliasearch by zuliaio.

the class FileStorageTest method storeFile.

private void storeFile(String documentId, String filename, Document meta, byte[] content) throws Exception {
    zuliaWorkPool.delete(new DeleteAssociated(documentId, TEST_INDEX, filename));
    if (content.length > 32 * 1024 * 1024) {
        StoreLargeAssociated storeLargeAssociated = new StoreLargeAssociated(documentId, TEST_INDEX, filename, content);
        storeLargeAssociated.setMeta(meta);
        zuliaWorkPool.storeLargeAssociated(storeLargeAssociated);
    } else {
        Store associatedDocStore = new Store(documentId, TEST_INDEX);
        associatedDocStore.addAssociatedDocument(AssociatedBuilder.newBuilder().setDocument(content).setFilename(filename).setMetadata(meta));
        zuliaWorkPool.store(associatedDocStore);
    }
}
Also used : Store(io.zulia.client.command.Store) StoreLargeAssociated(io.zulia.client.command.StoreLargeAssociated) DeleteAssociated(io.zulia.client.command.DeleteAssociated)

Aggregations

StoreLargeAssociated (io.zulia.client.command.StoreLargeAssociated)3 Store (io.zulia.client.command.Store)2 JCommander (com.beust.jcommander.JCommander)1 ParameterException (com.beust.jcommander.ParameterException)1 DeleteAssociated (io.zulia.client.command.DeleteAssociated)1 ZuliaPoolConfig (io.zulia.client.config.ZuliaPoolConfig)1 ZuliaWorkPool (io.zulia.client.pool.ZuliaWorkPool)1 File (java.io.File)1