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);
}
}
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);
}
}
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);
}
}
Aggregations