public static JsonRecord of(String path, String value, int kind, String index) { return new JsonRecord(path, value, kind, index); }
@Override public JsonRecord map(int index, ResultSet r, StatementContext ctx) throws SQLException { return JsonRecord.of(r.getString("path"), r.getString("value"), r.getString("ovalue"), null); } }
public Consumer<JsonRecord> createSetConsumer() { return r -> { PreparedBatch insert = getInsertBatch(); insert.bind("path", r.getPath()) .bind("value", r.getValue()) .bind("ovalue", r.getOValue()) .bind("idx", r.getIndex()) .add(); batchSize += r.getPath().length() + r.getValue().length(); if (batchSize > 512 * 1024) { // Write the batch once we have enough data. insert.execute(); batchSize = 0; } }; }
public Consumer<JsonRecord> createSetConsumer() { return r -> { PreparedBatch insert = getInsertBatch(); insert.bind("path", r.getPath()) .bind("value", r.getValue()) .bind("kind", r.getKind()) .bind("idx", r.getIndex()) .add(); batchSize += r.getPath().length() + r.getValue().length(); if (batchSize > 512 * 1024) { // Write the batch once we have enough data. insert.execute(); batchSize = 0; } }; }
private void writeValue(JsonRecord value) throws IOException { switch (value.getKind()) { case JsonTokenId.ID_STRING: jg.writeString(value.getValue()); break; case JsonTokenId.ID_NULL: jg.writeNull(); break; case JsonTokenId.ID_NUMBER_FLOAT: case JsonTokenId.ID_NUMBER_INT: jg.writeNumber(value.getValue()); break; case JsonTokenId.ID_TRUE: jg.writeBoolean(true); break; case JsonTokenId.ID_FALSE: jg.writeBoolean(false); break; default: } }
private void writeValue(JsonRecord value) throws IOException { switch (value.getValue().charAt(0)) { case JsonRecordSupport.STRING_VALUE_PREFIX: jg.writeString(value.getValue().substring(1)); break; case JsonRecordSupport.NULL_VALUE_PREFIX: jg.writeNull(); break; case JsonRecordSupport.NEG_NUMBER_VALUE_PREFIX: case NUMBER_VALUE_PREFIX: jg.writeNumber(value.getOValue()); break; case JsonRecordSupport.TRUE_VALUE_PREFIX: jg.writeBoolean(true); break; case JsonRecordSupport.FALSE_VALUE_PREFIX: jg.writeBoolean(false); break; default: } }
public void accept(JsonRecord record) { try { String path = record.getPath(); path = Strings.trimSuffix(path.substring(base.length()), "/");
@Override public void accept(JsonRecord record) { try { String path = record.getPath(); path = Strings.trimSuffix(path.substring(base.length()), "/");
@Override public JsonRecord map(int index, ResultSet r, StatementContext ctx) throws SQLException { return JsonRecord.of(r.getString("path"), r.getString("value"), r.getInt("kind"), null); } }
public static JsonRecord of(String path, String value, String ovalue, String index) { return new JsonRecord(path, value, ovalue, index); }
currentPath = path + toArrayIndexPath(arrayIndex) + "/"; consumer.accept(JsonRecord.of(currentPath, String.valueOf(NULL_VALUE_PREFIX), "null", indexFieldValue(indexes, currentPath))); if( inArray ) { arrayIndex++; consumer.accept(JsonRecord.of(currentPath, value, ovalue, indexFieldValue(indexes, currentPath))); if( inArray ) { arrayIndex++;
currentPath = path + toArrayIndexPath(arrayIndex) + "/"; consumer.accept(JsonRecord.of(currentPath, "", nextToken.id(), indexFieldValue(indexes, currentPath))); if( inArray ) { arrayIndex++; currentPath = path + toArrayIndexPath(arrayIndex) + "/"; consumer.accept(JsonRecord.of(currentPath, jp.getValueAsString(), nextToken.id(), indexFieldValue(indexes, currentPath))); if( inArray ) { arrayIndex++;