public static String layoutToTable(TABLE_LAYOUT layout, TableLayoutStrategy tableLayoutStrategy) { if (tableLayoutStrategy == null) { tableLayoutStrategy = new TablePrefixLayoutStrategy(); } switch (layout) { case SPO: { return tableLayoutStrategy.getSpo(); } case PO: { return tableLayoutStrategy.getPo(); } case OSP: { return tableLayoutStrategy.getOsp(); } } return null; }
public void setTableLayoutStrategy(final TableLayoutStrategy tableLayoutStrategy) { if (tableLayoutStrategy != null) { this.tableLayoutStrategy = tableLayoutStrategy; } else { this.tableLayoutStrategy = new TablePrefixLayoutStrategy(); //default } set(CONF_TBL_SPO, this.tableLayoutStrategy.getSpo()); set(CONF_TBL_PO, this.tableLayoutStrategy.getPo()); set(CONF_TBL_OSP, this.tableLayoutStrategy.getOsp()); set(CONF_TBL_NS, this.tableLayoutStrategy.getNs()); set(CONF_TBL_EVAL, this.tableLayoutStrategy.getEval()); }
public static String layoutPrefixToTable(TABLE_LAYOUT layout, String prefix) { return layoutToTable(layout, new TablePrefixLayoutStrategy(prefix)); }
@Override public String getNamespace(final String pfx) throws RyaDAOException { try { final Scanner scanner = connector.createScanner(tableLayoutStrategy.getNs(), ALL_AUTHORIZATIONS); scanner.fetchColumn(INFO_NAMESPACE_TXT, EMPTY_TEXT); scanner.setRange(new Range(new Text(pfx))); final Iterator<Map.Entry<Key, Value>> iterator = scanner .iterator(); if (iterator.hasNext()) { return new String(iterator.next().getValue().get(), StandardCharsets.UTF_8); } } catch (final Exception e) { throw new RyaDAOException(e); } return null; }
@Override public void init() throws RdfDAOException { try { if (isInitialized()) { throw new IllegalStateException("Already initialized"); } if (!resd.isInitialized()) { resd.init(); } checkNotNull(connector); tableLayoutStrategy = conf.getTableLayoutStrategy(); TableOperations tos = connector.tableOperations(); AccumuloRdfUtils.createTableIfNotExist(tos, tableLayoutStrategy.getSelectivity()); AccumuloRdfUtils.createTableIfNotExist(tos, tableLayoutStrategy.getProspects()); initialized = true; } catch (Exception e) { throw new RdfDAOException(e); } }
@Override public void init() throws RdfDAOException { try { if (isInitialized()) { throw new IllegalStateException("Already initialized"); } checkNotNull(connector); tableLayoutStrategy = conf.getTableLayoutStrategy(); // evalTable = conf.get(RdfCloudTripleStoreConfiguration.CONF_TBL_EVAL, evalTable); // conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_EVAL, evalTable); final TableOperations tos = connector.tableOperations(); AccumuloRdfUtils.createTableIfNotExist(tos, tableLayoutStrategy.getEval()); // boolean tableExists = tos.exists(evalTable); // if (!tableExists) // tos.create(evalTable); isInitialized.set(true); } catch (final Exception e) { throw new RdfDAOException(e); } }
public void setTableLayoutStrategy(final TableLayoutStrategy tableLayoutStrategy) { if (tableLayoutStrategy != null) { this.tableLayoutStrategy = tableLayoutStrategy; } else { this.tableLayoutStrategy = new TablePrefixLayoutStrategy(); //default } set(CONF_TBL_SPO, this.tableLayoutStrategy.getSpo()); set(CONF_TBL_PO, this.tableLayoutStrategy.getPo()); set(CONF_TBL_OSP, this.tableLayoutStrategy.getOsp()); set(CONF_TBL_NS, this.tableLayoutStrategy.getNs()); set(CONF_TBL_EVAL, this.tableLayoutStrategy.getEval()); }
public static String layoutToTable(TABLE_LAYOUT layout, TableLayoutStrategy tableLayoutStrategy) { if (tableLayoutStrategy == null) { tableLayoutStrategy = new TablePrefixLayoutStrategy(); } switch (layout) { case SPO: { return tableLayoutStrategy.getSpo(); } case PO: { return tableLayoutStrategy.getPo(); } case OSP: { return tableLayoutStrategy.getOsp(); } } return null; }
public static String layoutPrefixToTable(TABLE_LAYOUT layout, String prefix) { return layoutToTable(layout, new TablePrefixLayoutStrategy(prefix)); }
@Override public String getNamespace(final String pfx) throws RyaDAOException { try { final Scanner scanner = connector.createScanner(tableLayoutStrategy.getNs(), ALL_AUTHORIZATIONS); scanner.fetchColumn(INFO_NAMESPACE_TXT, EMPTY_TEXT); scanner.setRange(new Range(new Text(pfx))); final Iterator<Map.Entry<Key, Value>> iterator = scanner .iterator(); if (iterator.hasNext()) { return new String(iterator.next().getValue().get(), StandardCharsets.UTF_8); } } catch (final Exception e) { throw new RyaDAOException(e); } return null; }
protected String[] getTables() { // core tables final List<String> tableNames = Lists.newArrayList( tableLayoutStrategy.getSpo(), tableLayoutStrategy.getPo(), tableLayoutStrategy.getOsp(), tableLayoutStrategy.getNs(), tableLayoutStrategy.getEval()); // Additional Tables for (final AccumuloIndexer index : secondaryIndexers) { tableNames.add(index.getTableName()); } return tableNames.toArray(new String[]{}); }
private static final String[] EMPTY_STR_ARR = new String[0]; private TableLayoutStrategy tableLayoutStrategy = new TablePrefixLayoutStrategy();
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public CloseableIteration<Namespace, RyaDAOException> iterateNamespace() throws RyaDAOException { try { final Scanner scanner = connector.createScanner(tableLayoutStrategy.getNs(), ALL_AUTHORIZATIONS); scanner.fetchColumnFamily(INFO_NAMESPACE_TXT); final Iterator<Map.Entry<Key, Value>> result = scanner.iterator(); return new AccumuloNamespaceTableIterator(result); } catch (final Exception e) { throw new RyaDAOException(e); } }
protected String[] getTables() { // core tables final List<String> tableNames = Lists.newArrayList( tableLayoutStrategy.getSpo(), tableLayoutStrategy.getPo(), tableLayoutStrategy.getOsp(), tableLayoutStrategy.getNs(), tableLayoutStrategy.getEval()); // Additional Tables for (final AccumuloIndexer index : secondaryIndexers) { tableNames.add(index.getTableName()); } return tableNames.toArray(new String[]{}); }
private static final String[] EMPTY_STR_ARR = new String[0]; private TableLayoutStrategy tableLayoutStrategy = new TablePrefixLayoutStrategy();
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public CloseableIteration<Namespace, RyaDAOException> iterateNamespace() throws RyaDAOException { try { final Scanner scanner = connector.createScanner(tableLayoutStrategy.getNs(), ALL_AUTHORIZATIONS); scanner.fetchColumnFamily(INFO_NAMESPACE_TXT); final Iterator<Map.Entry<Key, Value>> result = scanner.iterator(); return new AccumuloNamespaceTableIterator(result); } catch (final Exception e) { throw new RyaDAOException(e); } }
public void setTablePrefix(final String tablePrefix) { Preconditions.checkNotNull(tablePrefix); set(CONF_TBL_PREFIX, tablePrefix); setTableLayoutStrategy(new TablePrefixLayoutStrategy(tablePrefix)); //TODO: Should we change the layout strategy }
public void setTablePrefix(final String tablePrefix) { Preconditions.checkNotNull(tablePrefix); set(CONF_TBL_PREFIX, tablePrefix); setTableLayoutStrategy(new TablePrefixLayoutStrategy(tablePrefix)); //TODO: Should we change the layout strategy }
/** * Creates an AccumuloRyaDAO after updating the AccumuloRdfConfiguration so that it is consistent * with the configuration of the RyaInstance that the user is trying to connect to. This ensures * that user configuration aligns with Rya instance configuration and prevents the creation of * new index tables based on a user's query configuration. This method requires the {@link AccumuloRyaInstanceDetailsRepository} * to exist. * * @param config - user's query configuration * @return - AccumuloRyaDAO with an updated configuration that is consistent with the Rya instance configuration * @throws AccumuloException * @throws AccumuloSecurityException * @throws RyaDAOException */ public static AccumuloRyaDAO getAccumuloDAOWithUpdatedConfig(final AccumuloRdfConfiguration config) throws AccumuloException, AccumuloSecurityException, RyaDAOException { final String ryaInstance = config.get(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX); Objects.requireNonNull(ryaInstance, "RyaInstance or table prefix is missing from configuration."+RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX); final String user = config.get(AccumuloRdfConfiguration.CLOUDBASE_USER); final String pswd = config.get(AccumuloRdfConfiguration.CLOUDBASE_PASSWORD); Objects.requireNonNull(user, "Accumulo user name is missing from configuration."+AccumuloRdfConfiguration.CLOUDBASE_USER); Objects.requireNonNull(pswd, "Accumulo user password is missing from configuration."+AccumuloRdfConfiguration.CLOUDBASE_PASSWORD); config.setTableLayoutStrategy( new TablePrefixLayoutStrategy(ryaInstance) ); updateAccumuloConfig(config, user, pswd, ryaInstance); return getAccumuloDAO(config); }
/** * Creates an AccumuloRyaDAO after updating the AccumuloRdfConfiguration so that it is consistent * with the configuration of the RyaInstance that the user is trying to connect to. This ensures * that user configuration aligns with Rya instance configuration and prevents the creation of * new index tables based on a user's query configuration. This method requires the {@link AccumuloRyaInstanceDetailsRepository} * to exist. * * @param config - user's query configuration * @return - AccumuloRyaDAO with an updated configuration that is consistent with the Rya instance configuration * @throws AccumuloException * @throws AccumuloSecurityException * @throws RyaDAOException */ public static AccumuloRyaDAO getAccumuloDAOWithUpdatedConfig(final AccumuloRdfConfiguration config) throws AccumuloException, AccumuloSecurityException, RyaDAOException { final String ryaInstance = config.get(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX); Objects.requireNonNull(ryaInstance, "RyaInstance or table prefix is missing from configuration."+RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX); final String user = config.get(AccumuloRdfConfiguration.CLOUDBASE_USER); final String pswd = config.get(AccumuloRdfConfiguration.CLOUDBASE_PASSWORD); Objects.requireNonNull(user, "Accumulo user name is missing from configuration."+AccumuloRdfConfiguration.CLOUDBASE_USER); Objects.requireNonNull(pswd, "Accumulo user password is missing from configuration."+AccumuloRdfConfiguration.CLOUDBASE_PASSWORD); config.setTableLayoutStrategy( new TablePrefixLayoutStrategy(ryaInstance) ); updateAccumuloConfig(config, user, pswd, ryaInstance); return getAccumuloDAO(config); }