@Override public String toString() { return "StreamingPropertyValue{" + "valueType=" + getValueType() + ", length=" + getLength() + '}'; } }
@Override public String toString() { return "StreamingPropertyValue{" + "valueType=" + getValueType() + ", length=" + getLength() + '}'; } }
private static String readStreamingPropertyValueForHistory( StreamingPropertyValue spv, Locale locale, ResourceBundle resourceBundle ) { if (spv.getValueType() == String.class) { return readStreamingPropertyValueStringForHistory(spv); } else { return String.format(locale, resourceBundle.getString("history.nondisplayable"), spv.getLength()); } }
totalLength = mediaPropertyValue.getLength(); in = mediaPropertyValue.getInputStream();
@Test public void testStreamingPropertyValue() { StreamingPropertyValue spv = new DefaultStreamingPropertyValue(new ByteArrayInputStream("test".getBytes()), byte[].class, 4L) .searchIndex(true); testValue( spv, getStreamingPropertyValueBytes(), (givenValue, deserializedValue) -> { assertNotNull(deserializedValue); assertTrue(deserializedValue.isSearchIndex()); assertEquals(byte[].class, deserializedValue.getValueType()); assertEquals(4L, (long) deserializedValue.getLength()); } ); }
@Test public void testStreamingPropertyValue() { StreamingPropertyValue spv = new DefaultStreamingPropertyValue(new ByteArrayInputStream("test".getBytes()), byte[].class, 4L) .searchIndex(true); testValue( spv, getStreamingPropertyValueBytes(), (givenValue, deserializedValue) -> { assertNotNull(deserializedValue); assertTrue(deserializedValue.isSearchIndex()); assertEquals(byte[].class, deserializedValue.getValueType()); assertEquals(4L, (long) deserializedValue.getLength()); } ); }
StreamingPropertyValue value = (StreamingPropertyValue) propSmallValue; assertEquals(String.class, value.getValueType()); assertEquals("value1".getBytes().length, (long) value.getLength()); assertEquals("value1", IOUtils.toString(value.getInputStream())); assertEquals("value1", IOUtils.toString(value.getInputStream())); value = (StreamingPropertyValue) propLargeValue; assertEquals(String.class, value.getValueType()); assertEquals(expectedLargeValue.getBytes().length, (long) value.getLength()); assertEquals(expectedLargeValue, IOUtils.toString(value.getInputStream())); assertEquals(expectedLargeValue, IOUtils.toString(value.getInputStream())); value = (StreamingPropertyValue) propSmallValue; assertEquals(String.class, value.getValueType()); assertEquals("value1".getBytes().length, (long) value.getLength()); assertEquals("value1", IOUtils.toString(value.getInputStream())); assertEquals("value1", IOUtils.toString(value.getInputStream())); value = (StreamingPropertyValue) propLargeValue; assertEquals(String.class, value.getValueType()); assertEquals(expectedLargeValue.getBytes().length, (long) value.getLength()); assertEquals(expectedLargeValue, IOUtils.toString(value.getInputStream())); assertEquals(expectedLargeValue, IOUtils.toString(value.getInputStream()));
StreamingPropertyValue value = (StreamingPropertyValue) propSmallValue; assertEquals(String.class, value.getValueType()); assertEquals("value1".getBytes().length, (long) value.getLength()); assertEquals("value1", IOUtils.toString(value.getInputStream())); assertEquals("value1", IOUtils.toString(value.getInputStream())); value = (StreamingPropertyValue) propLargeValue; assertEquals(String.class, value.getValueType()); assertEquals(expectedLargeValue.getBytes().length, (long) value.getLength()); assertEquals(expectedLargeValue, IOUtils.toString(value.getInputStream())); assertEquals(expectedLargeValue, IOUtils.toString(value.getInputStream())); value = (StreamingPropertyValue) propSmallValue; assertEquals(String.class, value.getValueType()); assertEquals("value1".getBytes().length, (long) value.getLength()); assertEquals("value1", IOUtils.toString(value.getInputStream())); assertEquals("value1", IOUtils.toString(value.getInputStream())); value = (StreamingPropertyValue) propLargeValue; assertEquals(String.class, value.getValueType()); assertEquals(expectedLargeValue.getBytes().length, (long) value.getLength()); assertEquals(expectedLargeValue, IOUtils.toString(value.getInputStream())); assertEquals(expectedLargeValue, IOUtils.toString(value.getInputStream()));
StreamingPropertyValue value ) { StreamAndLength streamAndLength = streamAndLength(value.getInputStream(), value.getLength()); String id = makeId(elementId, key, name, visibility, timestamp); try (Handle handle = dbi.open()) {
@Test public void testGetStreamingPropertyValueInputStreams() throws Exception { graph.defineProperty("a").dataType(String.class).textIndexHint(TextIndexHint.FULL_TEXT).define(); graph.defineProperty("b").dataType(String.class).textIndexHint(TextIndexHint.FULL_TEXT).define(); graph.defineProperty("c").dataType(String.class).textIndexHint(TextIndexHint.FULL_TEXT).define(); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("a", StreamingPropertyValue.create("Test Value A"), VISIBILITY_A) .setProperty("b", StreamingPropertyValue.create("Test Value B"), VISIBILITY_A) .setProperty("c", StreamingPropertyValue.create("Test Value C"), VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B); StreamingPropertyValue spvA = (StreamingPropertyValue) v1.getPropertyValue("a"); assertEquals(12L, (long) spvA.getLength()); StreamingPropertyValue spvB = (StreamingPropertyValue) v1.getPropertyValue("b"); assertEquals(12L, (long) spvA.getLength()); StreamingPropertyValue spvC = (StreamingPropertyValue) v1.getPropertyValue("c"); assertEquals(12L, (long) spvA.getLength()); ArrayList<StreamingPropertyValue> spvs = Lists.newArrayList(spvA, spvB, spvC); List<InputStream> streams = graph.getStreamingPropertyValueInputStreams(spvs); assertEquals("Test Value A", IOUtils.toString(streams.get(0))); assertEquals("Test Value B", IOUtils.toString(streams.get(1))); assertEquals("Test Value C", IOUtils.toString(streams.get(2))); }
@Test public void testGetStreamingPropertyValueInputStreams() throws Exception { graph.defineProperty("a").dataType(String.class).textIndexHint(TextIndexHint.FULL_TEXT).define(); graph.defineProperty("b").dataType(String.class).textIndexHint(TextIndexHint.FULL_TEXT).define(); graph.defineProperty("c").dataType(String.class).textIndexHint(TextIndexHint.FULL_TEXT).define(); graph.prepareVertex("v1", VISIBILITY_A) .setProperty("a", StreamingPropertyValue.create("Test Value A"), VISIBILITY_A) .setProperty("b", StreamingPropertyValue.create("Test Value B"), VISIBILITY_A) .setProperty("c", StreamingPropertyValue.create("Test Value C"), VISIBILITY_A) .save(AUTHORIZATIONS_A_AND_B); graph.flush(); Vertex v1 = graph.getVertex("v1", AUTHORIZATIONS_A_AND_B); StreamingPropertyValue spvA = (StreamingPropertyValue) v1.getPropertyValue("a"); assertEquals(12L, (long) spvA.getLength()); StreamingPropertyValue spvB = (StreamingPropertyValue) v1.getPropertyValue("b"); assertEquals(12L, (long) spvA.getLength()); StreamingPropertyValue spvC = (StreamingPropertyValue) v1.getPropertyValue("c"); assertEquals(12L, (long) spvA.getLength()); ArrayList<StreamingPropertyValue> spvs = Lists.newArrayList(spvA, spvB, spvC); List<InputStream> streams = graph.getStreamingPropertyValueInputStreams(spvs); assertEquals("Test Value A", IOUtils.toString(streams.get(0))); assertEquals("Test Value B", IOUtils.toString(streams.get(1))); assertEquals("Test Value C", IOUtils.toString(streams.get(2))); }
StreamingPropertyValue streamingPropertyValue = (StreamingPropertyValue) property.getValue(); in = streamingPropertyValue.getInputStream(); totalLength = streamingPropertyValue.getLength(); } else { byte[] value = property.getValue().toString().getBytes();