To develop metro style application we can use languages like c#, javascript, html, c++ too...
Saturday, January 28, 2012
Windows 8 Programming Tutorials : Lets see what we can do on windows 8 and how.
Wednesday, January 25, 2012
Impliment And/Or multi condition in hbase.
Here FilterList listOfFiltersA and FilterList listOfFiltersB will impliment AND condition of the filters in the filter list and FilterList listOfFiltersC will impliment OR Condition on listOfFiltersA and listOfFiltersB
public static void multiConditionReturn() throws IOException
{
HTable hTable = new HTable("well");
Scan scan = new Scan();
FilterList listOfFiltersA = new FilterList(FilterList.Operator.MUST_PASS_ALL);
FilterList listOfFiltersB = new FilterList(FilterList.Operator.MUST_PASS_ALL);
FilterList listOfFiltersC = new FilterList(FilterList.Operator.MUST_PASS_ONE);
SingleColumnValueFilter nodeFilter;
nodeFilter = new SingleColumnValueFilter
(
Bytes.toBytes("cf"),
Bytes.toBytes("well_name"),
CompareOp.EQUAL,
Bytes.toBytes("AB Test Well")
);
listOfFiltersA.addFilter(nodeFilter);
nodeFilter = new SingleColumnValueFilter
(
Bytes.toBytes("cf"),
Bytes.toBytes("well_region"),
CompareOp.EQUAL,
Bytes.toBytes("Region Name")
);
listOfFiltersA.addFilter(nodeFilter);
nodeFilter = new SingleColumnValueFilter
(
Bytes.toBytes("cf"),
Bytes.toBytes("wellDatum_name"),
CompareOp.EQUAL,
Bytes.toBytes("Kelly Bushing")
);
listOfFiltersB.addFilter(nodeFilter);
nodeFilter = new SingleColumnValueFilter
(
Bytes.toBytes("cf"),
Bytes.toBytes("well_uid"),
CompareOp.EQUAL,
Bytes.toBytes("BGC_TD")
);
listOfFiltersB.addFilter(nodeFilter);
listOfFiltersC.addFilter(listOfFiltersA);
listOfFiltersC.addFilter(listOfFiltersB);
scan.setFilter(listOfFiltersC);
ResultScanner scanner = hTable.getScanner(scan);
for (Result result : scanner) {
System.out.println(result);
}
}
public static void multiConditionReturn() throws IOException
{
HTable hTable = new HTable("well");
Scan scan = new Scan();
FilterList listOfFiltersA = new FilterList(FilterList.Operator.MUST_PASS_ALL);
FilterList listOfFiltersB = new FilterList(FilterList.Operator.MUST_PASS_ALL);
FilterList listOfFiltersC = new FilterList(FilterList.Operator.MUST_PASS_ONE);
SingleColumnValueFilter nodeFilter;
nodeFilter = new SingleColumnValueFilter
(
Bytes.toBytes("cf"),
Bytes.toBytes("well_name"),
CompareOp.EQUAL,
Bytes.toBytes("AB Test Well")
);
listOfFiltersA.addFilter(nodeFilter);
nodeFilter = new SingleColumnValueFilter
(
Bytes.toBytes("cf"),
Bytes.toBytes("well_region"),
CompareOp.EQUAL,
Bytes.toBytes("Region Name")
);
listOfFiltersA.addFilter(nodeFilter);
nodeFilter = new SingleColumnValueFilter
(
Bytes.toBytes("cf"),
Bytes.toBytes("wellDatum_name"),
CompareOp.EQUAL,
Bytes.toBytes("Kelly Bushing")
);
listOfFiltersB.addFilter(nodeFilter);
nodeFilter = new SingleColumnValueFilter
(
Bytes.toBytes("cf"),
Bytes.toBytes("well_uid"),
CompareOp.EQUAL,
Bytes.toBytes("BGC_TD")
);
listOfFiltersB.addFilter(nodeFilter);
listOfFiltersC.addFilter(listOfFiltersA);
listOfFiltersC.addFilter(listOfFiltersB);
scan.setFilter(listOfFiltersC);
ResultScanner scanner = hTable.getScanner(scan);
for (Result result : scanner) {
System.out.println(result);
}
}
Tuesday, January 24, 2012
How to delete a specific row or given rows in hbase using java code
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package witsml131;
import java.io.IOException;
import java.util.ArrayList;
import javax.security.auth.login.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.util.Bytes;
/**
*
* @author shashwat
*/
public class DeleteFromHbase {
public static void main(String[] args) throws IOException {
HTable table = new HTable("well");
ArrayList<String> rowsToDelete = new ArrayList(); //array with all rows names to delete.
Delete del = new Delete(Bytes.toBytes("2"));//for single row named 2
table.delete(del);
//deleting all rows in rowsToDelete in array list rowsToDelete
for (String rows : rowsToDelete) {
del = new Delete(Bytes.toBytes(rows));//for single row named 2
table.delete(del);
}
table.close();
}
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package witsml131;
import java.io.IOException;
import java.util.ArrayList;
import javax.security.auth.login.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.util.Bytes;
/**
*
* @author shashwat
*/
public class DeleteFromHbase {
public static void main(String[] args) throws IOException {
HTable table = new HTable("well");
ArrayList<String> rowsToDelete = new ArrayList(); //array with all rows names to delete.
Delete del = new Delete(Bytes.toBytes("2"));//for single row named 2
table.delete(del);
//deleting all rows in rowsToDelete in array list rowsToDelete
for (String rows : rowsToDelete) {
del = new Delete(Bytes.toBytes(rows));//for single row named 2
table.delete(del);
}
table.close();
}
}
How can I get it to parse XML contained within a String instead of a file?
public static Document loadXMLFromString(String xml) throws Exception
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource is = new InputSource(new StringReader(xml));
return builder.parse(is);
}
Comparing StAX to Other JAXP APIs
As an API in the JAXP family, StAX can be compared, among other APIs, to
SAX, TrAX, and JDOM. Of the latter two, StAX is not as powerful or
flexible as TrAX or JDOM, but neither does it require as much memory or
processor load to be useful, and StAX can, in many cases, outperform the
DOM-based APIs. The same arguments outlined above, weighing the
cost/benefits of the DOM model versus the streaming model, apply here.
With this in mind, the closest comparisons between can be made between
StAX and SAX, and it is here that StAX offers features that are
beneficial in many cases; some of these include:
Thursday, January 19, 2012
Working with Pushpins in the Map Control
To add a basic pushpin, create the pushpin object and add it as a child to the map. The following example allows the user to push a button that adds a pushpin to the center of the current map view.
<phone:PhoneApplicationPage
x:Class="WindowsPhoneApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True" xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps">
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<my:Map Height="427" HorizontalAlignment="Left" Margin="12,6,0,0" Name="map1" VerticalAlignment="Top" Width="438" />
<Button Content="Add Center Pushpin" Height="72" HorizontalAlignment="Left" Margin="90,467,0,0" Name="button1" VerticalAlignment="Top" Width="297" Click="button1_Click" />
</Grid>
</Grid>
</phone:PhoneApplicationPage>
Use the Bing Maps Silverlight Control for Windows Phone(Source MSDN)
- Make sure you have downloaded and installed the Windows Phone SDK from the App Hub.
- Launch Visual Studio 2010 Express for Windows Phone from the Windows Start menu.
- Create a new project by clicking the File | New Project menu command.
- The New Project window will be displayed. Expand the Visual C# templates, and then select the Silverlight for Windows Phone templates.
- Select the Windows Phone Application template. Fill in the project Name as desired.
- Click OK. A new project will be created and MainPage.xaml will be opened in the Visual Studio designer window.
The next step is to lay out the controls of the application using the Visual Studio designer. After adding the controls, the final layout will look similar to the following screenshot:
To add the controls of the application
Subscribe to:
Posts (Atom)
Featured Posts
Learn how to install Apache, MySQL and PHP on Ubuntu. Complete LAMP stack installation guide with one-shot commands, PHP testing and php-opcache troubleshooting
How to Install LAMP Stack on Ubuntu | Complete Guide UBUNTU • LINUX • SERVER • PHP ...
-
public struct CoOrds { public int x, y; public CoOrds( int p1, int p2) { x = p1; y = p2; } }
-
LM Studio Overview LM Studio is a desktop application designed for developing and experimenting with large language models (LLMs)...