RDBRow row = new RDBRow(id, "1".equals(shasbinary) ? 1L : 0L, "1".equals(sdeletedonce), smodified.length() == 0 ? 0 : Long.parseLong(smodified), Long.parseLong(smodcount), Long.parseLong(scmodcount), -1L, -1L, -1L, sdata, bytes);
final String charData = row.getData(); checkNotNull(charData, "RDBRow.getData() is null for collection " + collection + ", id: " + row.getId()); doc.put(ID, row.getId()); if (row.getModified() != RDBRow.LONG_UNSET) { doc.put(MODIFIED, row.getModified()); if (row.getModcount() != RDBRow.LONG_UNSET) { doc.put(MODCOUNT, row.getModcount()); if (RDBDocumentStore.USECMODCOUNT && row.getCollisionsModcount() != RDBRow.LONG_UNSET) { doc.put(CMODCOUNT, row.getCollisionsModcount()); if (row.hasBinaryProperties() != null) { doc.put(HASBINARY, row.hasBinaryProperties().longValue()); if (row.deletedOnce() != null) { doc.put(DELETEDONCE, row.deletedOnce().booleanValue()); if (row.getSchemaVersion() >= 2) { if (row.getSdType() != RDBRow.LONG_UNSET) { doc.put(SDTYPE, row.getSdType()); if (row.getSdMaxRevTime() != RDBRow.LONG_UNSET) { doc.put(SDMAXREVTIME, row.getSdMaxRevTime()); byte[] bdata = row.getBdata(); boolean blobInUse = false; JsopTokenizer json;
String data = rs.getString(field++); byte[] bdata = rs.getBytes(field++); result.add(new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, schemaVersion, sdType, sdMaxRevTime, data, bdata)); dataTotal += data.length(); resultRange = String.format(" Result range: '%s'...'%s'.", result.get(0).getId(), result.get(result.size() - 1).getId());
T doc = getIfCached(collection, row.getId(), row.getModcount()); if (doc == null) { if (lastmodified == row.getModified() && lastmodified >= 1) { try (CacheLock lock = acquireLockFor(row.getId())) { if (!tracker.mightBeenAffected(row.getId())) {
return null; } else { if (lastmodcount == row.getModcount() && lastmodified == row.getModified() && lastmodified >= 1) {
@Test public void conditionalRead() throws SQLException { String id = this.getClass().getName() + ".conditionalRead"; super.ds.remove(Collection.NODES, id); UpdateOp op = new UpdateOp(id, true); op.set("_modified", 1L); removeMe.add(id); assertTrue(super.ds.create(Collection.NODES, Collections.singletonList(op))); NodeDocument nd = super.ds.find(Collection.NODES, id, 0); assertNotNull(nd); Long lastmodcount = nd.getModCount(); Long lastmodified = nd.getModified(); assertNotNull(lastmodcount); assertNotNull(lastmodified); RDBTableMetaData tmd = ((RDBDocumentStore) super.ds).getTable(Collection.NODES); Connection con = super.rdbDataSource.getConnection(); con.setReadOnly(true); try { RDBRow rMcNotMatch = jdbc.read(con, tmd, id, lastmodcount + 1, lastmodified); assertNotNull(rMcNotMatch.getData()); RDBRow rMcNotGiven = jdbc.read(con, tmd, id, -1, lastmodified); assertNotNull(rMcNotGiven.getData()); RDBRow rMcMatch = jdbc.read(con, tmd, id, lastmodcount, lastmodified); assertNull(rMcMatch.getData()); RDBRow rMcMatchModNonmatch = jdbc.read(con, tmd, id, lastmodcount, lastmodified + 2); assertNotNull(rMcMatchModNonmatch.getData()); } finally { con.close(); } }
T doc = getIfCached(collection, row.getId(), row.getModcount()); if (doc == null) { if (lastmodified == row.getModified() && lastmodified >= 1) { try (CacheLock lock = acquireLockFor(row.getId())) { if (!tracker.mightBeenAffected(row.getId())) {
String data = rs.getString(field++); byte[] bdata = rs.getBytes(field++); result.add(new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, schemaVersion, sdType, sdMaxRevTime, data, bdata)); dataTotal += data.length(); resultRange = String.format(" Result range: '%s'...'%s'.", result.get(0).getId(), result.get(result.size() - 1).getId());
return null; } else { if (lastmodcount == row.getModcount() && lastmodified == row.getModified() && lastmodified >= 1) {
final String charData = row.getData(); checkNotNull(charData, "RDBRow.getData() is null for collection " + collection + ", id: " + row.getId()); doc.put(ID, row.getId()); if (row.getModified() != RDBRow.LONG_UNSET) { doc.put(MODIFIED, row.getModified()); if (row.getModcount() != RDBRow.LONG_UNSET) { doc.put(MODCOUNT, row.getModcount()); if (RDBDocumentStore.USECMODCOUNT && row.getCollisionsModcount() != RDBRow.LONG_UNSET) { doc.put(CMODCOUNT, row.getCollisionsModcount()); if (row.hasBinaryProperties() != null) { doc.put(HASBINARY, row.hasBinaryProperties().longValue()); if (row.deletedOnce() != null) { doc.put(DELETEDONCE, row.deletedOnce().booleanValue()); if (row.getSchemaVersion() >= 2) { if (row.getSdType() != RDBRow.LONG_UNSET) { doc.put(SDTYPE, row.getSdType()); if (row.getSdMaxRevTime() != RDBRow.LONG_UNSET) { doc.put(SDMAXREVTIME, row.getSdMaxRevTime()); byte[] bdata = row.getBdata(); boolean blobInUse = false; JsopTokenizer json;
RDBRow row = new RDBRow(id, "1".equals(shasbinary) ? 1L : 0L, "1".equals(sdeletedonce), smodified.length() == 0 ? 0 : Long.parseLong(smodified), Long.parseLong(smodcount), Long.parseLong(scmodcount), -1L, -1L, -1L, sdata, bytes);
byte[] bdata = rs.getBytes("BDATA"); RDBRow row = new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, -1L, -1L, -1L, data, bdata); StringBuilder fulljson = dumpRow(ser, id, row); if (format == Format.CSV) {
byte[] bdata = rs.getBytes("BDATA"); RDBRow row = new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, -1L, -1L, -1L, data, bdata); StringBuilder fulljson = dumpRow(ser, id, row); if (format == Format.CSV) {
tmd.getName(), id, modcount, modified, (data == null ? 0 : data.length()), (bdata == null ? 0 : bdata.length)); return new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, schemaVersion, sdType, sdMaxRevTime, data, bdata); } else {
tmd.getName(), id, modcount, modified, (data == null ? 0 : data.length()), (bdata == null ? 0 : bdata.length)); return new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, schemaVersion, sdType, sdMaxRevTime, data, bdata); } else {
@Test public void testSimpleBoth() throws UnsupportedEncodingException { try { RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, 0L, 0L, 0L, "{}", "{}".getBytes("UTF-8")); this.ser.fromRow(Collection.NODES, row); fail("should fail"); } catch (DocumentStoreException expected) { } }
@Test public void testBlobAndDiffBorked() throws UnsupportedEncodingException { try { RDBRow row = new RDBRow("_foo", 1L, false, 1l, 2l, 3l, 0L, 0L, 0L, "[[\"\", \"\", \"\"]]", "{}".getBytes("UTF-8")); this.ser.fromRow(Collection.NODES, row); fail("should fail"); } catch (DocumentStoreException expected) { } }
tmd.getName(), id, lastmodcount, lastmodified, modcount, modified, (data == null ? 0 : data.length()), (bdata == null ? 0 : bdata.length)); return new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, schemaVersion, sdType, sdMaxRevTime, data, bdata); } else {
tmd.getName(), id, lastmodcount, lastmodified, modcount, modified, (data == null ? 0 : data.length()), (bdata == null ? 0 : bdata.length)); return new RDBRow(id, hasBinary, deletedOnce, modified, modcount, cmodcount, schemaVersion, sdType, sdMaxRevTime, data, bdata); } else {
@Test public void testSimpleBlobGzipped() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); GZIPOutputStream gos = new GZIPOutputStream(bos); gos.write("{}".getBytes("UTF-8")); gos.close(); RDBRow row = new RDBRow("_foo", 0L, false, 1l, 2l, 3l, 0L, 0L, 0L, "\"blob\"", bos.toByteArray()); NodeDocument doc = this.ser.fromRow(Collection.NODES, row); assertEquals("_foo", doc.getId()); assertEquals(false, doc.hasBinary()); assertEquals(2L, doc.getModCount().longValue()); }