Comments (2)
Support the following syntax:
CREATE TABLE foo (
host_name varchar,
created_date date
constraint my_pk primary key (host_name ASC, created_date DESC));
also this:
CREATE TABLE foo (
id varchar PRIMARY KEY DESC,
created_date date);
By default, the row key order would be ascending, but this could be overridden as shown above.
The implementation should all be mostly isolated to PDataType. However, the sort order would need to be stored in the SYSTEM.TABLE metadata table, in the row representing the column. The order value would cached in PColumn and passed through the PDataType methods. Check out the elegant way that Orderly does the writing, by having a mask on an Order enum and xor-ing like this:
/** The sort order of a row key, ascending or descending. */
public enum Order
{
ASCENDING((byte)0),
DESCENDING((byte)0xff);
private final byte mask;
Order(byte mask) { this.mask = mask; }
/** Gets the byte mask associated with the sort order. When a
* serialized byte is XOR'd with the mask, the result is the same byte
* but sorted in the direction specified by the Order object.
* @see RowKey#serialize
*/
byte mask() { return mask; }
}
public class FixedIntWritableRowKey extends RowKey
{
private IntWritable iw;
@Override
public Class getSerializedClass() { return IntWritable.class; }
@Override
public int getSerializedLength(Object o) throws IOException {
return Bytes.SIZEOF_INT;
}
@Override
public void serialize(Object o, ImmutableBytesWritable w)
throws IOException
{
byte[] b = w.get();
int offset = w.getOffset();
int i = ((IntWritable)o).get();
Bytes.putInt(b, offset, i ^ Integer.MIN_VALUE ^ order.mask());
RowKeyUtils.seek(w, Bytes.SIZEOF_INT);
}
@Override
public void skip(ImmutableBytesWritable w) throws IOException {
RowKeyUtils.seek(w, Bytes.SIZEOF_INT);
}
@Override
public Object deserialize(ImmutableBytesWritable w) throws IOException {
int offset = w.getOffset();
byte[] s = w.get();
int i = Bytes.toInt(s, offset) ^ Integer.MIN_VALUE ^ order.mask();
RowKeyUtils.seek(w, Bytes.SIZEOF_INT);
if (iw == null)
iw = new IntWritable();
iw.set(i);
return iw;
}
}
from phoenix.
Fixed by @simontoens, with a new record of a 78 file change list for his first Phoenix contribution! Thanks for the awesome work.
from phoenix.
Related Issues (20)
- Got TableNotFoundException when upgrading from Phoenix 2.2.x HOT 1
- Not able to see the table in hbase
- java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
- encounter Error: (state=08000,code=101), when we create index on bigtable HOT 19
- Creating Empty Column Families with CREATE Table HOT 1
- why am i select data slow? HOT 2
- Add REGEXP_LIKE buit-in function HOT 2
- When I run the Phoenix over my hbase cluster I meet the warning below HOT 2
- phoenix map hbase table , phoenix data content is not correct HOT 1
- ERROR 1012 (42M03): Table undefined HOT 6
- How to use phoenuix to map to an Existing HBase Table
- what situation does index works? HOT 1
- how can i use UPSERT VALUES? HOT 1
- Exception on upserting data on table with using upsert select
- Query a Secure HBase cluster through Phoenix In Java code HOT 2
- Offtopic Question: Bloom Filter Implementation In Apex
- Phoenix View for HBase is not updating
- Operations on table throw exception: ArrayIndexOutOfBoundsException & DoNotRetryIOException
- Phoenix issue-Distribution-IBM BigInsights- Hbase(1.1.1)-Phoenix 4.7 HOT 1
- Phoenix View on pre-existing HBase namespace table? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phoenix.