67
67
import org .elasticsearch .common .blobstore .ImmutableBlobContainer ;
68
68
import org .elasticsearch .common .blobstore .support .PlainBlobMetaData ;
69
69
import org .elasticsearch .common .collect .ImmutableMap ;
70
+ import org .elasticsearch .common .collect .ImmutableList ;
71
+ import org .elasticsearch .common .collect .Lists ;
72
+ import org .elasticsearch .common .collect .Maps ;
70
73
import org .elasticsearch .common .component .AbstractComponent ;
71
74
import org .elasticsearch .common .logging .ESLogger ;
72
75
import org .elasticsearch .common .logging .Loggers ;
@@ -192,21 +195,19 @@ private boolean deleteBlobs(String blobPath, String... blobNames)
192
195
long timestamp = System .currentTimeMillis ();
193
196
194
197
Map <String , Map <String , List <Mutation >>> mutationMap =
195
- new HashMap < String , Map < String , List < Mutation >>> ();
198
+ Maps . newHashMap ();
196
199
197
- List <Mutation > blobNamesMutations = new ArrayList < Mutation > ();
200
+ List <Mutation > blobNamesMutations = Lists . newArrayList ();
198
201
199
202
for (String blobName : blobNames ) {
200
203
String blobKey = blobKey (blobPath , blobName );
201
204
202
205
// Delete the blob data from Blobs.
203
206
204
- List <Mutation > blobsMutations = new ArrayList <Mutation >(1 );
205
- blobsMutations .add (createDelete (null , timestamp ));
206
-
207
- Map <String , List <Mutation >> blobsMutationMap =
208
- new HashMap <String , List <Mutation >>();
209
- blobsMutationMap .put ("Blobs" , blobsMutations );
207
+ Map <String , List <Mutation >> blobsMutationMap = Maps .newHashMap ();
208
+ blobsMutationMap .put (
209
+ "Blobs" ,
210
+ ImmutableList .of (createDelete (null , timestamp )));
210
211
211
212
mutationMap .put (blobKey , blobsMutationMap );
212
213
@@ -216,8 +217,7 @@ private boolean deleteBlobs(String blobPath, String... blobNames)
216
217
}
217
218
218
219
Map <String , List <Mutation >> blobNamesMutationMap =
219
- new HashMap <String , List <Mutation >>();
220
- blobNamesMutationMap .put ("BlobNames" , blobNamesMutations );
220
+ ImmutableMap .of ("BlobNames" , blobNamesMutations );
221
221
222
222
mutationMap .put (blobPath , blobNamesMutationMap );
223
223
@@ -243,10 +243,9 @@ private boolean deleteBlobs(String blobPath, String... blobNames)
243
243
private Mutation createDelete (String name , long timestamp ) {
244
244
Deletion deletion = new Deletion (timestamp );
245
245
if (name != null ) {
246
- List <ByteBuffer > columnNames = new ArrayList <ByteBuffer >(1 );
247
- columnNames .add (utf8 .encode (name ));
248
246
deletion .setPredicate (
249
- new SlicePredicate ().setColumn_names (columnNames ));
247
+ new SlicePredicate ().setColumn_names (
248
+ ImmutableList .of (utf8 .encode (name ))));
250
249
}
251
250
return new Mutation ().setDeletion (deletion );
252
251
}
@@ -369,7 +368,7 @@ private void writeBlob(Cassandra.Client client, String blobPath, String blobName
369
368
long timestamp = System .currentTimeMillis ();
370
369
371
370
Map <String , Map <String , List <Mutation >>> mutationMap =
372
- new HashMap < String , Map < String , List < Mutation >>> ();
371
+ Maps . newHashMap ();
373
372
374
373
// Insert the blob data into Blobs.
375
374
@@ -382,25 +381,22 @@ private void writeBlob(Cassandra.Client client, String blobPath, String blobName
382
381
ByteBuffer blobData = ByteBuffer .allocate (intSizeInBytes );
383
382
new DataInputStream (is ).readFully (blobData .array ());
384
383
385
- List <Mutation > blobsMutations = new ArrayList <Mutation >();
386
- blobsMutations .add (createInsert ("data" , blobData , timestamp ));
387
-
388
- Map <String , List <Mutation >> blobsMutationMap =
389
- new HashMap <String , List <Mutation >>();
390
- blobsMutationMap .put ("Blobs" , blobsMutations );
384
+ Map <String , List <Mutation >> blobsMutationMap = Maps .newHashMap ();
385
+ blobsMutationMap .put (
386
+ "Blobs" ,
387
+ ImmutableList .of (createInsert ("data" , blobData , timestamp )));
391
388
392
389
mutationMap .put (blobKey , blobsMutationMap );
393
390
394
391
// Insert the blobName into BlobNames.
395
392
396
393
ByteBuffer size = utf8 .encode (Long .toString (sizeInBytes ));
397
394
398
- List <Mutation > blobNamesMutations = new ArrayList <Mutation >();
399
- blobNamesMutations .add (createInsert (blobName , size , timestamp ));
400
-
401
395
Map <String , List <Mutation >> blobNamesMutationMap =
402
- new HashMap <String , List <Mutation >>();
403
- blobNamesMutationMap .put ("BlobNames" , blobNamesMutations );
396
+ Maps .newHashMap ();
397
+ blobNamesMutationMap .put (
398
+ "BlobNames" ,
399
+ ImmutableList .of (createInsert (blobName , size , timestamp )));
404
400
405
401
mutationMap .put (blobPath , blobNamesMutationMap );
406
402
0 commit comments