MCPcopy Create free account
hub / github.com/M66B/FairEmail / partition

Method partition

app/src/main/java/eu/faircode/email/CloudSync.java:832–854  ·  view source on GitHub ↗
(JSONArray jarray)

Source from the content-addressed store, hash-verified

830 }
831
832 private static List<JSONArray> partition(JSONArray jarray) throws JSONException {
833 Log.i("Cloud batch size=" + jarray.length() + "/" + BATCH_SIZE);
834 if (jarray.length() <= BATCH_SIZE)
835 return Arrays.asList(jarray);
836
837 int count = 0;
838 List<JSONArray> jpartitions = new ArrayList<>();
839 for (int i = 0; i < jarray.length(); i += BATCH_SIZE) {
840 JSONArray jpartition = new JSONArray();
841 for (int j = 0; j < BATCH_SIZE && i + j < jarray.length(); j++) {
842 count++;
843 jpartition.put(jarray.get(i + j));
844 }
845 jpartitions.add(jpartition);
846 }
847
848 Log.i("Cloud partitions=" + jpartitions.size());
849
850 if (count != jarray.length())
851 throw new IllegalArgumentException("Partition error size=" + count + "/" + jarray.length());
852
853 return jpartitions;
854 }
855}

Callers 1

callMethod · 0.95

Calls 6

iMethod · 0.95
sizeMethod · 0.65
lengthMethod · 0.45
putMethod · 0.45
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected