public static void jsonStreamToRecords(Set<String> indexes, String dbPath, InputStream is, Consumer<JsonRecord> consumer) throws IOException { try (JsonParser jp = new JsonFactory().createParser(is)) { jsonStreamToRecords(indexes, jp, dbPath, consumer); JsonToken jsonToken = jp.nextToken(); if (jsonToken != null) { throw new JsonParseException(jp, "Document did not terminate as expected."); } } }
public static void jsonStreamToRecords(HashSet<String> indexes, String dbPath, InputStream is, Consumer<JsonRecord> consumer) throws IOException { try (JsonParser jp = new JsonFactory().createParser(is)) { jsonStreamToRecords(indexes, jp, dbPath, consumer); JsonToken jsonToken = jp.nextToken(); if (jsonToken != null) { throw new JsonParseException(jp, "Document did not terminate as expected."); } } }
currentPath = path + toArrayIndexPath(arrayIndex) + "/"; jsonStreamToRecords(indexes, jp, currentPath + validateKey(jp.getCurrentName()) + "/", consumer); } else if (nextToken == VALUE_NULL) { if (inArray) {
JsonRecordSupport.jsonStreamToRecords(indexes, jp, baseDBPath, mb.createSetConsumer()); } catch (IOException e) { throw new JsonDBException(e);
JsonRecordSupport.jsonStreamToRecords(indexPaths, jp, baseDBPath, mb.createSetConsumer()); } catch (IOException e) { throw new JsonDBException(e);
currentPath = path + toArrayIndexPath(arrayIndex) + "/"; jsonStreamToRecords(indexes, jp, currentPath + validateKey(jp.getCurrentName()) + "/", consumer); } else if (nextToken == VALUE_NULL) { if (inArray) {
@Override public void set(String path, InputStream body) { withTransaction(dbi -> { BatchManager mb = new BatchManager(dbi); String baseDBPath = JsonRecordSupport.convertToDBPath(path); mb.deleteRecordsForSet(baseDBPath); try { JsonRecordSupport.jsonStreamToRecords(indexPaths, baseDBPath, body, mb.createSetConsumer()); } catch (IOException e) { throw new JsonDBException(e); } mb.flush(); }); if( bus!=null ) { bus.broadcast("jsondb-updated", prefix(trimSuffix(path, "/"), "/")); } }
@Override public void set(String path, InputStream body) { withTransaction(dbi -> { BatchManager mb = new BatchManager(dbi); String baseDBPath = JsonRecordSupport.convertToDBPath(path); mb.deleteRecordsForSet(baseDBPath); try { JsonRecordSupport.jsonStreamToRecords(indexes, baseDBPath, body, mb.createSetConsumer()); } catch (IOException e) { throw new JsonDBException(e); } mb.flush(); }); if( bus!=null ) { bus.broadcast("jsondb-updated", prefix(trimSuffix(path, "/"), "/")); } }