How can I perform efficient Deletions in Accumulo across multiple ranges? - accumulo

I have an index table with the following schema:
Row CF CQ
Name POB DOB
How could I efficiently delete multiple rows (i.e. John Doe:New York:01/01/75 , Jane Doe:Miami:06/21/80)?

Use a BatchDeleter and setRanges of all the Range (rows) that you want to delete
https://accumulo.apache.org/1.7/apidocs/org/apache/accumulo/core/client/BatchDeleter.html

BatchDeleter deleter= conn.createBatchDeleter("Table Name", new Authorizations(), 1, config);
Collection<Range> ranges = new ArrayList<Range>();
Scanner tableScannerRange= conn.createScanner("TableName", new Authorizations());
tableScannerRange.setRange(new Range("XXXX"));
for (Entry<Key, Value> entry : tableScannerRange) {
ranges.add(new Range(entry.getKey().getRow()));
}
deleter.setRanges(ranges);
deleter.delete();

Or Use Put Delete
Mutation mutation_data = new Mutation(" ");
mutation_data.putDelete(CF,CQ);

Related

How to list and remove duplicate values using mongoose

Following the comments on Mongoose: how to define a combination of fields to be unique?
First let's get the array of data sorted by all values which supposed to be unique.
Assuming we're talking about strings (as in this question), we can combine them to create one long string that is supposed to be unique.
Being sorted, if there are duplicate values they'll show up right after the other, so let's look for results that repeat themselves:
var previousName;
Person.find().sort('firstName lastName').exec().each(function (person) {
var name = person.firstName + person.lastName;
if (name == previousName) {
console.log(name);
person.remove();
}
previousName = name;
})

BatchScanner with limits per range

Is there a way to get first n whole rows using BatchScanner for each range.
I would like to pull latest user activity for multiple users up to say 100 whole rows per user. Row key starts with user id followed with timestamp.
Thanks,
Dejan
Dejan -- Take a look at the WholeRowIterator. Here's some example code for how you would use it.
Connector conn = getConnector();
BatchScanner bs = conn.createBatchScanner("mytable", new Authorizations(), 4);
IteratorSetting iterator = new IteratorSetting(100, WholeRowIterator.class);
bs.addScanIterator(iterator);
for (Entry<Key,Value> entry : bs) {
SortedMap<Key,Value> row = WholeRowIterator.decodeRow(entry.getKey(), entry.getValue());
}

LinqToExcel:How to get specific row in Excel

I have an excel that looks like
ID Name DepartmentID Ext
1298 Alice AA1152 1221
1299 Andrew AA1152 1235
2894 Jack AA1152 1285
2723 Daniel AA1152 4239
All employees are in the same department, and I want to get the DepartmentID from excel to link to the department name in database.
I've read this tutorial http://www.codeproject.com/Articles/659643/Csharp-Query-Excel-and-CSV-Files-Using-LinqToExcel but it has to read the entire file and access sequentially in foreach loop.
How can I get only one row from excel using LinqToExcel library?
Thanks a lot.
You should be able to use First() to return only the first result :
var artistAlbums = from a in excelFile.Worksheet(sheetName) select a;
var firstAlbum = artistAlbums.First();
And to get one specific row, combine Skip() and First(), for example :
var fifthAlbum = artistAlbums.Skip(4).First();
Try something like this
var excelData = new ExcelQueryFactory(excelFileName);
var yourRow = from c in excelData.Worksheet<YourMappedClass>(WorksheetName) where c.Id==SomeValue select c;
There are quite a few other things you can accomplish as well as explained in their github page.

Entity Framework 4.1 & existing database

Hi I have an existing database with a table with 30 fields, I want to split the table into many models so I could retrieve/save fields that I need and not every time retrieve/save the whole object from the db. using c#.
I think I should be using Code-First. Could someone provide an example or a tutorial link?
thanks,
You don't need to split table to be able to load a subset of field or persist subset of fields. Both operations are available with the whole table mapped to single entity as well.
For selection you simply have to use projection:
var data = from x in context.HugeEntities
select new { x.Id, x.Name };
You can use either anonymous type in projection or any non-mapped class.
For updates you can simply use:
var data = new HugeEntity { Id = existingId, Name = newName };
context.HugeEntities.Attach(data);
var dataEntry = context.Entry(data);
dataEntry.Property(d => d.Name).IsModified = true; // Only this property will be updated
context.SaveChanges();
Or:
var data = new HugeEntity { Id = existingId };
context.HugeEntities.Attach(data);
data.Name = newName;
context.SaveChanges(); // Now EF detected change of Name property and updated it
Mapping multiple entities to single table must follows very strict rules and it is possible only with table splitting were all entities must be related with one-to-one relation (and there are some problems with more than two entities per split table in code first) or with table-per-hierarchy inheritance. I don't think that you want to use any of them for this case.

duplicated column name when using join with Zend_Db_table

I have two tables. Both of them have a column named 'title'. When I use the following code snippet to join two tables, I can't access one of the title column.
$select = $this->select(Zend_Db_Table::SELECT_WITH_FROM_PART);
$select->setIntegrityCheck(false);
$select->join("service","service.id = lecture.service_id");
return $select;
is there a way to access both columns?
You need to rename one of the columns so it doesn't conflict with the other. If you pass an array as the optional 3rd argument to join(), you can specify which columns to retrieve from the joined table. If one or more of the entries in the array is hashed, then the hash key will be used as the property name. With the code below, you can refer to the title column of the service table as "service_title" in your query results. If you want other columns from the service table, add them to the array, with or without hashes as desired.
$select = $this->select(Zend_Db_Table::SELECT_WITH_FROM_PART);
$select->setIntegrityCheck(false);
$select->join("service", "service.id = lecture.service_id",
array("service_title" => "service.title");
return $select;
$select = $this->select();
$select->from(array('t'=>'table1'), array('table_title AS title_first','table_sendo_colun','table_third_colun'));
$select->setIntegrityCheck(false);
$select->join("service","service.id = t.service_id");
return $select;
Maybe It can do the job.
RegardĀ“s.

Resources