@Override public Object apply(final Element element) { return null != element ? element.getIdentifier(id) : null; }
@Override public Object get(final String reference) { if (ELEMENT.equals(reference)) { return element; } if (PROPERTIES.equals(reference)) { return element.getProperties(); } final IdentifierType idType = IdentifierType.fromName(reference); if (null == idType) { return element.getProperty(reference); } return element.getIdentifier(idType); }
/** * Attempts to find the value of a field from a given {@link Element}, * corresponding to a provided key, where the key is the name of the field. * * @param element the Element from which to retrieve a field value * @param key the name of the field to be retrieved * @return the value of the field */ private Object getFieldValue(final Element element, final String key) { final IdentifierType idType = IdentifierType.fromName(key); final Object value; if (null == idType) { if (GROUP.equals(key)) { value = element.getGroup(); } else { value = element.getProperty(key); } } else { value = element.getIdentifier(idType); } return value; }
/** * Attempts to find the value of a field from a given {@link Element}, * corresponding to a provided key, where the key is the name of the field. * * @param element the Element from which to retrieve a field value * @param key the name of the field to be retrieved * @return the value of the field */ private Object getFieldValue(final Element element, final String key) { final IdentifierType idType = IdentifierType.fromName(key); final Object value; if (null == idType) { if (GROUP.equals(key)) { value = element.getGroup(); } else { value = element.getProperty(key); } } else { value = element.getIdentifier(idType); } return value; }
@Test public void shouldReturnValueOfIdentifierType() { // Given final Element element = mock(Element.class); final IdentifierType type = IdentifierType.SOURCE; final String value = "testSource"; final ExtractId extractor = new ExtractId(type); given(element.getIdentifier(type)).willReturn(value); // When final Object result = extractor.apply(element); // Then assertEquals(value, result); }
@Override public Object apply(final Element element) { return null != element ? element.getIdentifier(id) : null; }
if (counter == sampleRate) { if (isEntity) { sample.add(element.getIdentifier(IdentifierType.VERTEX)); } else { sample.add(element.getIdentifier(IdentifierType.SOURCE));
@Override public Object get(final String reference) { if (ELEMENT.equals(reference)) { return element; } if (PROPERTIES.equals(reference)) { return element.getProperties(); } final IdentifierType idType = IdentifierType.fromName(reference); if (null == idType) { return element.getProperty(reference); } return element.getIdentifier(idType); }
private Map<Object, Integer> calculateSplitsForColumn(final JavaRDD<Element> data, final IdentifierType colName) { final List<Object> splits = data.sample(false, 1.0 / sampleRate) .map(element -> element.getIdentifier(colName)) .sortBy(obj -> obj, true, numOfSplits) .mapPartitions(objectIterator -> { final List<Object> list = new ArrayList<>(1); if (objectIterator.hasNext()) { list.add(objectIterator.next()); } return list.iterator(); }) .collect(); final Map<Object, Integer> splitPoints = new TreeMap<>(COMPARATOR); int i = 0; for (final Object split : splits) { if (null != split) { splitPoints.put(split, i); } i++; } return splitPoints; }
/** * Attempts to find the value of a field from a given {@link Element}, * corresponding to a provided key, where the key is the name of the field. * * @param element the Element from which to retrieve a field value * @param key the name of the field to be retrieved * @return the value of the field */ private Object getFieldValue(final Element element, final String key) { final IdentifierType idType = IdentifierType.fromName(key); final Object value; if (null == idType) { if (GROUP.equals(key)) { value = element.getGroup(); } else { value = element.getProperty(key); } } else { value = element.getIdentifier(idType); } return value; }
/** * Attempts to find the value of a field from a given {@link Element}, * corresponding to a provided key, where the key is the name of the field. * * @param element the Element from which to retrieve a field value * @param key the name of the field to be retrieved * @return the value of the field */ private Object getFieldValue(final Element element, final String key) { final IdentifierType idType = IdentifierType.fromName(key); final Object value; if (null == idType) { if (GROUP.equals(key)) { value = element.getGroup(); } else { value = element.getProperty(key); } } else { value = element.getIdentifier(idType); } return value; }