@Test public void estimatedSizeOfWithoutLiteral() throws Exception { Statement statement = VALUE_FACTORY.createStatement( VALUE_FACTORY.createBNode("http: VALUE_FACTORY.createURI("http: VALUE_FACTORY.createURI("http: VALUE_FACTORY.createURI("http: long size = StatementSizeEstimator.estimatedSizeOf(statement); long stringsSize = 4 * StringSizeEstimator.estimatedSizeOf("http: long minOverhead = 5 * 8 + 9 * 4 + 4 * 8; long maxOverhead = 5 * 16 + 9 * 8 + 4 * 8; assertTrue(size <= maxOverhead + stringsSize); assertTrue(size >= minOverhead + stringsSize); }
public static long estimatedSizeOf(Statement statement) { Value object = statement.getObject(); Resource context = statement.getContext(); long result = STATEMENT_OVERHEAD + 2 * URI_BNODE_OVERHEAD + OBJ_REF + StringSizeEstimator.estimatedSizeOf(statement.getSubject().stringValue()) + StringSizeEstimator.estimatedSizeOf(statement.getPredicate().stringValue()); if (object instanceof Literal) { Literal literal = (Literal) object; result += LITERAL_OVERHEAD + StringSizeEstimator.estimatedSizeOf(literal.stringValue()); if (literal.getLanguage() != null) { result += StringSizeEstimator.estimatedSizeOf(literal.getLanguage()); } if (literal.getDatatype() != null) { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(literal.getDatatype().stringValue()); } } else { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(object.stringValue()); } if (context != null) { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(context.stringValue()); } return result; }
StatementSizeEstimator { public static long estimatedSizeOf(Statement statement) { Value object = statement.getObject(); Resource context = statement.getContext(); long result = STATEMENT_OVERHEAD + 2 * URI_BNODE_OVERHEAD + OBJ_REF + StringSizeEstimator.estimatedSizeOf(statement.getSubject().stringValue()) + StringSizeEstimator.estimatedSizeOf(statement.getPredicate().stringValue()); if (object instanceof Literal) { Literal literal = (Literal) object; result += LITERAL_OVERHEAD + StringSizeEstimator.estimatedSizeOf(literal.stringValue()); if (literal.getLanguage() != null) { result += StringSizeEstimator.estimatedSizeOf(literal.getLanguage()); } if (literal.getDatatype() != null) { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(literal.getDatatype().stringValue()); } } else { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(object.stringValue()); } if (context != null) { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(context.stringValue()); } return result; } }
StatementSizeEstimator { public static long estimatedSizeOf(Statement statement) { Value object = statement.getObject(); Resource context = statement.getContext(); long result = STATEMENT_OVERHEAD + 2 * URI_BNODE_OVERHEAD + OBJ_REF + StringSizeEstimator.estimatedSizeOf(statement.getSubject().stringValue()) + StringSizeEstimator.estimatedSizeOf(statement.getPredicate().stringValue()); if (object instanceof Literal) { Literal literal = (Literal) object; result += LITERAL_OVERHEAD + StringSizeEstimator.estimatedSizeOf(literal.stringValue()); if (literal.getLanguage() != null) { result += StringSizeEstimator.estimatedSizeOf(literal.getLanguage()); } if (literal.getDatatype() != null) { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(literal.getDatatype().stringValue()); } } else { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(object.stringValue()); } if (context != null) { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(context.stringValue()); } return result; }  }
StatementSizeEstimator { public static long estimatedSizeOf(Statement statement) { Value object = statement.getObject(); Resource context = statement.getContext(); long result = STATEMENT_OVERHEAD + 2 * URI_BNODE_OVERHEAD + OBJ_REF + StringSizeEstimator.estimatedSizeOf(statement.getSubject().stringValue()) + StringSizeEstimator.estimatedSizeOf(statement.getPredicate().stringValue()); if (object instanceof Literal) { Literal literal = (Literal) object; result += LITERAL_OVERHEAD + StringSizeEstimator.estimatedSizeOf(literal.stringValue()); if (literal.getLanguage() != null) { result += StringSizeEstimator.estimatedSizeOf(literal.getLanguage()); } if (literal.getDatatype() != null) { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(literal.getDatatype().stringValue()); } } else { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(object.stringValue()); } if (context != null) { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(context.stringValue()); } return result; }  static long estimatedSizeOf(Statement statement); }
StatementSizeEstimator { public static long estimatedSizeOf(Statement statement) { Value object = statement.getObject(); Resource context = statement.getContext(); long result = STATEMENT_OVERHEAD + 2 * URI_BNODE_OVERHEAD + OBJ_REF + StringSizeEstimator.estimatedSizeOf(statement.getSubject().stringValue()) + StringSizeEstimator.estimatedSizeOf(statement.getPredicate().stringValue()); if (object instanceof Literal) { Literal literal = (Literal) object; result += LITERAL_OVERHEAD + StringSizeEstimator.estimatedSizeOf(literal.stringValue()); if (literal.getLanguage() != null) { result += StringSizeEstimator.estimatedSizeOf(literal.getLanguage()); } if (literal.getDatatype() != null) { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(literal.getDatatype().stringValue()); } } else { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(object.stringValue()); } if (context != null) { result += URI_BNODE_OVERHEAD + StringSizeEstimator.estimatedSizeOf(context.stringValue()); } return result; }  static long estimatedSizeOf(Statement statement);  }