use of org.elasticsearch.common.bytes.BytesArray in project crate by crate.
the class BlobRecoveryHandler method getExistingDigestsFromTarget.
private Set<BytesArray> getExistingDigestsFromTarget(byte prefix) {
BlobStartPrefixResponse response = (BlobStartPrefixResponse) transportService.submitRequest(request.targetNode(), BlobRecoveryTarget.Actions.START_PREFIX, new BlobStartPrefixSyncRequest(request.recoveryId(), request.shardId(), prefix), TransportRequestOptions.EMPTY, new FutureTransportResponseHandler<TransportResponse>() {
@Override
public TransportResponse newInstance() {
return new BlobStartPrefixResponse();
}
}).txGet();
Set<BytesArray> result = new HashSet<BytesArray>();
for (byte[] digests : response.existingDigests) {
result.add(new BytesArray(digests));
}
return result;
}
use of org.elasticsearch.common.bytes.BytesArray in project crate by crate.
the class RemoteDigestBlob method chunk.
private Status chunk(ChannelBuffer buffer, boolean last) {
assert transferId != null : "transferId should not be null";
PutChunkRequest request = new PutChunkRequest(index, Hex.decodeHex(digest), transferId, new BytesArray(buffer.array()), size, last);
size += buffer.readableBytes();
PutChunkResponse putChunkResponse = client.execute(PutChunkAction.INSTANCE, request).actionGet();
return putChunkResponse.status();
}
use of org.elasticsearch.common.bytes.BytesArray in project crate by crate.
the class TransportShardUpsertAction method buildMapFromSource.
@VisibleForTesting
Map<String, Object> buildMapFromSource(Reference[] insertColumns, Object[] insertValues, boolean isRawSourceInsert) {
Map<String, Object> sourceAsMap;
if (isRawSourceInsert) {
BytesRef source = (BytesRef) insertValues[0];
sourceAsMap = XContentHelper.convertToMap(new BytesArray(source), true).v2();
} else {
sourceAsMap = new LinkedHashMap<>(insertColumns.length);
for (int i = 0; i < insertColumns.length; i++) {
sourceAsMap.put(insertColumns[i].ident().columnIdent().fqn(), insertValues[i]);
}
}
return sourceAsMap;
}
use of org.elasticsearch.common.bytes.BytesArray in project elasticsearch by elastic.
the class SearchHitTests method testHasSource.
public void testHasSource() {
SearchHit searchHit = new SearchHit(randomInt());
assertFalse(searchHit.hasSource());
searchHit.sourceRef(new BytesArray("{}"));
assertTrue(searchHit.hasSource());
}
use of org.elasticsearch.common.bytes.BytesArray in project elasticsearch by elastic.
the class StoredScriptsIT method testBasics.
public void testBasics() {
assertAcked(client().admin().cluster().preparePutStoredScript().setLang(LANG).setId("foobar").setContent(new BytesArray("{\"script\":\"1\"}"), XContentType.JSON));
String script = client().admin().cluster().prepareGetStoredScript(LANG, "foobar").get().getSource().getCode();
assertNotNull(script);
assertEquals("1", script);
assertAcked(client().admin().cluster().prepareDeleteStoredScript().setId("foobar").setLang(LANG));
StoredScriptSource source = client().admin().cluster().prepareGetStoredScript(LANG, "foobar").get().getSource();
assertNull(source);
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> client().admin().cluster().preparePutStoredScript().setLang("lang#").setId("id#").setContent(new BytesArray("{}"), XContentType.JSON).get());
assertEquals("Validation Failed: 1: id cannot contain '#' for stored script;" + "2: lang cannot contain '#' for stored script;", e.getMessage());
}
Aggregations