private static long getBinarySize(PropertyState property) { try { return property.size(); } catch (Exception e) { return -1; } }
@Override public long size() { return delegate.size(); }
private static long getBinarySize(PropertyState property) { try { return property.size(); } catch (Exception e) { return -1; } }
@Override public long size() { return ps.size(); }
@Override public long size() { return delegate.size(); }
@Override public long size(int index) { return delegate.size(index); }
@Override public long size(int index) { return ps.size(index); }
@Override public long size(int index) { return delegate.size(index); }
@Override public long size() { return ps.size(); }
@Override public long size(int index) { return ps.size(index); }
@Override public long size() { return parsed().size(); }
@Override public long size() { return parsed().size(); }
/** * Returns the binary size of a property value represented as a JSON or * {@code -1} if the property is not of type binary. * * @param json the property value. * @return the size of the referenced binary value(s); otherwise {@code -1}. */ private long getBinarySize(@Nullable String json) { if (json == null) { return -1; } PropertyState p = new DocumentPropertyState( DocumentNodeStore.this, "p", json); if (p.getType().tag() != PropertyType.BINARY) { return -1; } long size = 0; if (p.isArray()) { for (int i = 0; i < p.count(); i++) { size += p.size(i); } } else { size = p.size(); } return size; }
/** * Returns the binary size of a property value represented as a JSON or * {@code -1} if the property is not of type binary. * * @param json the property value. * @return the size of the referenced binary value(s); otherwise {@code -1}. */ private long getBinarySize(@Nullable String json) { if (json == null) { return -1; } PropertyState p = new DocumentPropertyState( DocumentNodeStore.this, "p", json); if (p.getType().tag() != PropertyType.BINARY) { return -1; } long size = 0; if (p.isArray()) { for (int i = 0; i < p.count(); i++) { size += p.size(i); } } else { size = p.size(); } return size; }
@Override public long size(int index) { long size; PropertyState parsed = parsed(); if (parsed.getType() == Type.BINARIES) { size = parsed.getValue(Type.BINARY, index).length(); } else { size = parsed.size(index); } return size; }
@Override public long size(int index) { long size; PropertyState parsed = parsed(); if (parsed.getType() == Type.BINARIES) { size = parsed.getValue(Type.BINARY, index).length(); } else { size = parsed.size(index); } return size; }
size += (56 + propState.size(i) * 2) * 2;
size += (56 + propState.size(i) * 2) * 2;
@Test public void testSize() throws Exception { FileDataStore fds = createFileDataStore(); DataStoreBlobStore dbs = new DataStoreBlobStore(fds); nodeStore = getNodeStore(dbs); int size = Segment.MEDIUM_LIMIT + 1; byte[] data2 = new byte[size]; new Random().nextBytes(data2); Blob b = nodeStore.createBlob(new ByteArrayInputStream(data2)); NodeBuilder builder = nodeStore.getRoot().builder(); builder.child("hello").setProperty("world", b); nodeStore.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY); PropertyState ps = nodeStore.getRoot().getChildNode("hello").getProperty("world"); // world = {2318851547697882338 bytes} assertEquals(size, ps.size()); // assertEquals("{" + size + " bytes}", ps.toString()); }
@Test public void multiValuedBinarySize() throws Exception { NodeBuilder builder = ns.getRoot().builder(); List<Blob> blobs = newArrayList(); for (int i = 0; i < 3; i++) { blobs.add(builder.createBlob(new RandomStream(BLOB_SIZE, i))); } builder.child("test").setProperty("p", blobs, Type.BINARIES); TestUtils.merge(ns, builder); PropertyState p = ns.getRoot().getChildNode("test").getProperty("p"); assertEquals(Type.BINARIES, p.getType()); assertEquals(3, p.count()); reads.clear(); assertEquals(BLOB_SIZE, p.size(0)); // must not read the blob via stream assertEquals(0, reads.size()); }