Set up Accumulo table through api - java

new to Accumulo, and this may sound silly, but I was wondering how to setup a table through the api? The documentation is definitely lacking. I have been able to find
conn.tableOperations().createTable("myTable");
as well as like setting up locality groups:
HashSet<Text> metadataColumns = new HashSet<Text>();
metadataColumns.add(new Text("domain"));
metadataColumns.add(new Text("link"));
HashSet<Text> contentColumns = new HashSet<Text>();
contentColumns.add(new Text("body"));
contentColumns.add(new Text("images"));
localityGroups.put("metadata", metadataColumns);
localityGroups.put("content", contentColumns);
conn.tableOperations().setLocalityGroups("mytable", localityGroups);
Map<String, Set<Text>> groups =
conn.tableOperations().getLocalityGroups("mytable");
From the documentation, but I want to know how to take the first approach and build the table. Then build the columns.
Thanks in advance!

There is no inherent schema for a table to set up. Once it is created using the API you found, you can insert whatever key-value pairs you wish in it.

Related

Problems with queryBuilder greenDAO

I am using latest version of GreenDAO... I am missing something on using the data from the DB.
I need to prevent the creation of records that have the same PROFILE_NUMBER. Currently during testing I have inserted 1 record with the PROFILE_NUMBER of 1.
I need someone to show me an example of how to obtain the actual value of the field from the db.
I am using this
SvecPoleDao svecPoleDao = daoSession.getSvecPoleDao();
List poles = svecPoleDao.queryBuilder().where(SvecPoleDao.Properties.Profile_number.eq(1)).list();
and it obtains something... this.
[com.example.bobby.poleattachmenttest2_workingdatabase.db.SvecPole#bfe830c3.2]
Is this serialized? The actual value I am looking for here is 1.
Here is the solution.You'll need to use listlazy() instead of list().
List<SvecPole> poles = svecPoleDao.queryBuilder().where(SvecPoleDao.Properties.Profile_number.eq(1)).listLazy();

Hbase Single Query to Return all the column from Multiple Column Family

Iam new to the Hbase. I would to like to know how to retrieve all the columns from two column family in Single Query using Java API, and please provide me the link which will give the brief about Hbase internal architecture.
You can adding multiple column families with "addFamily" method.
Get get = new Get(rowKey);
get.addFamily(columnFamily1);
get.addFamily(columnFamily2);
(if you use the "scan")
Scan scan = new Scan(startRowKey, stopRowKey);
scan.addFamily(columnFamily1);
scan.addFamily(columnFamily2);
And about the document, you can find everything in hbase book which in the hbase website.
https://hbase.apache.org/2.0/book.html

Adding new columns to Schema of BigQuery Table in Java

I am looking for ways to update Schema of an existing table in BigQuery. I could see doing the same in python here which is an API Request. I wanted to see this in Java and going through documentation and source code I could find
TableDefinition tableDefinition = StandardTableDefinition.of(schema);
table.toBuilder().setDefinition(definition)
But it rewrites the whole schema. Other possible of ways of updating schema can be found here
Can someone guide me regarding adding new columns to existing table in BigQuery using Java ?
Have a look in this github issue. You need to specify the entire schema again -including your new cols.

Java QueryDsl for "update myTable where myColumn in ('interesting', 'values')"?

I'm trying to translate this query in QueryDsl:
update myThings set firstColumn = 'newValue' where secondColumn in ('interesting', 'stuff')
I spent hours looking for documentation but the java fu is just not strong enough in this one... :( I can find all kinds of QueryDsl example, but I cant find any for this. I will probably need SimpleExpression.eqAny(CollectionExpression), but I can't figure out how to build such a CollectionExpression around my simple list of strings.
List<String> interestingValues = Arrays.asList("interesting", "stuff");
queryFactory.update(myThings)
.set(myThings.firstColumn, "newValue")
// .where(myThings.secondColumn.in(interestingValues)
// 'in' will probably try to look in table "interestingValues"?
// .where(myThings.secondColumn.eqAny(interestingValues)
// 'eqAny' seems interesting, but doesn't accept a list
.execute();
All I can find is API definitions, but then I get lost in generics any other "new" java concepts which I still have trouble understanding. An example would be very much appreciated.
You have to use new JPAUpdateClause(session, myThings):
JPAUpdateClause<myThings> update = new JPAUpdateClause(session, myThings);
update.set(myThings.firstColumn, "newValue")
.where(myThings.secondColumn.in(interestingValues))
.execute();
If you are using hibernate, use HibernateUpdateClause() instead;

Lotus getting field from database

I am new to lotus. I need to get some info from Lotus database with Java. I have database:
Session session = NotesFactory.createSession(host, user, pwd);
Database database = session.getDatabase(server, database);
I have that info:
field - fldContractorCode;
form - form="formAgreement";
For example field is "abcde";
So how I can get info from that database? I need to use seatch formula? Or what methods I need to use? Thanx for help.
UPD
Now I am using such way:
DocumentCollection collection = DATABASE.search("form=\"formAgreement\"");
Document doc = collection.getFirstDocument();
while(doc != null) {
doc.getItemValueString("fldContractorCode");
doc = collection.getNextDocument();
}
And it works fine for me, but I think that way is not very comfortable because to find some document for example with field="abcd" I need to itearte over collection every time...
So that why I am asking for some way to find document by the field value. And I dont understand what is VIEW in database and where to get this VIEW name.
In your existing code, you can just change one line:
DocumentCollection collection = DATABASE.search("form=\"formAgreement\ & "fldContractorCode=\"abcd\"");
However, this will be slow if the database contains many documents. For best performance, you should consider using Domino Designer to add a new view to your database and using the getDocumentByKey() method suggested in the other answers. If that is not an option, Simon's suggestion of using the FTSearch() method is faster than the Search() method, but only if a full text index exists for the database. It also has a slightly different syntax for the search string.
There are a number of ways to get the document.
1. Search for the document from a view, where the first column of the view contains a sorted value of the fldContractorCode.
For example:
String key = "abide";
View view = db.getView("viewName");
Document doc = view.getDocumentByKey(key, true);
2. You can use the Database FTSearch Method to do a full text search to find the document. You will need the database to have a full text index created.
3. If you know the UNID or notes ID of the document you can use getDocumentByUNID() or getDocumentByID().
Your question is quite broad, so I recommend reading the Infocenter as it details sample code for each method.
http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/topic/com.ibm.designer.domino.main.doc/H_NOTESDATABASE_CLASS_JAVA.html
You will have to drill down to the DOCUMENT (not Form) you want to retrieve the field from.
Lotus Notes has a very easy to understand hierarchical way to get to where you want. You will need to instantiate objects in this sequence:
Session
Database
View
Document
Let's say you have a view called $(sysAgreements) that list all forms "formAgreement".
Its selection formula would be something like this:
SELECT Form="formAgreement"
To get to the document or documents you want you will do something like this:
Session session = NotesFactory.createSession(host, user, pwd);
Database database = session.getDatabase(server, database);
View view = database.getView("$(sysAgreements)");
Document doc = view.getDocumentByKey(VIEW_KEY);
String fieldContent = doc.getItemValueString("fldContractorCode");
There are several ways to retrieve info from a Notes database. This is one of them. Bear in mind that they key used by Notes to search a view with getDocumentByKey is the 1st sorted column.
If you want to get multiple documents you can use:
DocumentCollection docCol = view.getAllDocumentsByKey(VIEW_KEY);
and then iterate over it.
Avoid doing ftsearch because it's slow and a bit painful to Notes. Prefere looking up in the views.
Also another powerful source of help is the Notes help. Get the help database from a computer that has the Notes Development Client installed. But pay attention to the name of the help you're picking, there are 3 helps in Notes: the client, development and administration. Development is what you want.

Categories

Resources