public byte[] toJson(final boolean prettyPrint, final String... fieldsToExclude) throws SchemaException { try { return JSONSerialiser.serialise(this, prettyPrint, fieldsToExclude); } catch (final SerialisationException e) { throw new SchemaException(e.getMessage(), e); } }
public byte[] toJson(final boolean prettyPrint, final String... fieldsToExclude) throws SchemaException { try { return JSONSerialiser.serialise(this, prettyPrint, fieldsToExclude); } catch (final SerialisationException e) { throw new SchemaException(e.getMessage(), e); } }
@JsonIgnore protected CHILD_CLASS json(final byte[] jsonBytes, final Class<? extends ViewElementDefinition> clazz) throws SchemaException { if (null != jsonBytes) { try { merge(JSONSerialiser.deserialise(jsonBytes, clazz)); } catch (final SerialisationException e) { throw new SchemaException("Unable to deserialise json", e); } } return self(); }
public CHILD_CLASS json(final Class<? extends ELEMENT_DEFS> clazz, final Object[] jsonItems) throws SchemaException { if (null != jsonItems) { for (final Object jsonItem : jsonItems) { try { if (jsonItem instanceof InputStream) { merge(JSONSerialiser.deserialise((InputStream) jsonItem, clazz)); } else if (jsonItem instanceof Path) { final Path path = (Path) jsonItem; if (Files.isDirectory(path)) { for (final Path filePath : Files.newDirectoryStream(path)) { merge(JSONSerialiser.deserialise(Files.readAllBytes(filePath), clazz)); } } else { merge(JSONSerialiser.deserialise(Files.readAllBytes(path), clazz)); } } else { merge(JSONSerialiser.deserialise((byte[]) jsonItem, clazz)); } } catch (final IOException e) { throw new SchemaException("Failed to load element definitions from bytes", e); } } } return self(); }
final Class<?> clazz = getElementDef().transientProperties.get(newProp); if (!clazz.equals(newPropClass)) { throw new SchemaException("Unable to merge schemas. Conflict of transient property classes for " + newProp + ". Classes are: " + clazz.getName() + " and " + newPropClass.getName());
public IteratorSettingBuilder schema(final Schema schema) { try { setting.addOption(AccumuloStoreConstants.SCHEMA, new String(schema.toCompactJson(), CommonConstants.UTF_8)); } catch (final UnsupportedEncodingException e) { throw new SchemaException("Unable to deserialise schema from JSON", e); } return this; }
public Builder addSchema(final InputStream schemaStream) { if (null != schemaStream) { try { addSchema(IOUtils.toByteArray(schemaStream)); } catch (final IOException e) { throw new SchemaException("Unable to read schema from input stream", e); } finally { CloseableUtil.close(schemaStream); } } return this; }
public IteratorSettingBuilder view(final View view) { try { setting.addOption(AccumuloStoreConstants.VIEW, new String(view.toCompactJson(), CommonConstants.UTF_8)); } catch (final UnsupportedEncodingException e) { throw new SchemaException("Unable to deserialise view from JSON", e); } return this; }
public Builder addSchema(final Path schemaPath) { if (null != schemaPath) { try { if (Files.isDirectory(schemaPath)) { for (final Path path : Files.newDirectoryStream(schemaPath)) { addSchema(path); } } else { addSchema(Files.readAllBytes(schemaPath)); } } catch (final IOException e) { throw new SchemaException("Unable to read schema from path: " + schemaPath, e); } } return this; }
public Builder storeProperties(final URI propertiesURI) { if (null != propertiesURI) { try { storeProperties(StreamUtil.openStream(propertiesURI)); } catch (final IOException e) { throw new SchemaException("Unable to read storeProperties from URI: " + propertiesURI, e); } } return this; }
public Builder addSchemas(final URI... schemaURI) { if (null != schemaURI) { try { addSchemas(StreamUtil.openStreams(schemaURI)); } catch (final IOException e) { throw new SchemaException(UNABLE_TO_READ_SCHEMA_FROM_URI, e); } } return this; }
public Builder addSchema(final URI schemaURI) { if (null != schemaURI) { try { addSchema(StreamUtil.openStream(schemaURI)); } catch (final IOException e) { throw new SchemaException(UNABLE_TO_READ_SCHEMA_FROM_URI, e); } } return this; }
public byte[] toJson(final boolean prettyPrint, final String... fieldsToExclude) throws SchemaException { try { return JSONSerialiser.serialise(this, prettyPrint, fieldsToExclude); } catch (final SerialisationException e) { throw new SchemaException(e.getMessage(), e); } }
@Override protected void setup(final Context context) { super.setup(context); proportionToSample = context.getConfiguration().getFloat(AccumuloSampleDataForSplitPointsJobFactory.PROPORTION_TO_SAMPLE, 0.001f); final Schema schema; try { schema = Schema.fromJson(context.getConfiguration() .get(AccumuloSampleDataForSplitPointsJobFactory.SCHEMA).getBytes(CommonConstants.UTF_8)); } catch (final UnsupportedEncodingException e) { throw new SchemaException("Unable to deserialise Store Schema from JSON", e); } try { elementConverter = Class .forName(context.getConfiguration().get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS)) .asSubclass(AccumuloElementConverter.class) .getConstructor(Schema.class) .newInstance(schema); } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new IllegalArgumentException("Element converter could not be created: " + context.getConfiguration().get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS), e); } }
public Builder view(final URI view) { try { view(null != view ? StreamUtil.openStream(view) : null); } catch (final IOException e) { throw new SchemaException("Unable to read view from URI: " + view, e); } return this; }
public Builder addStoreProperties(final URI updatePropertiesURI) { if (null != updatePropertiesURI) { try { addStoreProperties(StreamUtil.openStream(updatePropertiesURI)); } catch (final IOException e) { throw new SchemaException("Unable to read storeProperties from URI: " + updatePropertiesURI, e); } } return this; }
public byte[] toJson(final boolean prettyPrint, final String... fieldsToExclude) throws SchemaException { try { return JSONSerialiser.serialise(this, prettyPrint, fieldsToExclude); } catch (final SerialisationException e) { throw new SchemaException(e.getMessage(), e); } }
@Override public void init(final SortedKeyValueIterator<Key, Value> source, final Map<String, String> options, final IteratorEnvironment env) throws IOException { super.init(source, options, env); try { schema = Schema.fromJson(options.get(AccumuloStoreConstants.SCHEMA).getBytes(CommonConstants.UTF_8)); } catch (final UnsupportedEncodingException e) { throw new SchemaException("Unable to deserialise the schema from json", e); } LOGGER.debug("Initialising AggregatorIterator with schema {}", schema); final String elementConverterClass = options.get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS); try { elementConverter = Class .forName(elementConverterClass) .asSubclass(AccumuloElementConverter.class) .getConstructor(Schema.class) .newInstance(schema); LOGGER.debug("Creating AccumuloElementConverter of class {}", elementConverterClass); } catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { throw new AggregationException("Failed to create element converter of the class name provided (" + elementConverterClass + ")", e); } }
@JsonIgnore protected CHILD_CLASS json(final byte[] jsonBytes, final Class<? extends ViewElementDefinition> clazz) throws SchemaException { if (null != jsonBytes) { try { merge(JSONSerialiser.deserialise(jsonBytes, clazz)); } catch (final SerialisationException e) { throw new SchemaException("Unable to deserialise json", e); } } return self(); }
schema = Schema.fromJson(options.get(AccumuloStoreConstants.SCHEMA).getBytes(CommonConstants.UTF_8)); } catch (final UnsupportedEncodingException e) { throw new SchemaException("Unable to deserialise the schema", e); view = View.fromJson(options.get(AccumuloStoreConstants.VIEW).getBytes(CommonConstants.UTF_8)); } catch (final UnsupportedEncodingException e) { throw new SchemaException("Unable to deserialise the view", e);