private boolean canEvaulate(Object first) { if (first instanceof String) { return true; } if (first instanceof GeoPoint) { return true; } if (first instanceof StreamingPropertyValue && ((StreamingPropertyValue) first).getValueType() == String.class) { return true; } return false; } }
public StreamingPropertyValueTableDataRef(String dataRowKey, StreamingPropertyValue propertyValue, long length) { super(propertyValue); this.dataRowKey = dataRowKey; this.valueType = propertyValue.getValueType(); this.length = length; }
public StreamingPropertyValueTableDataRef(String dataRowKey, StreamingPropertyValue propertyValue, long length) { super(propertyValue); this.dataRowKey = dataRowKey; this.valueType = propertyValue.getValueType(); this.length = length; }
private boolean canEvaulate(Object first) { if (first instanceof String) { return true; } if (first instanceof GeoPoint) { return true; } if (first instanceof StreamingPropertyValue && ((StreamingPropertyValue) first).getValueType() == String.class) { return true; } return false; } }
protected Class<?> getValueType(Object value) { Class<?> valueClass = value.getClass(); if (value instanceof StreamingPropertyValue) { valueClass = ((StreamingPropertyValue) value).getValueType(); } else if (value instanceof StreamingPropertyValueRef) { valueClass = ((StreamingPropertyValueRef) value).getValueType(); } return valueClass; }
protected StreamingPropertyValueRef(StreamingPropertyValue propertyValue) { this.valueType = propertyValue.getValueType().getName(); this.searchIndex = propertyValue.isSearchIndex(); }
@Override public String toString() { return "StreamingPropertyValue{" + "valueType=" + getValueType() + ", length=" + getLength() + '}'; } }
protected StreamingPropertyValueRef(StreamingPropertyValue propertyValue) { this.valueType = propertyValue.getValueType().getName(); this.searchIndex = propertyValue.isSearchIndex(); }
@Override public String toString() { return "StreamingPropertyValue{" + "valueType=" + getValueType() + ", length=" + getLength() + '}'; } }
protected Class<?> getValueType(Object value) { Class<?> valueClass = value.getClass(); if (value instanceof StreamingPropertyValue) { valueClass = ((StreamingPropertyValue) value).getValueType(); } else if (value instanceof StreamingPropertyValueRef) { valueClass = ((StreamingPropertyValueRef) value).getValueType(); } return valueClass; }
private static Object convertStreamingPropertyValue(Object value) { StreamingPropertyValue spv = (StreamingPropertyValue) value; try { if (spv.getValueType() == String.class) { try (InputStream in = spv.getInputStream()) { value = IOUtils.toString(in, Charset.defaultCharset()); } } else if (spv.getValueType() == byte[].class) { try (InputStream in = spv.getInputStream()) { byte[] buffer = new byte[100000]; int read; read = in.read(buffer, 0, buffer.length); value = Arrays.copyOfRange(buffer, 0, read); } } else { return "Could not convert StreamingPropertyValue of type " + spv.getValueType().getName(); } } catch (IOException e) { throw new SecurityException("Could not get StreamingPropertyValue input stream", e); } return value; }
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()); } }
private boolean isStreamingPropertyValueIndexable(Graph graph, String propertyName, StreamingPropertyValue streamingPropertyValue) { if (!streamingPropertyValue.isSearchIndex()) { return false; } PropertyDefinition propertyDefinition = getPropertyDefinition(graph, propertyName); if (propertyDefinition != null && !propertyDefinition.getTextIndexHints().contains(TextIndexHint.FULL_TEXT)) { return false; } Class valueType = streamingPropertyValue.getValueType(); if (valueType == String.class) { return true; } else { throw new VertexiumException("Unhandled StreamingPropertyValue type: " + valueType.getName()); } }
private boolean isStreamingPropertyValueIndexable(Graph graph, String propertyName, StreamingPropertyValue streamingPropertyValue) { if (!streamingPropertyValue.isSearchIndex()) { return false; } PropertyDefinition propertyDefinition = getPropertyDefinition(graph, propertyName); if (propertyDefinition != null && !propertyDefinition.getTextIndexHints().contains(TextIndexHint.FULL_TEXT)) { return false; } Class valueType = streamingPropertyValue.getValueType(); if (valueType == String.class) { return true; } else { throw new VertexiumException("Unhandled StreamingPropertyValue type: " + valueType.getName()); } }
private boolean isStreamingPropertyValueIndexable(Graph graph, String propertyName, StreamingPropertyValue streamingPropertyValue) { if (!streamingPropertyValue.isSearchIndex()) { return false; } PropertyDefinition propertyDefinition = getPropertyDefinition(graph, propertyName); if (propertyDefinition != null && !propertyDefinition.getTextIndexHints().contains(TextIndexHint.FULL_TEXT)) { return false; } Class valueType = streamingPropertyValue.getValueType(); if (valueType == String.class) { return true; } else { throw new VertexiumException("Unhandled StreamingPropertyValue type: " + valueType.getName()); } }
private boolean isStreamingPropertyValueIndexable(Graph graph, String propertyName, StreamingPropertyValue streamingPropertyValue) { if (!streamingPropertyValue.isSearchIndex()) { return false; } PropertyDefinition propertyDefinition = getPropertyDefinition(graph, propertyName); if (propertyDefinition != null && !propertyDefinition.getTextIndexHints().contains(TextIndexHint.FULL_TEXT)) { return false; } Class valueType = streamingPropertyValue.getValueType(); if (valueType == String.class) { return true; } else { throw new VertexiumException("Unhandled StreamingPropertyValue type: " + valueType.getName()); } }
@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()); } ); }
private void addPropertyToIndexInner(Graph graph, IndexInfo indexInfo, String deflatedPropertyName, Object propertyValue, Visibility propertyVisibility) throws IOException { if (indexInfo.isPropertyDefined(deflatedPropertyName, propertyVisibility)) { return; } Class dataType; if (propertyValue instanceof StreamingPropertyValue) { StreamingPropertyValue streamingPropertyValue = (StreamingPropertyValue) propertyValue; if (!streamingPropertyValue.isSearchIndex()) { return; } dataType = streamingPropertyValue.getValueType(); addPropertyToIndex(graph, indexInfo, deflatedPropertyName, propertyVisibility, dataType, true); } else if (propertyValue instanceof String) { dataType = String.class; addPropertyToIndex(graph, indexInfo, deflatedPropertyName + EXACT_MATCH_PROPERTY_NAME_SUFFIX, propertyVisibility, dataType, false); addPropertyToIndex(graph, indexInfo, deflatedPropertyName, propertyVisibility, dataType, true); } else if (propertyValue instanceof GeoPoint) { addPropertyToIndex(graph, indexInfo, deflatedPropertyName + GEO_PROPERTY_NAME_SUFFIX, propertyVisibility, GeoPoint.class, true); addPropertyToIndex(graph, indexInfo, deflatedPropertyName, propertyVisibility, String.class, true); } else if (propertyValue instanceof GeoCircle) { addPropertyToIndex(graph, indexInfo, deflatedPropertyName + GEO_PROPERTY_NAME_SUFFIX, propertyVisibility, GeoCircle.class, true); addPropertyToIndex(graph, indexInfo, deflatedPropertyName, propertyVisibility, String.class, true); } else { checkNotNull(propertyValue, "property value cannot be null for property: " + deflatedPropertyName); dataType = propertyValue.getClass(); addPropertyToIndex(graph, indexInfo, deflatedPropertyName, propertyVisibility, dataType, true); } }
private void addPropertyToIndexInner(Graph graph, IndexInfo indexInfo, String deflatedPropertyName, Object propertyValue, Visibility propertyVisibility) throws IOException { if (indexInfo.isPropertyDefined(deflatedPropertyName, propertyVisibility)) { return; } Class dataType; if (propertyValue instanceof StreamingPropertyValue) { StreamingPropertyValue streamingPropertyValue = (StreamingPropertyValue) propertyValue; if (!streamingPropertyValue.isSearchIndex()) { return; } dataType = streamingPropertyValue.getValueType(); addPropertyToIndex(graph, indexInfo, deflatedPropertyName, propertyVisibility, dataType, true); } else if (propertyValue instanceof String) { dataType = String.class; addPropertyToIndex(graph, indexInfo, deflatedPropertyName + EXACT_MATCH_PROPERTY_NAME_SUFFIX, propertyVisibility, dataType, false); addPropertyToIndex(graph, indexInfo, deflatedPropertyName, propertyVisibility, dataType, true); } else if (propertyValue instanceof GeoPoint) { addPropertyToIndex(graph, indexInfo, deflatedPropertyName + GEO_PROPERTY_NAME_SUFFIX, propertyVisibility, GeoPoint.class, true); addPropertyToIndex(graph, indexInfo, deflatedPropertyName, propertyVisibility, String.class, true); } else if (propertyValue instanceof GeoCircle) { addPropertyToIndex(graph, indexInfo, deflatedPropertyName + GEO_PROPERTY_NAME_SUFFIX, propertyVisibility, GeoCircle.class, true); addPropertyToIndex(graph, indexInfo, deflatedPropertyName, propertyVisibility, String.class, true); } else { checkNotNull(propertyValue, "property value cannot be null for property: " + deflatedPropertyName); dataType = propertyValue.getClass(); addPropertyToIndex(graph, indexInfo, deflatedPropertyName, propertyVisibility, dataType, true); } }